The Semantic Code
Posted by Abhijit Nadgouda on October 19th, 2006.
I had been introduced to the concept of Semantic Markup much earlier. But it is one of the things that is not a technical necessity, so I remained at the surface for a long time. I recently got chance to delve into the whys and hows that I would like to share with you, or rather discuss with you. Semantic Markup, by itself, is a vast subject, we will focus on the web design subset of it for the purpose of this article, lets call it Semantic HTML.
What Is Semantic HTML
Semantic Markup is a way of writing your markup so that the reader understands what the data is about. The term reader includes machines like the search engine bots or parsers along with the humans.
Semantic HTML is a way of writing your HTML code such that the HTML tags express what the data is that is enclosed between them. It is about using HTML tags for what they stand for. For example, using h1 instead of div for the title of an article indicates that it is a heading. Ofcourse you can always use <div class="heading"> to make it more expressive, however there two problems to it:
h1is globally known as a tag for heading, as a standard, rather than our custom tag. If each of us created custom tags, there would be no common software programs that we would work for us.h1is still more expressive and space-saving than thediv
Some of the other examples are using div for block elements which are usually rendered on a new line, cite to cite source of information, p for paragraphs, code for source code and so on. The HTML tags are named such that their meaning is quite apparent.
To be able to follow Semantic HTML, the underlying markup has to be extensible. This is one of the reasons we are slowly migrating to XHTML from HTML. HTML is inherently presentational, i.e., it provides information of how to present the data. Whereas Semantic HTML should convey what is the data about.
Benefits
The two points mentioned earlier are the basic benefits of using semantic code. If we use globally known tags, others understand without any additional effort. Any software program that uses the globally known tags will not be able to understand our page.
A working example of this is that search engines weigh keyword importance according to what they are. For example, and article title enclosed in one of the headings (h1 and its hierarchy) would get higher importance and hence visibility than spans. Semantic HTML enables effective Search Engine Optimization (SEO).
The semantic data extractor is a good demonstration of the possibilities of using Semantic HTML and software automation.
The semantic data extractor is a good demonstration of what can be achieved by Semantic HTML and software automation.
A side effect of excluding presentational information from the semantic markup is that now data and its presentation can be decoupled in implementation. Which means that you can change presentation without touching the data, or apply the presentation to multiple types of data. This is exactly what technologies like CSS and XHTML together achieve. Of course Semantic HTML is not necessary for this decoupling, but provides for by being semantic it enforces exclusion of presentational information.
Benefit To Developers/Designers
Another unintended benefit of Semantic HTML that I have realised is that it can be used for communication between developers and designers in a project. When I, as a content engineer, want to design a page, I first try to realise all the content that has to be in there. Somewhere the content priorities also have to be decided, e.g., primary, secondary, …. Then I prepare pure markup, without thinking about the styles or the presentation. This markup contains two important pieces of information - structure of different content types and different content types to include in the page. If this markup is semantic, then the designer can understand it better, reducing requirements for documentation. I might end up playing both the roles, but it gives me an opportunity to focus on the two different things exclusively.
Nate Koechley talks about Layered Semantic Markup (LSM). LSM is a framework of web technologies with the philosophy of structured semantic markup as core of web development. By building layers of presentation and behavior above the core of semantic markup, the framework builds flexible and future-ready web pages.
The XFN and FOAF projects are extensions of the Semantic HTML that use semantics not only in the tags but also in the attributes. In my opinion they are just a tip of the iceberg of possibilities with Semantic Web.
Epilogue
Semantic HTML is a way of building and participating in the semantic Web. This will ensure higher visibility and future readiness. Semantic HTML also makes your web pages open to automation. However, Semantic HTML is not mandatory, it is a best practice, a code of conduct. The beginning might be a little tough, but the advantages are many, if you follow the Semantic Code.
Make A Comment
( 20 so far )
20 Responses to The Semantic Code
It becomes very easy to use semantic markup when you know the meaning of each tag in your markup.
And what their structural meaning in the document is: Are it block elements (eg P, H1), inline elements (textual elements) (eg A, STRONG)and what containers (grouping elements: DIV and SPAN) are.
Read about it:
http://www.w3.org/TR/html401/struct/global.html#h-7.5.3
One step further is to chose what semantic markup is more suited to use when dealing with search engine optimisation.
The excessive use of wrapper divs to control layouts with CSS does not interfere with semantic HTML provided the elements contained in the divs are semantic. For example fluid designs, elastic designs, divs to make IE contain wide floats, etcetera will increase the use of wrapper divs.
This is not about presentation but to provide hacks and hoosk to make a layout work as intended. A screen reader does not see divs, since divs have no semantic value to that same screen reader.
[…] My third article on Semantic HTML in fadtastic.net is up. It is a kind of follow up to my article on the generic Semantic Markup. […]
Ofcourse you can always use <div class="heading"> … to make it more expressive,
Absolutely wrong idea, I would never allow this practise under any circumstances.
… <div class="header"> would be meaningful since you will group all elements like h1, ul (eg for navigation), skip links, … whatever you put in your header.
A thorough and intelligent article/discussion.
I would like to think that as newbie’s learn HTML/CSS based designs that they also consider the semantics of how they are coding right from the off. It seems to tie in with compliant coding rather nicely.
[…] The Semantic Code […]
Very well written and I like the approach your have towards semantic correctness. I think everyone should strive for the highest possible accessibility, and semantically correct code structure, but not always at the cost of innovation. Treating this like a best practice rather than a “do-it-or-else” mentality seems much more open to new ideas and healthy for the psyche. ;)
[…] Semantic HTML is a way of writing your HTML code such that the HTML tags express what the data is that is enclosed between them. It is about using HTML tags for what they stand for. For example, using h1 instead of div for the title of an article indicates that it is a heading. http://fadtastic.net/2006/10/19/the-semantic-code/ […]
[…] » The Semantic Code » fadtastic - a multi-author web design trends journal (tags: webdesign tutorial) […]
Have you tried your own page in the “semantic data extractor”?
This is a good reminder of how I should be doing things. The header (h1, h2, etc.) tags are a great example of what was a bad habit for me. Habits can be hard to break and I think there are a lot of folks out there that just got out of the habit (or never got INTO the habit) of using the good old h1-h6 tags as they were intended. My personal opinion is that the trend of small fonts, even pixel fonts if you will, was what drove designers to shun the monstrous size of the h1. As that trend is on the wane (possibly out even), designers, myself included, need the help of gentle reminders like this article to rehabilitate our thinking of markup in general. Thank. This was a good read.
[…] Abhijit Nadgouda discusses the benefits of semantic HTML […]
[…] Im Beitrag The Semantic Code auf fadtastic erhält man eine Definition zu semantischem HTML. Außerdem werden die Vorteile und das Potential des sinnhaften Codes beleuchtet. […]
[…] The Semantic Code […]
[…] Fadtastic: The Semantic Code Se trata de generar el código para que los lectores humanos y robots sepan de qué se trata. […]
[…] It is well known that headings contributes to better SEO as well as semantic HTML. However, it also impacts the accessibility, for which using the heading structure is necessary. […]
[…] return in a search. It increases your page rank and makes the page look tidy without CSS. Check out this article to learn […]
[…] Meaning of Semantics Writing Semantic HTML The semantic Code Semantic code: What? Why? How? Semantics, HTML, XHTML, and Structure Share and Enjoy: These icons […]
Related In Some Way, Shape Or Form
The above post has obviously kept you amused. Why not discover similar material:
The posts Print In Style, CSS Hacks: Are They Cool or Not?, Toggling Web Trends.., Draft Blogger’s Code of Conduct, Branding your CSS Stylesheets, are related to this post.
Or why not take time out to find out about the author of the post.



