Not a member? or Register

Style Guide Post

Markup Guide

Within this document, references will be made to elements and attributes. It’s important to understand the difference, so consider this sample code:

<a href="index.php">Home</a>

The base HTML element is the a in this case. The attribute is any additional information about that element within the initial < > pair, or the href value in this case.

To view the example usage for any item within this document, please view its source.


Header Examples

The main page header of this guide is an h1 element. Please reserve h1 for individual page titles only. Any header elements may include links, as depicted in the example.

The secondary header above is an h2 element, which may be used for any form of important page-level header. More than one may be used per page. Consider using an h2 unless you need a header level of less importance, or as a sub-header to an existing h2 element. Any header level may include links, as depicted in the example.

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

For all headers below third-level, follow the guidelines listed above. Only use lower header levels when necessary.

Fifth-Level Header

For all headers below third-level, follow the guidelines listed above. Only use lower header levels when necessary.

Sixth-Level Header

For all headers below third-level, follow the guidelines listed above. Only use lower header levels when necessary.


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:

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Cras euismod fringilla arcu. Integer posuere. Aliquam ipsum. Donec eget massa ac orci tempus euismod. Donec quis neque nec neque consequat sollicitudin. Donec commodo tempor nulla. Suspendisse venenatis. Ut ut leo. Nunc placerat urna at libero. Nunc suscipit lacus.

lipsum.com

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 cite element.)


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, kbd, strong, and var.

abbr
Used for any abbreviated text, whether it be 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 getJello() { echo $aDeliciousSnack; }

Inline usage: just like elsewhere in this document, HTML elements like em or code 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 inc a strikethrough line, it’s preferable to the s element. The del element also has a datetime attribute which allows you to include a timestamp directly in the element. Example deleted text and usage: She bought two five 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 the em 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 an i element or a span 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. Like del, ins has a datetime attribute which allows you to include a timestamp directly in the element. Example inserted text and usage: She bought two five 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.
strong
Used for denoting stronger emphasis than the em element. In most instances where you’d want to bold text (using the HTML element b or otherwise) you should use the strong 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, so b element or a span 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.
small
The small element represents side comments such as small print.
s
The s element represents contents that are no longer accurate or no longer relevant. When indicating document edits, use the del instead.
q
The q element represents some phrasing content quoted from another source. as stated on w3.org wiki.
dfn
The HTML is the publishing language of the World Wide Web.
samp
The samp element represents output from a program or computing system. If you input a wrong value, it is displayed as error!!
mark
The markelement represents a run of text in one document marked or highlighted for reference purposes, due to its relevance in another context.

Look around and you will find, no-one’s really colour blind.

As we can tell from the spelling of the word, the person writing this quote is clearly not American.


Subscripts and Superscripts

In order to test how subscripts and superscripts (sub and sup markup) work inside running text, we need some dummy text around constructs like x1 and H2O (where subscripts occur). So here is some fill so that you will (hopefully) see whether and how badly the subscripts and superscripts mess up vertical spacing between lines. Now superscripts: Mlle, 1st, and then some mathematical notations: ex, sin2 x, and some nested superscripts (exponents) too: Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.


Address

John Doe LLC
111 Example Avenue
13341 Ano Liosia
Athens, Greece
Phone: +39 210 123 4567
web : www.singeridis.com/markup/
email : me@example.com

Figure and figcaption

The figure element represents some flow content.


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.
  1. This is an ordered list.
  2. It has two items.
  3. No, I lied, it has three.
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 accompanying dd, but in that case they share descriptions with the next available dt. You may not have a dd without a parent dt.

Tables

The following table has a caption. The first row and the first column contain table header cells only; other cells are data cells.

Caption: Sample table: Areas of some countries, in sq km
Country Total area Land area
Copyright…
Greece 131,990 130,800
Finland 337,030 305,470
Iceland 103,000 100,250
Norway 324,220 307,860
Sweden 449,964 410,928

0saves
If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

Post a Comment