Your first web page
You open a plain text editor, type a doctype and three elements, save the file with an .html extension, and double-click it. A browser renders a heading and a paragraph. Adding one linked stylesheet changes the colours and spacing. That whole path is what this page walks through, in order, with the starter tags and the first CSS properties you will actually use.
Stage by stage
| Property | Example value | What it changes |
|---|---|---|
| color | navy | Text colour of the selected element |
| font-size | 18px | Size of the text, in pixels |
| background-color | #f5f5f5 | Background behind the element |
| margin | 16px | Space outside the element's border |
| padding | 12px | Space inside the element's border |
| max-width | 720px | Maximum line length before wrapping |
Write one HTML file with a doctype and three elements, open it in a browser, then add one linked stylesheet.
An HTML document starts with a <!DOCTYPE html> declaration followed by the html, head and body elements. Everything else on the page lives inside those three. The head carries the title and the link to the stylesheet; the body carries what a visitor sees.
HTML elements are marked with tags in angle brackets, and most elements have an opening and a closing tag. The opening tag for a paragraph is <p> and the closing tag is </p>. Text goes between them.
A stylesheet is linked to a page with one link element with rel=stylesheet in the head element. That single line is what connects style.css to index.html; without it the page renders in the browser's default style.
The procedure, the element list and the property list were built from the published HTML and CSS specifications and from the common failures reported at each stage. Stage times are typical budgets for a first attempt and vary with the editor in use.
Reference points
Reference points: the late-1991 HTML description, the 1994 CSS proposal, the 1996 CSS1 Recommendation and the 2014 HTML5 Recommendation.