语义标记:为什么< header>而不是< div id ="标题"&gt ;? [英] Semantic markup: Why <header> instead of <div id="header">?

查看:163
本文介绍了语义标记:为什么< header>而不是< div id ="标题"&gt ;?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,所以我理解了关于语义标记的宣传:它增强/进一步指定了搜索引擎的元素或页面的含义,因此也为人类阅读搜索结果。对微格式和< h1>,< h2>,< p>< / code>等所有信用因为这些标记指示了分层结构和/或特定目的并且增加了含义到页面。

但为什么现在有< aside>,< header>< footer> 的标签?他们比< div id =aside / header / footer> 更有优势吗?

这些标签没有特定的子属性或属性,如< audio>< form>< img> 标记(src,action等),我几乎无法想象它意味着搜索引擎性能的改进,以寻找标题标记而不是标题标识。此外,如果初学者在使用这些标签时犯了错误,是不是会更糟糕,因为错误一直延伸到DOM节点级别?

那么为什么有新的HTML'语义'标签与普通的ol'div没有明显的区别?或者,如果这是错误的,什么是好处?



编辑:我正在寻找的答案是链接安东尼在此主题的第4条评论中指出: http://www.w3.org/TR /html5/sections.html

标签存在的理由如< aside>,< header>< footer> ,是:


划分内容是定义标题和页脚范围的内容。 - W3C


解决方案

好处是标记描述了内容和结构该文件更准确。使用 id < div> 并不意味着标题,无论 id 可能是 - 完全是任意的。而< header> 是一个标题,无论它的 id


Okay, so I understand the hype about semantic markup: it enhances/ further specifies the meaning of an element or page for search engines, and therefore for humans reading search results. All credits to microformats and <h1>, <h2>, <p> and such, because these tags indicate a hierarchical structure and/or specific purpose and add meaning to the page.

But why are there now tags like <aside>, <header>, <footer>? What is their advantage over <div id="aside/header/footer">?

These tags have no specific sub-properties or attributes like an <audio>, <form>, <img> tag (src, action, etc.) and I can hardly imagine it means such an improvement for search engine performance to look for a header tag instead of a header id. Furthermore, if beginners make mistakes while using these tags, wouldn't it be even worse because the error goes all the way down to the DOM node level?

So why are there new HTML 'semantic' tags with no apparent benefit over the plain ol' divs? Or if this is wrong, what IS the benefit?

EDIT: The answer I was looking for is in the link Anthony pointed at in the 4th comment of this thread: http://www.w3.org/TR/html5/sections.html.

The justification for the existence of tags like <aside>, <header>, <footer>, is:

Sectioning content is content that defines the scope of headings and footers. - W3C

解决方案

The benefit is that the mark-up describes the content and the structure of the document more accurately. A <div> with an id does not mean a header, whatever that id may be - it's completely arbitrary. Whereas a <header> is a header, no matter what its id.

这篇关于语义标记:为什么&lt; header&gt;而不是&lt; div id =&quot;标题&quot;&gt ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆