ID tags are very similar to class tag, that’s is why many people are confuse. I always wonder this myself…here is what I know…
ID tag can only be use once on a single page. For example, you have <div id=”something”>content here</div> you can not use it again on the same page. Actually, you can use the same id tags on the same page as many time as you like because many browsers do not enforce the HTML/XHTML rules but it will give you an error if you validate your page at w3c when you have two identical id tags on the same page.
So each id tag must be unique on a single page. Since id are only use once each page, it is very useful to identified a specific content on a page. For example, you have a id for the header and another unique id for the footer and if you want to have the link color for the header to be different from the footer you use id to separate the header and the footer.
It might seem that class are more powerful than id because you can only use id once per page, but that is not true. ID are more powerful than class and it can overwrite the class tags if the style conflict with each other.
That’s all for now. I hope this make sense. If you don’t get it just post comment below and I’ll do my best.
More info on ““ with the below links.
Do you like this article?