CSS class, or HTML tag?I’ve come across this situation many times. Let’s say you have a list of things to display, which is common on every web page. For this example, I will list my web site copyright, and general information:
The markup for that is as such:
This is a nice, unordered list, with each piece of information on separate lines. However, the very first item (matthom) should be bold, or enlarged. In a sense, it is the "header" of the entire list. To make that first item stand out, I could do one of two things. Create a CSS class that makes the text bold and enlarged, and apply that class to only the first list item:
Or... take the first list item out completely, and replace it with
(For the sake of this example, I’d be using My question is... What’s more semantically correct – using a class, or a header tag?
Comments/Mentions
|
Editor Picks
Email NewsletterSubscribe to the digest newsletter to receive posts by email: Recent Comments
Advertisements
|
DEFINITELY HTML tags!
I'm using a User Agent which doesn't support styles (or, I've chosen to disable them, or something). I load your website, and what would have used to have been a header displays like any other normal text.
If that's acceptable, then you shouldn't have been using headers to start with (because that would mean they were never intended to function as headers, but instead as simple styling devices for text with no STRUCTURAL meaning -- what semantics is all about).
So, consider the semantics of header tags (they're designed to create structure in a document, as with all headers), then consider what a website would look like (and structure like) if styles went and jumped overboard, or the website was being read aloud by a screen reader.
Additionally, there're search engines to consider: content in headers (within reason) is given greater weight than normal text -- if your "headers" aren't semantically headers, and just styled text, then search engines (which don't care about style sheets!) aren't going to index your content as well as they could, and your ranking will reflect poorly because of that...
Josh.