Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why browsers parses custom tags in HTML5? [duplicate]

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?

like image 660
olefrank Avatar asked Dec 20 '22 15:12

olefrank


1 Answers

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>

like image 186
0b10011 Avatar answered Jan 10 '23 18:01

0b10011