G

 

Semantics

 

<< Previous    [1]  2  3    Next >>

Writing Semantic HTML

Writing Semantic HTML
By Jesse Skinner

Semantic HTML means using HTML tags for their implied meaning, rather than just using (meaningless) div and span tags for absolutely everything. Why would you want to do this? Depending on the tag, the content in the tag can be interpreted in a certain way. Here are some examples.

Header tags

If you use < h1 > instead of < div class="header" >, and < h2 > instead of < div class="subheader" >, et cetera, Google and other search engines will interpret your headers as being important titles in your page. This way, when people search on the words in your headers and sub-headers, your page will be considered more relevant (and rank higher). Plus, it's much shorter and cleaner.

This works both ways: don't use header tags for anything except headers, especially not increasing your font size or outlining your search engine keywords. This way, your page can be parsed for structure (you can do this with the W3C HTML Validator). This structure can then be used by screen readers or other tools to build a table of contents for your page.

Form labels

The < label > tag is so sadly forgotten. It's not immediately clear what the point of using it is, so very few web pages take advantage of it. The label tag is used to identify a label for an input field, for example "E-mail Address". It can either be used be wrapping it around the text and input field like: < label >First Name: < input name="fname"/ >, or it can be used with the for attribute like so: < label for="fname" >First Name: < input id="fname" name="fname" />.

<< Previous    [1]  2  3    Next >>