Styleguide
A basic guide to semantic markup, including proper usage examples.
The paragraph above has a class of leader
.
Header Examples
The main page header of this guide is an h1
element. Please reserve h1
for individual page titles only.
Third-Level Header
The header above is an h3
element, which may be used for any form of page-level header which falls below the h2
header in a document hierarchy. More than one may be used per page.
Fourth-Level Header
The header above is an h4
element, which may be used for any form of page-level header which falls below the h3
header in a document hierarchy. More than one may be used per page.
Paragraphs
All paragraphs are wrapped in p
tags. Additionally, p
elements can be wrapped with a blockquote
element if the p
element is indeed a quote. Historically, blockquote
has been used purely to force indents, but this is now achieved using CSS. Reserve blockquote
for quotes. Here’s an example of correct usage:
Many forms of Government have been tried and will be tried in this world of sin and woe. No one pretends that democracy is perfect or all-wise.
Indeed, it has been said that democracy is the worst form of government except all those other forms that have been tried from time to time.
Additionally, you might wish to cite the source, as in the above example. (The correct method involves the cite
attribute directly applied to the blockquote
element, but since no browser makes any use of that information whatsoever, it’s useful to also specify the standalone footer
element as detailed at html5doctor.com/blockquote-q-cite/.)
Inline Text
You might have noticed all the monospaced text in this guide. There are a number of inline HTML elements you may use anywhere within other elements, including abbr, cite, code
, del, em, ins, strong, and var.
- abbr
- Used for any abbreviated text, whether it be acronym, initialism, or otherwise. Generally, it’s less work and useful (enough) to mark up only the first occurence of any particular abbreviation on a page, and ignore the rest. Any text in the
title
attribute will appear when the user’s mouse hovers the abbreviation (although notably, this does not work in Internet Explorer for Windows). Example abbreviations and usage: NASA, HTML, and Mass. code
-
Used for computer code samples. Useful for technology-oriented sites, not so useful otherwise. Example code and usage:
function getJelly() { echo $aDeliciousSnack; }
With line numbers:
<?php
echo 'Hello World!';
?>
Inline usage: just like elsewhere in this document, HTML elements like
em
orcode
can be considered code, and marked up as such. - cite
- Used for defining a citation or reference to other information sources. Example cited text and usage: More information can be found in [ISO-0000]
del- Used for deleted or retracted text which still must remain on the page for some reason. Since the default style includes a strikethrough line, it’s preferable to the
s
element. Thedel
element also has adatetime
attribute which allows you to include a timestamp directly in the element. Example deleted text and usage: She boughttwofive pairs of shoes. - em
- Used for denoting emphasized text. In most instances where you'd want to italicize text (using the HTML element
i
or otherwise) you should use theem
element instead. Notable exceptions are stylistic italicizing of proper titles, foreign languages, etc. where italicizing is used for differentiation instead of emphasis. In those cases, no proper HTML elements exist, so ani
element or aspan
element with a custom class may be preferable. Example emphasized text and usage: You simply must try the negitoro maki! - ins
- Used for inserted text and counterpart to the
del
element. Likedel
,ins
has adatetime
attribute which allows you to include a timestamp directly in the element. Example inserted text and usage: She boughttwofive pairs of shoes. - kbd
- Used for text which should be typed by the user. Mainly useful for computer instructions. Example keyboard text and usage: Please press Enter to continue.
q
-
Used for quoting inline. Example usage illustrating nested quotations:
John said,
I saw Lucy at lunch, she told me
Mary wants you to get some ice cream on your way home
. I think I will get some at Ben and Jerry’s, on Gloucester Road. - strong
- Used for denoting stronger emphasis than the
em
element. In most instances where you'd want to bold text (using the HTML elementb
or otherwise) you should use thestrong
element instead. Notable exceptions are stylistic bolding of examples, first occurences of names in an article, etc. where bolding is used for differentiation instead of emphasis. In those cases, no proper HTML elements exist, sob
element or aspan
element with a custom class may be preferable. Example strong text and usage: Don't stick nails in the electrical outlet. - var
- Used for variables within computer code snippets. Useful for technology-oriented sites, not so useful otherwise. Example code and usage: Add 5 to $result and recalculate.
Lists
Then there are the lists. ul
denotes an unordered list (ie. a list of loose items that don't require numbering, or a bulleted list). ol
denotes an ordered list, and various numbering schemes are available through the CSS (including 1,2,3... a,b,c... i,ii,iii... and so on). Each item within the ul
or ol
requires a surrounding <li>
and </li>
tag, to denote individual items within the list (as you may have guessed, li
stands for list item).
Additionally, dl
is another list type called a definition list. Instead of list items, the content of a dl
consists of dt
(Definition Term) and dd
(Definition description) pairs. Though it may be called a "definition list", dl
can apply to other scenarios where a parent/child relationship is applicable. For example, it may be used for marking up dialogues, with each dt
naming a speaker, and each dd
containing his or her words.
Example lists and usage:
- This is an unordered list.
- It has two items.
- This is an ordered list.
- It has two items.
- No, I lied, it has three.
-
Sometimes we want lists to contain block elements, like paragraphs. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus condimentum venenatis eros ac condimentum. Morbi elit odio, imperdiet at ornare vel, auctor in turpis. In hac habitasse platea dictumst. Nulla facilisi. Aliquam fermentum lobortis turpis non porttitor.
-
Shall we do that again? Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus condimentum venenatis eros ac condimentum. Morbi elit odio, imperdiet at ornare vel, auctor in turpis. In hac habitasse platea dictumst. Nulla facilisi. Aliquam fermentum lobortis turpis non porttitor.
- This is a term.
- This is the definition of that term, which both live in a
dl
. - Here is another term.
- And it gets a definition too, which is this line.
- Here is term that shares a definition with the term below.
- Here is a defined term.
dt
terms may stand on their own without an accompanyingdd
, but in that case they share descriptions with the next availabledt
. You may not have add
without a parentdt
.
Tables
Tables should be used when displaying tabular data. The thead
, tfoot
and tbody
elements enable you to group rows within each a table.
If you use these elements, you must use every element. They should appear in this order: thead
, tfoot
and tbody
, so that browsers can render the foot before receiving all the data. You must use these tags within the table element.
Ingredients | Serves 12 | Serves 24 |
---|---|---|
Milk | 1 quart | 2 quart |
Cinnamon Sticks | 2 | 1 |
Vanilla Bean, Split | 1 | 2 |
Cloves | 5 | 10 |
Mace | 10 blades | 20 blades |
Egg Yolks | 12 | 24 |
Cups Sugar | 1 ½ cups | 3 cups |
Dark Rum | 1 ½ cups | 3 cups |
Brandy | 1 ½ cups | 3 cups |
Vanilla | 1 tbsp | 2 tbsp |
Half-and-half or Light Cream | 1 quart | 2 quart |
Freshly grated nutmeg to taste |
Columns
Half columns
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Third columns
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Quarter columns
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Third columns with two-thirds/third columns
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Third columns with third/two-third columns
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Quarter columns with a three quarters column
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat dolor in reprehenderit in voluptate velit.