html是网络的语言 - 它确定网页上的内容以及按什么顺序显示。那些新的语言的人迅速得知,通常有几种方法可以通过HTML和HTML和accompanying styling。< / p >
但是,并非所有方法都是平等的。通常,您如何编写HTML与HTML对访问者的展示一样重要。< / p >
具体地说,我说话的g aboutsemantic HTML, HTML code that says what it does. In this introductory guide, I’ll introduce you to semantic HTML — what it is, how to write it, and why it’s important for every marketer and burgeoning web developer to adopt. We’ll finish up by listing some common semantic elements to add to your tool belt.< / p >
What is semantic HTML?
Semantic HTML (also called semantic markup) is HTML code that uses HTML tags to effectively describe the purpose of page elements. Semantic HTML code communicates the meaning of its elements to both computers and humans, which helps web browsers, search engines, assistive technologies, and human developers understand the components of a web page.< / p >
The key to well-written semantic HTML is the use of semantic tags. Semantic HTML tags have names that tell the person or machine reading the code what exactly they’re meant to do.< / p >
Here’s a basic example: The(paragraph) tag is a semantic HTML tag — all content between its opening标签和关闭< / p >tag is a block of paragraph of text. Anyone or any device reading this tag will understand its purpose.< / p >
其他一些常见的语义HTML标签是:< / p >
- ,,, etc.: Headings on the page in descending order of importance.
- : A hyperlink.
- : A button element.
- 和
:这些元素表明其中的文字很重要。 和:表示网页的标题和页脚部分。
In each of these examples, the tag itself tells us exactly what the element is used for. In fact, many HTML elements can convey meaning with their tags, as long as they’re being used for the correct purpose (e.g., not using atag for a heading or an标签段落)。< / p >
然后提示一个问题:哪些HTML标签是非语义的?< / p >
最常见的非语义,HTML标签是 看看下面的示例。在这里,我们有两个相同的按钮元素。但是,第一个元素使用tag while the second uses the See the PenSemantic HTML - button vs divby Christina Perricone (@hubspot) onCodePen。 This example illustrates how different tags can achieve the same visual results — to a sighted, human user, the experience of using these buttons is the same. Even so, it’s always better to opt for the semantic implementation, in this case。接下来,我们将探讨为什么语义标记比通用标记更好。< / p > Semantic HTML not only makes your code neater and easier to read — it also makes it moreaccessible to assistive technology和search engines. Let’s unpack each benefit below.< / p > 屏幕读取器rely on semantically-rich HTML to process web pages and help users with low vision navigate them. Semantic tags tell screen reader users where they are and how they can interact with the current page.< / p > 如果页面构造为 内置键盘可访问性也带有许多语义元素。当屏幕阅读器看到一个element on a page, it allows this element to be “clicked” with the enter key. The same can’t be said for the generic As another example, when a screen reader detects a<表>element, users can use special keyboard controls to move up and down rows and across columns. By writing clean, semantic HTML, you enable extra accessibility features with no extra work.< / p > 屏幕读取器also let their users navigate the page more efficiently by jumping between like elements, or pulling up a list of similar elements to summarize page content — one more reason to use semantic tags appropriately.< / p > Like with assistive technologies, semantic markup helps search engine crawlers navigate your page to better understand its structure and contents. Semantic HTML is a great way to show search engines what to index and get the most from your crawl budget.< / p > 例如,tag encloses the main content of a page — use it to signal the unique parts of a page and avoid wasting indexing on repeated page elements. Place the less important content inside Web developers write and read hundreds of lines of code daily, so anything that makes their jobs easier is worth the effort. Semantically rich markup allows developers to locate specific page elements more quickly than sifting through a pile of Readability is especially important if you’re working on a team — you can’t expect fellow developers (or even your future self) to immediately understand your page from code alone. However, the better you organize your content, the more quickly other developers will see the structure and the more efficient your development will be.< / p > Since semantic HTML revolves around the proper use of tags, let’s review some common semantic tags you can implement on your site. We’ve broken these tags down into those used on text, those used to communicate page layout, and other handy semantic tags.< / p > These tags convey the meaning of the text that they contain:< / p > 这些HTML标签用于将儿童元素分为部分。每个部分都包含相关内容。< / p > 在学习一种新的编码语言时,尤其是像HTML一样基本的编码语言时,将最佳实践尽快纳入您的代码至关重要。随着您继续获得更高级的技能,您早期形成的习惯更有可能坚持。< / p > Semantic markup is one such practice — it makes your code more readable, more search-engine-friendly, and more accessible to assistive technologies. Plus, your fellow developers will appreciate your careful attention to detail and adherence to best practices.< / p > When approaching a web page, consider each element and see if there’s a semantic way to place it, instead of just springing for a或a Originally published Apr 27, 2021 7:00:00 AM, updated November 20 2021< / p > Topics:< / p >html
Expand Offer Sign up for HubSpot's CMS SoftwareWhat are the benefits of semantic HTML?
可访问性
SEO
人类的可读性
Semantic HTML Tags
Semantic HTML Tags for Text
(ordered list): A list of items that must display in a particular order. Browsers typically apply numbers to each item.
(unordered list): A list of items in which order is not important. Browsers typically apply bullets or dashes to each item.
:计算机代码。浏览器通常采用样式来区分该文本与周围文本。
Semantic HTML Tags for Structure
其他语义HTML标签
Semantic HTML is well-written HTML.
Don't forget to share this post!
Related Articles
Download for Later