P粉2629261952023-08-23 20:17:14
There is a good article about HTML5 semantics on HTML5Doctor.
Semantics have always been part of HTML, existing in some form. It helps you understand what's happening on the page.
In the old days, when almost everything used <div>
, we still achieved semantics by giving it a "semantic" class name or id name.
These tags help in structuring and understanding the layout correctly.
If you do this:
<div class="nav"></div>
and
<nav></nav>
or
<div class="sidebar"></div>
and
<aside></aside>There is no problem with
, but the latter provides better readability for you, crawlers, readers, etc.
P粉2001385102023-08-23 13:52:22
Oxford Dictionary states the following:
As their name suggests, these tags are designed to enhance the meaning of your web pages. Good semantics play an important role in automatic processing of documents. This automatic processing happens more often than you realize - every website ranked by search engines is derived from the automatic processing of all websites.
If you visit a (well designed) web page, as a human reader you can immediately (visually) distinguish all the page elements and more importantly understand the content. On the top left you can see the company logo, next to the site navigation, there is a search bar and some text about the company, a link to products you can buy and a legal disclaimer at the bottom.
However, the machine is stupid and cannot do this: Looking at the same page as yours, a web crawler will only see an image, a series of anchor tags, a text node, an input field, and an image with a link. There is another text node at the bottom. Now, how are they supposed to know which part of the document you intend to be the navigation or the main article, or some less important footnote? They can guess hints for specific elements by analyzing your document structure using some common criteria. For example, the
Now imagine if a normal