Semantic Coding

During the past week there have been a number of posts about semantic markup (see: Andy Budd), specifically about the use of <i> and <b> (see: sidesh0w.com, Matthew Thomas, Luminosity, bestkungfu and cookiecrook).

Since I have recently been changing the way I code by paying more attention to semantics and using the best, cleanest CSS that I can, this has gotten me to thinking.

To sum up the various arguments, the bold and italic attributes shouldn’t be used (according to the Semantic Coders Guild) because they are purely presentational (ie: visual) and provide no meaning. Instead, they say that we should use the “semantically correct” <em> (emphasis, typically italics) and <strong> (strong, typically bold) elements. These elements are useful for things like screen readers for the visually impaired. They literally tell the reader to add emphasis when reading, just like you do when talking.

So how do we convey that via the visual media of the web? CSS allows us to style <em> and <strong> anyway we want to add visual emphasis.

So far so good.

But I began thinking. Is <strong> really a necessary element? It seems redundant and/or meaningless to me. The point of marking something out in bold/strong type is to add emphasis. So why not just use <em>? It would be just as easy, and I would argue just as semantically correct, to use something like <em class=”italic”> and <em class=”bold”> to change the visual nature of the element while still retaining the semantic emphasis. [Note: the classes mention would, of course, be properly styled in the style sheet with font-style: italic and font-weight: bold. Call the classes whatever you’d like.]

My thoughts snowballed from there to the ever-present <span> element. Does it ever serve any semantic purpose? I think the only time I use it is when I need a hook in order to visually style a section of text. (See the note in the previous paragraph.) So, if the Semantic Coders Guild is calling for the end of all non-semantic markup, what do we do with spans? I’m sure that somewhere, someone has managed to use a span in a semantic way, but I personally can’t think of any at the moment.

[For those of you who may be looking at the code for this site, don’t bother telling me how bad it is. I already know that the code has problems. I haven’t bothered to clean it up because I am working on a full redesign - or more correctly, an actual design. While I have been working with HTML for a few years, it is only recently that I have begun to understand and care about the code. At work I am constantly improving my coding habits, moving away form HTML tag soup to proper coding. It is so much easier to maintain. This will be reflected in my new site, whenever it gets done.]

[Oh, I made up the Semantic Coders Guild. If anyone was wondering.]

Filed under:

The URI to TrackBack this entry is: http://www.tjameswhite.com/blog/archives/2004/05/semantic-coding/trackback/

Comments »

No comments yet.

RSS feed for comments on this post.

Leave a comment

Comments are moderated, if you've commented before, it will show up automatically. If not, it will be submitted for approval. Please leave a name and e-mail address. They are for my verification only and do not appear online in any way shape or form. Without a name and/or and email address I don't know who you are your comment will not be approved.

Line and paragraph breaks automatic, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

(required)

(required)