Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is semantic markup, and why would I want to use that?

Like it says.

like image 758
Dustman Avatar asked Sep 23 '08 01:09

Dustman


Video Answer


2 Answers

Using semantic markup means that the (X)HTML code you use in a page contains metadata describing its purpose -- for example, an <h2> that contains an employee's name might be marked class="employee-name". Originally there were some people that hoped search engines would use this information, but as the web has evolved semantic markup has been mostly used for providing hooks for CSS.

With CSS and semantic markup, you can keep the visual design of the page separate from the markup. This results in bandwidth savings, because the design only has to be downloaded once, and easier modification of the design because it's not mixed in to the markup.


Another point is that the elements used should have a logical relationship to the data contained within them. For example, tables should be used for tabular data, <p> should be used for textual paragraphs, <ul> should be used for unordered lists, etc. This is in contrast to early web designs, which often used tables for everything.

like image 151
John Millikin Avatar answered Sep 23 '22 14:09

John Millikin


Semantics literally means using "meaningful" language; in Web Development, this basically means using tags and identifiers which describe the content.

For example, applying IDs such as #Navigation, #Header and #Content to your <div> tags, rather than #Left, and #Main, or using unordered lists for a list of navigational links, rather than a table.

The main benefits are in future maintenance; you can easily change the layout or the presentation without losing the meaning of your content. You navigation bar can move from the left to the right, or your links displayed horizontally rather than vertically, without losing the meaning.

like image 43
Dexter Avatar answered Sep 19 '22 14:09

Dexter