Search code examples
htmltagssemantics

Why browsers parses custom tags in HTML5?


Possible Duplicate:
Is it OK to use unknown HTML tags?

I've tested a custom tag <oles-tag> ... </oles-tag> in Chrome and IE9.

I use HTML5 doctype <!DOCTYPE html>.

HTML5 does NOT support custom tags. The code won't validate, but the browsers parses it anyway. I can even target it with CSS...

Why does browsers parse custom tags when it's not standardized valid code?

And why shouldn't I just use custom tags for the sake of semantic code?


Solution

  • Why does browsers parse custom tags, when it's not standardized and valid code?

    To make it forward-compatible. Just imagine if it was impossible for you to style <article> elements in old browsers because <article> didn't exist when those old browsers were written. That'd be terrible, wouldn't it? glares at IE

    And why shouldn't I just use custom tags for the sake of semantic code?

    Because no one else (programs) recognizes those tags, therefore they're not semantic. The reason why elements like <article> are considered semantic is because they have an established use. When you use a custom element that doesn't have an established use, it could be interpreted in a number of ways, leading to inconsistency among programs. glares at <b> and <i>