Regarding Semantics

Written by That Web Guy on 25th June 2009. 13 comments

Regarding Semantics
  • Avant Innovations
  • Advertise Here

Semantics (n) The meaning, or an interpretation of the meaning, of a word. Now that's out of the way, what do semantics mean in modern web design? Depending on who you ask you could get a varied response, but if anything is certain it's that the concept of semantic mark-up isn't difficult to grasp.

Note: This article is about semantic mark-up, not the semantic web (which will allegedly be web 3.0), although the latter is dependant on the former. The semantic web is a topic probably not suitable for this blog just yet, but you can read more on that subject here, or something a little more digestible here. Let's continue.

When referring to a web document, semantics is about the meaning of any given element and how said element describes what it contains. Any web designer who practices keeping presentation separate from the content (with CSS) probably already constructs their web documents in a semantic fashion or very close, even if they are unaware.

I like to describe semantics as "using the right tool for the right job" although I'm sure there's a better analogy out there. But before I go deeper into that, check out these two different sets of mark-up.

Designer A: Non-semantic

<h4>Important heading</h4>
Pod Bay is decompressed. All doors are secure.<br /><br />
<h2>Less important heading</h2>
You are free to open pod bay doors.<br /><br />
<a href="pod.html">Pod</a><br />
<a href="bay.html">Bay</a><br />
<a href="doors.html">Doors</a>

The first example by Designer A (which curiously looks like something I would have done during the .com boom era) is a typical throwback to design practices of yesteryear, when designers would use html elements to try and control the presentation. Designer A didn't like the big ugly size of an H1 and wanted something smaller, so he has used an H4 instead. He has then used an H2 for emphasis, because it's physically bigger than an H4.

In the next part Designer A has used double <br /> to separate paragraphs because he likes the line-height it offers. And finally the navigation items are separated by single <br /> to give the appearance of a vertical list.

This structure is called non-semantic, or meaningless. The key point to note here is that mark-up should never be used for presentational purposes. The internet gods gave us CSS for that purpose.

Designer B: Semantically correct

<h1>Important heading</h1>
<p>Pod Bay is decompressed. All doors are secure.</p>
<h2>Less important heading</h2>
<p>You are free to open pod bay doors.</p>
<ul>
<li><a href="pod.html">Pod</a></li>
<li><a href="bay.html">Bay</a></li>
<li><a href="doors.html">Doors</a></li>
</ul>

Designer B has done the right thing by giving the mark-up meaning. A heading should be a heading, and the most important heading should always be an H1. Sub-headings will run in consecutive order, H2, H3 etc. Paragraphs should be placed in P tags, and a list should be placed in an ordered or unordered (OL or UL) list.

If you're following what I mean you've probably already figured out what one of the most historically abused HTML elements was (and sadly sometimes still is) when talking about non-semantic code. Did someone say tables?

Tables are a textbook example of everything that was wrong with web design. Have you ever stopped to think about why we don't use them for layout (besides the fact they're more difficult to manage)? We are now more aware that semantically speaking tables are the wrong element for the job. Tables are only meant for one thing only - tabular data. And if you're using tables for your layout then everything inside them is semantically meaningless.

The significance of the content should dictate what element you use

Absorb that again: The significance of the content should dictate what element to use. Just to reiterate Designers B's example, the meaning is simple. If you're dealing with the most important title on a page, it should be contained in an H1. If it's a less important heading, then put it in an H2. If you're quoting some content, it belongs in a blockquote. When you're specifying an address, use the address element. If you've got a list of items, put them in a UL or OL. You get the idea.

Does it matter?

The value of this answer will depend on you. For one thing, semantics make things a heck of a lot easier for screen readers, or more specifically the people relying on screen readers to get around a web site. But if you believe some of the articles out there, then by keeping our mark-up semantic we are preparing our sites for web 3.0 and improved machine/device understanding.

Whatever the result, it's obvious semantics are important to keeping your mark-up clean, structured and meaningful.

Now go get 'em.

Is this worth sharing?

That Web Guy

About That Web Guy

That Web Guy (Mikey to his friends) is a veteran web designer based in Perth, Western Australia, and currently Design Director at Perth Web Design. When he's not XHTML'ing or messing around in Photoshop, Mikey can usually be found preaching web standards evangelism onto unsuspecting victims.

Feel free to send That Web Guy a message some time, follow him on Twitter, or make a donation.

Comments

Not a Member

Nicely Explained

I think it does matter and its standard practice every designer should be doing anyway.

Thursday 25th June 2009 | 09:03 PM Reply Comment URL Back to top

Marvin The Martian

Marvin The Martian

In addition, I would strongly suggest to all designers to use proper indenting when writing code. It will help long term when updating and if and when someone else has to edit your code.

Friday 26th June 2009 | 12:52 PM Reply Comment URL Profile Back to top

CSS Babe

CSS Babe

Once again you make sense. I think I've been like Designer A more than I've been Designer B but I'm getting better.

Thanks for the awesome information you keep sharing.

Saturday 27th June 2009 | 05:03 PM Reply Comment URL Profile Back to top

Harun Smrkovic

Harun Smrkovic

OK. Off topic:
How the hell did you make effect of text being "yellow marked" when selected ?

Monday 29th June 2009 | 05:24 AM Reply Comment URL Profile Back to top

That Web Guy

That Web Guy

Responding to this comment by Harun Smrkovic

It's cool huh? Have a look at lines 15 to 21 of my css file: http://www.thatwebguyblog.com/lib/css/screen.css

Monday 29th June 2009 | 06:00 AM Reply Comment URL Profile Back to top

Kim OJ

Kim OJ

I did not notice that before, that is pretty cool!

Monday 29th June 2009 | 07:46 AM Reply Comment URL Profile Back to top

Harun Smrkovic

Harun Smrkovic

Hey, simple as that !?
Great! Thank you ;)

Monday 29th June 2009 | 03:35 PM Reply Comment URL Profile Back to top

Not a Member

Josh

Great article, keep them coming!

Thursday 2nd July 2009 | 03:01 AM Reply Comment URL Back to top

Jasmine

Jasmine

Meaningful - makes sense.

Tuesday 22nd December 2009 | 08:19 AM Reply Comment URL Profile Back to top

Not a Member

Angelina

I get it now. I love the way you explain things. But I'm ashamed to admit I still have a little bit of Designer A in me :-(

Wednesday 30th December 2009 | 08:25 PM Reply Comment URL Back to top

Not a Member

Bruce

Thanks for one of the most easily digestible articles on this topic. You made it make sense.

Wednesday 19th May 2010 | 12:38 PM Reply Comment URL Back to top

That Web Guy

That Web Guy

Responding to this comment by Bruce

You're welcome

Saturday 22nd May 2010 | 06:47 AM Reply Comment URL Profile Back to top

ScottFoley

ScottFoley

Fantastic article. This is something that is so important to know for designers of any level. You've done a great job of giving clear cut examples of how to write semantic html. This is something that every designer should get in the habit of doing. Thanks.

Tuesday 1st June 2010 | 11:01 PM Reply Comment URL Profile Back to top

FYI: You are currently not logged in. It's cool though - you can still comment. But only members get a profile page, access to the download section and they can pimp their own web sites. Feel free to register or Login now!

Your name:

Your comments:

Note: HTML tags are automatically stripped from comments.

Are you human?
Turing

Sorry, I have to ask. So what sort of animal is this? (Hint: you don't have to be perfectly specific)

Back to top

Login to That Web Guy Blog

Login

Not registered? | Forgot your Password? Cancel Login