views:

88

answers:

4

What is the benefit of writing meaningful css .class and #id names? Do screen readers speak to help the user understand the meaning and purpose of content inside the tags?

A: 

You don't do it for the machines but for the humans.

If we only cared about machines we'd still be coding in assembly :)

cherouvim
but then why microformats adds so many classes are all these for humans?
metal-gear-solid
They are human meaning and readable enhancements to the markup which also benefit scrapers etc. Generally having good naming conventions makes the document understandable, maintenable and easier to work with (from humans). for instance try to understand what is going on in the gmail.com markup and css naming. Impossible :)
cherouvim
"markup which also benefit scrapers etc." could you explain more this please.
metal-gear-solid
microformats make it possible for web spiders/scrapers to extract meaningful content in a structured way from the tag soup.
cherouvim
ok and if we also write meaningful classes and IDs then will it be also helpful for web spiders/scrapers? what is the means of "extract" here
metal-gear-solid
+2  A: 

Generally-speaking, it's beneficial for the developer/designer only.

Jonathan Sampson
for single developer or only in team environment. and microformats does have same purose, its classes for developers
metal-gear-solid
it's beneficial to the project's health as well.
cherouvim
It's beneficial for *anybody* developing against the markup.
Jonathan Sampson
+1  A: 

Again, as all your recent questions on semantics, the answer stays the same:

It all depends on the data-context of the entity in question.

If your element holds a meaningful field, it is useful to assign it a class (even if you do not want to apply CSS to it) just to easily define that particular field:

<span class="username">Andrew Moore</span>

Doing so has the following advantages:

  • It easily identifies the field's content in your code.
  • It increases maintainability.
  • It helps parsers and third-party applications to fetch this field's value.

Microformats are just a larger example of this. Simply put, they are a set of pre-defined elements and attributes that hold a particular set of data, meant to ease parsing by third-party tools.

Andrew Moore
"ease parsing by third-party tools" which tools? and if we also write meaningful classes and IDs then will it be also helpful for those third party tools?
metal-gear-solid
@Jitendra: In the early days of Stack Overflow, the **flair** API wasn't available. Since SO has meaningful `class` definitions, people wrote 3rd-party tools to parse their user page, fetch their current reputation and badges and create image signatures for forums with their SO reputation. As for Microformats (which are just standardized version of the same idea), see this as an example of their usefulness: http://googlewebmastercentral.blogspot.com/2009/05/introducing-rich-snippets.html
Andrew Moore
@Jitendra: A bunch of other examples of user created third-party tools for Stack Overflow: http://meta.stackoverflow.com/questions/tagged/so-addon
Andrew Moore
I don't know about this concept "the flair API wasn't available. Since SO has meaningful class definitions, people wrote 3rd-party tools to parse their user page, fetch their" but thanks foe increasing my knowledge. btw can i ask What is flair API, and how can i parse and show my SO widgest for my email signature in gmail and outlook
metal-gear-solid
@Andrew Moore - thanks again for link
metal-gear-solid
@Jitendra: http://stackoverflow.com/users/flair
Andrew Moore
ur example of SO is situation specific.If we are not anything related to parsing for other tools.i think then ur first 2 point is write
metal-gear-solid
@Jitendra: It's not really situation specific. As soon as you are writing a service for users, users will want to modify/enhance it.
Andrew Moore
+1  A: 

Other answers are good, but I will focus on the scraping/third party tools aspect here.

Case 1 is spiders and crawling like search engines. If they parse your page and see something like id="username", they will be more likely to figure out some meaning in that than id="div-style-32". Granted, I'm not sure Google is doing this sort of thing now, but it could be if more people were better about it.

Case 2 is people writing scripts to pull down the HTML and process it in order to extract its content as data. Pretty much anyone who wants to do this can with any markup, its just a matter of how annoying it is. Cleaner and more well described markup allows the scraper script to more easily find the information it needs due to it's increased semantics.

This also includes things like browser extensions or Greasemonkey scripts that allow users to alter the behavior of the site. It will be easier to create these modifications with cleaner markup.

But if you don't want people scraping or modifying your site with client side extension, there is little you can do about from a technical standpoint. You can't stop it, you can only make it more of a pain in the ass. And the benefits of maintainability for the site developers are huge. So really, why not?

In short it makes all the different things you or others could do with your site easier to do.

Squeegy
u mean id="username" can be helpful for SEO.
metal-gear-solid
Has more potential to be more SEO, yes. Though currently I'm not sure it matters much with current indexing algorithms. But I don't know a lot on this subject either.
Squeegy