实际上,为什么要使用语义标记? [英] Practically speaking, why semantic markup?

查看:25
本文介绍了实际上,为什么要使用语义标记?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google 真的关心我是否使用

作为 标签?

Does Google really care if I use an <h5> as a <b> tag?

我应该关心语义标记的一些现实世界的实际原因是什么?

What are some real-world, practical reasons I should care about semantic markup?

推荐答案

几个例子

  • 许多视障人士依靠语音浏览器将页面读回给他们.这些程序不能很好地解释页面,除非它们被清楚地解释.换句话说,语义代码有助于可访问性搜索引擎需要了解您的内容是关于什么的,以便在搜索引擎上正确地对您进行排名.

    A few examples

    • Many visually impaired people rely on speech browsers to read pages back to them. These programs cannot interpret pages very well unless they are clearly explained. In other words semantic code aids accessibility Search engines need to understand what your content is about in order to rank you properly on search engines.

      语义代码往往会改善您在搜索引擎上的位置,因为搜索引擎蜘蛛"更容易理解.

      Semantic code tends to improve your placement on search engines, as it is easier for the "search engine spiders" to understand.

      然而,语义代码也有其他好处:

      However, semantic code has other benefits too:

      • 从上面的示例中可以看出,语义代码更短,因此下载速度更快.

      • As you can see from the example above, semantic code is shorter and so downloads faster.

      语义代码使网站更新更容易,因为您可以将设计风格应用于整个网站的标题,而不是逐页.

      Semantic code makes site updates easier because you can apply design style to headings across an entire site instead of on a per page basis.

      人们也更容易理解语义代码,因此如果新的网页设计师拿起代码,他们可以更快地学习.

      Semantic code is easier for people to understand too so if a new web designer picks up the code they can learn it much faster.

      由于语义代码不包含设计元素,因此无需重新编码所有 HTML 即可更改网站的外观.

      Because semantic code does not contain design elements it is possible to change the look and feel of your site without recoding all of the HTML.

      再一次,因为设计与您的内容是分开的,语义代码允许任何人添加或编辑页面,而无需对设计有很好的了解.

      Once again, because design is held separately from your content, semantic code allows anybody to add or edit pages without having to have a good eye for design.

      您只需描述内容,级联样式表定义内容的外观.

      You simply describe the content and the cascading style sheet defines what that content looks like.

      来源:boagworld

      <人力资源>

      语义是主题的隐含含义,如单词或句子.它有助于人类(以及现在的机器)如何解释主题.
      在网络上,HTML 为人类和机器提供服务,表明 HTML 标签内包含的内容的用途.
      自 HTML 诞生以来,元素已经根据网络上的实际使用情况进行了修改和调整,理想情况下,作者可以轻松导航标记并创建结构化的文档,并且机器可以推断精彩集合的上下文我们人类可以读取的数据.

      Semantics are the implied meaning of a subject, like a word or sentence. It aids how humans (and these days, machines) interpret subject matter.
      On the web, HTML serves both humans and machines, suggesting the purpose of the content enclosed within an HTML tag.
      Since the dawn of HTML, elements have been revised and adapted based on actual usage on the web, ideally so that authors can navigate markup with ease and create carefully structured documents, and so that machines can infer the context of the wonderful collection of data we humans can read.

      在机器能够理解语言及其所有细微差别与人类处于同一水平之前——甚至可能之后,我们需要 HTML 来帮助机器理解我们的意思.电脑不在乎你晚餐吃比萨饼.它可能只是想知道它到底应该用这些信息做什么.

      Until — and perhaps even after — machines can understand language and all its nuances at the same level as a human, we need HTML to help machines understand what we mean. A computer doesn’t care if you had pizza for dinner. It likely just wants to know what on earth it should do with that information.

      HTML 语义是一个微妙的主题,广受争议且易于解释.不是每个人都立即就同一件事达成一致,这就是问题出现的地方.

      HTML semantics are a nuanced subject, widely debated and easily open to interpretation. Not everyone agrees on the same thing right away, and this is where problems arise.

      请允许我画一幅画:
      您正忙于创建网站.
      你有一个想法,哦,现在我必须添加一个元素."
      然后另一个想法是,我为添加一个 div 感到很内疚.我听说 Div-itis 很糟糕."
      然后,我应该用别的东西.旁边的元素可能是合适的."
      三次搜索和五篇文章之后,您相当确信 aside 在语义上是不正确的.
      你决定文章,因为至少它不是一个 div.
      你浪费了 40 分钟,却没有任何实际的好处.
      — Divya Manian

      Allow me to paint a picture:
      You are busy creating a website.
      You have a thought, "Oh, now I have to add an element."
      Then another thought, "I feel so guilty adding a div. Div-itis is terrible, I hear."
      Then, "I should use something else. The aside element might be appropriate."
      Three searches and five articles later, you’re fairly confident that aside is not semantically correct.
      You decide on article, because at least it’s not a div.
      You’ve wasted 40 minutes, with no tangible benefit to show for it.
      — Divya Manian

      这引起了积极和消极的回应风暴.在 追求语义价值 来自 Jeremy Keith 认为语义正确并非没有结果,他甚至举了一个例子说明如何使用

      来调整文档的大纲.他总结道:

      This generated a storm of responses, both positive and negative. In Pursuing Semantic Value By Jeremy Keith argued that being semantically correct is not fruitless, and he even gave an example of how <section> can be used to adjust a document’s outline. He concludes:

      但是,如果您能够克服喧嚣的语气并进入文章的核心,这是一个相当直接的信息:不要过于关注语义,以免损害 Web 开发的其他重要方面.— 杰里米·基思

      But if you can get past the blustery tone and get to the kernel of the article, it’s a fairly straightforward message: don’t get too hung up on semantics to the detriment of other important facets of web development. — Jeremy Keith

      命名事物

      在 HTML5 中所有可能的新元素名称中,规范在<nav><footer> 之类的东西上设置得非常好.如果您在自己的标记中将其中任何一个用作类或 id,这绝非巧合.来自 Google 和 Opera(以及其他公司)之类的网络研究着眼于人们使用哪些名称来暗示其 HTML 文档的一部分的用途.HTML5 规范的作者认识到开发人员需要更多语义元素,并研究了哪些类和 ID 已被用于传达此类含义.

      Naming Things

      Of all the possible new element names in HTML5, the spec is pretty set on things like <nav> and <footer>. If you’ve used either of those as a class or id in your own markup, it’s no coincidence. Studies of the web from the likes of Google and Opera (amongst others) looked at which names people were using to hint at the purpose of a part of their HTML documents. The authors of the HTML5 spec recognised that developers needed more semantic elements and looked at what classes and IDs were already being used to convey such meaning.

      当然,不可能使用所有研究过的名称,并且在可以使用的数百万英语单词中,最好专注于满足网络需求的一小部分.然而,有些人认为规范还没有这样做.

      Of course, it isn’t possible to use all of the names researched, and of the millions of words in the English language that could have been used, it’s better to focus on a small subset that meets the demands of the web. Yet some people feel that the spec isn’t yet doing so.

      来源:html5doctor(这种情况持续了很长时间,所以我已经这里只举几个例子.)

      Source: html5doctor (This goes on for quite a while so I've only put a few examples here.)

      希望这会有所帮助!

      这篇关于实际上,为什么要使用语义标记?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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