H1 in article page - site title or article title?

前端 未结 8 758
天涯浪人
天涯浪人 2021-02-01 00:27

Within an article-oriented page (such as a blog post), the

element (level 1 heading) is commonly used to markup either:

  • the blog title (i.e

8条回答
  •  天涯浪人
    2021-02-01 01:00

    The part of a HTML page has an element named </code>. As the name implies, this is for the site title.</p> <p>HTML is used to structure a page into a machine parse-able form, not for layouting. If it was only about layouting, you could only use <code><div></code> and <code><span></code> blocks with different classes/ids and apply CSS to them. Instead of </p> <pre><code><h2>Sub Header</h2> </code></pre> <p>I could use</p> <pre><code><div class="header2>Sub Header</div> </code></pre> <p>and somewhere have some CSS code that will make this <code><div></code> look like h2 (font size, bold font, etc.). The difference is that a computer can't know that my <code><div></code> is in fact a second level header in the first example (how should it know that? I might name it differently than "header2"), however in the first case, it knows that it is a second level header by the fact that it is a <code><h2></code> element and if it wants to show the user a structured list of head-lines of a page, it can do so</p> <ul> <li>Top Level Header <ul> <li>Sub Header <ul> <li>Sub Sub Header</li> </ul></li> <li>Sub Header</li> <li>Sub Header</li> </ul></li> <li>Top Level Header <ul> <li>Sub Header <ul> <li>Sub Sub Header</li> <li>Sub Sub Header</li> </ul></li> <li>Sub Header<br>:<br></li> </ul></li> </ul> <p>by searching for the H1/H2/H3/... elements and structuring them as above. So if a computer tries to find out the title of a page, where will it look for it? In an element named <code><title></code> or in an element named <code><h1></code>? Think about that for a moment and you have your answer.</p> <p>Of course you might say "But the title is not visible on the page". Well, it is usually visible in the browser window somewhere (window title or at least tab title) - however, you may want it to be visible on the page as well - I can understand that. However, what speaks about doing that? Who says you may not repeat it? But I wonder if you should use a h1 element for that.</p> <pre><code><html> <head> <title>SOME TITLE :

    SOME TITLE
    :

    Use CSS to style #title the way you like. Make it super big and super bold and have an eye catching color if you like, nothing speaks against it. Automatic page parsers usually ignore div and span to some degree, as it tells them nothing (these are elements used to layout the page for the reader, but they say nothing about the structure of the page. LAYOUT is not STRUCTURE, you can only apply style to certain structural elements to generate a layout, but one should not be confused with the other one). Still a computer will know what the title of the page is, it knows it thanks to the title element.

提交回复
热议问题