开发者

Degradation issues for HTML5 semantic tags (article, footer, header)

开发者 https://www.devze.com 2023-01-02 08:30 出处:网络
How well do the new layout tags in HTML5 degrade? What are the hazards in using them? (I\'m not talking about <video>--I\'ve seen specific fallback code for it).

How well do the new layout tags in HTML5 degrade? What are the hazards in using them? (I'm not talking about <video>--I've seen specific fallback code for it).

Specifically, in the case of something like

<html>
<head></head>
<body>
<header>
<h1>Talking Dogs</h1>
<b><p>Humans aren't the only talkers!</p></b>
</header>
<article>
<p>Ever encountered a talking dog? I have.</p>
<p>It all happened one day as I was walking down the street...</p>
</article>
<footer>
© 2009 Woofer Dog Corporation
</footer>
</body>
</html>

Would using <header>, <article>, or <footer> cause any browser problems? Do they degrade to <div> in unsupporting browsers automatically? Or if I include them, should I only include them for semantic meaning开发者_如何学运维, and not for CSS styling or DOM scripting?


As long as you use html5shiv to handle IE, it will work fine.

The browser will treat all unknown tags (including HTML5 tags) as normal inline elements.
You should include the following CSS rule:

article, aside, figure, footer, header, hgroup,
menu, nav, section { display: block; }


For presentation you'll use CSS anyhow, so doesn't really matter if browser understands the tag itself.


HTML 5 Tags are not supported in IE the tags are still inactive. To activate the semantic HTML5 tags in IE use the following script inside your head section.

<!--[if IE]>
<script type="text/javascript">
(function(){
var html5elmeents = "address|article|aside|audio|canvas|command|datalist|details|dialog|figure|figcaption|footer|header|hgroup|keygen|mark|meter|menu|nav|progress|ruby|section|time|video".split('|');
for(var i = 0; i < html5elmeents.length; i++){
document.createElement(html5elmeents[i]);
}
}
)();
</script>
<![endif]-->
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号