News for hackers. Stuff that matters.
Re:A few HTML tips by msl09 on Wednesday August 24, 2016 @08:54AM (#12351631)
I can see the value of almost all of those recommendations but I don't understand the value of using the correct header sequence or tagging subheaders. I don't see anything in the linked W3C article that explains why I should use one idiom over another.
Re:A few HTML tips by throwanem on Wednesday August 24, 2016 @10:19AM (#12352191)
Consider automated TOC generation. If you use the h* tags as they're designed to be used, it's trivial to produce a table of contents for even a very complex document by simply extracting and numbering the headers, and hyperlinking it is almost as easy.

Consider screen readers and other accessibility technologies. If you use the h* tags as they're designed to be used, it is very easy for someone who cannot see your document to navigate within it by moving from header to header, and to navigate within sections by moving from subheader to subheader.

These are two examples of automatically extracting semantic information from an HTML document in order to enable new ways of interacting with its content. Such methods can only work if the semantic information is there to begin with. Using standard header tags in the standard fashion is a good, simple way to include such information. It is not the only way, but it is by far the most widely understood way, and you do both yourself and your readers a favor by not requiring the use of special-case exceptions to parse your content.

Of course, if your purpose is not to publish content, then this may not be a major concern for you. Perhaps you're building one of those modern-style marketing sites where the presentation is excruciatingly visual, the standard interaction methods are unnecessarily hijacked, and the content is minimally existent. In that case, I wouldn't worry so hard about it. But if you're publishing something that's got some meat to it, this is a standard worth following.

Re:A few HTML tips by steveax on Wednesday August 24, 2016 @11:22AM (#12352682)
Also, WRT screen reader users, like sighted users, they often scan the document by skimming the headings, links, etc. Screen reading software will pull these out into separately scannable lists available for the user to skim through outside of the context of the surrounding content. Having out of order heading creates a document outline that is confusing. This is why it's also important to write good linked text as scanning 20 links that all say "read more" is useless.
Re:A few HTML tips by YngwieMalware on Wednesday August 24, 2016 @09:13AM (#12351733)
A lot of it is semantics. A bunch of HTML5 is semantic vs. actually having different behavior. <header> behaves no differently than <div id="header"> but is more semantically correct.
Re:A few HTML tips by FroshKiller on Wednesday August 24, 2016 @10:01AM (#12352051)
A simpler way to say "more semantically correct" is "correct." Please don't trivialize the importance of semantics. Proper semantic representation makes documents more accessible.
Re:A few HTML tips by cloverich on Wednesday August 24, 2016 @10:19AM (#12352196)
I don't find the header, article, section, etc tags to be sufficiently clear that they are always used in the same way by different people. But maybe I'm missing something -- how do they improve accessibility?
Re:A few HTML tips by throwanem on Wednesday August 24, 2016 @10:23AM (#12352220)
Take a look at http://accessiblehtmlheadings.com/ for a pretty solid introduction. The tl;dr: is that, used properly, they enable screen readers and similar to identify document structure and make it more easily navigable.
Re:A few HTML tips by FroshKiller on Wednesday August 24, 2016 @10:56AM (#12352481)
Sorry, I should've provided a reference for you. The link throwanem posted is a good introduction with an interactive demonstration.
Re:A few HTML tips by rocky1138 on Wednesday August 24, 2016 @10:19AM (#12352188)
Do you have any documentation for this? This part of the article is what stood out for me, too.
Re:A few HTML tips by throwanem on Wednesday August 24, 2016 @10:22AM (#12352212)
The relevant section of the standard: https://www.w3.org/TR/html5/sections.html#the-h1,-h2,-h3,-h4... - https://www.w3.org/TR/html5/sections.html#headings-and-secti... expands on this somewhat further.

For a considerably more detailed treatment with special attention to concerns around accessibility and some information on other document elements with similar significance, take a look at http://accessiblehtmlheadings.com/ .

Re:A few HTML tips by rocky1138 on Wednesday August 24, 2016 @10:48AM (#12352416)
I see. For the longest time I've been using <h2> as a sub-title. I guess I'll have to stop that. Thanks!
Re:A few HTML tips by throwanem on Wednesday August 24, 2016 @10:51AM (#12352441)
You are most welcome!
Re:A few HTML tips by FroshKiller on Wednesday August 24, 2016 @10:57AM (#12352490)
Sorry again, I should've provided a reference for you. The link throwanem posted is very good.
Re:A few HTML tips by nommm-nommm on Wednesday August 24, 2016 @11:34AM (#12352767)
I think it also make the HTML easier to read.
Re:A few HTML tips by squeaky-clean on Wednesday August 24, 2016 @12:46PM (#12353342)
It's helpful to other computers reading your website. This can be anything from a screen reader to a search engine crawler to a script like Readability for extracting the readable sections of a website to a document.
Re:A few HTML tips by nerdponx on Wednesday August 24, 2016 @11:38AM (#12352793)
I know this is tangential, but Pandoc and Markdown in general benefit greatly from it.
Re:A few HTML tips by joshkpeterson on Wednesday August 24, 2016 @09:50AM (#12351961)
Isn't it because of the way screenreaders prioritize which headings to read based on the #? Eg read H1, then H2's, etc.