Live data from Hacker News

The ﹤main﹥ element

html5doctor.com

61–70 of 93 posts

Re: The ﹤main﹥ element

#61
Why are people hating on HTML semantics? I fear it is out of some fundamental misunderstanding of how semantics work on the web...

First let me be clear that there are (at least) two types of semantics on the web, one for machines (bots and screen readers) and one for meat (humans!).

In writing HTML, the goal is not to use every semantically-rich tag available and avoid everything else like the plague. Where you can convey extra semantic meaning, use the most appropriate tag available; where you cannot, use a div or a span or something else. Use of divs does not make your page less semantic - it is not deductive. However use of the correct semantic tags will make your page more semantic - it is additive!

In writing CSS, the goal is not to avoid classes/IDs altogether to keep your HTML "clean". The machines care not if your HTML is rammed full of classes; though you will certainly care when it comes to maintaining your pristine HTML. When writing CSS the goal isn't even to strive for "semantic" class names. CSS classes convey no semantics, at least not to machines. CSS classes should be used to convey semantics to the meat bags reading the code - devs, interested users etc. Nothing else matters with CSS, write it how you like, in as maintainable a fashion as possible and forget semantics in that domain.

Excellent article discussing the fallacies around semantics: http://nicolasgallagher.com/about-html-semantics-front-end-a...

Re: The ﹤main﹥ element

#62
post #40
post #37

I was honestly a little baffled to come into this thread and discover people were having trouble with semantic HTML. It's not hard to use, you just need to be inventive with your CSS. A page without divs, spans, strongs and bigs should be everyone's goal.

Could you show us one of your websites "without divs, spans"?

Still under heavy construction and playing with the layout, so forgive the ugliness of the css at the moment, but here is my personal website which I am attempting to do with good semantics and html5/css3 only, (no js).

http://www.warriors-shade.net

The actual article area will (should) accommodate the semantic tags well (main, article, aside, figure, etc).

Re: The ﹤main﹥ element

#63
post #4

Has anyone used all of the HTML5 tags in anger? I've tried a couple of times to build something fully "semantic". I struggle to create something that looks good semantically (ie just reading the HTML) and is also laid out on the page in the way I wanted it to be. There seem to be lots of situations, even in just mildly complicated web pages, where you need to write HTML code solely for graphics / layout reasons that…

I think that CSS is the biggest failure here. Let's say I have a blog, so for article page markup should be something like this: lorem ipsum search That way screen readers, search engines, etc will get the important stuff first and less important stuff afterwards. But since the common way of presenting blog is more like this: search I either have to do some hacky position:absolute things, crazy floats with negative e…

Does anyone know of any specific screen readers that actually take semantic HTML tags into account? Or is this just a theoretical thing? It would seem to me if screen reader software relied on authors of every random site to properly use semantic markup they wouldn't be in for a good time.

Re: The ﹤main﹥ element

#64
Question: is there any evidence that search engines actually use/respect semantic tags like , , , etc.? Or anyone here who knows firsthand from Google?

Just because, if I were writing a search engine, I would already have a bunch of "AI"/heuristics logic to tease these things out, since most sites don't use semantic HTML5 -- and it would probably do a solid job, since it's easy to compare a bunch of pages from a single site and figure out what parts are changing.

Then, if I actually started assuming that or was always the main/article part, it makes it easier for people to "game" the search engine with keyword-stuffing, etc. So, if I ran a search engine, I'd probably just ignore them completely and rely on my own heuristics.

(For example, Google completely ignores HTML language attributes: "Keep in mind that Google ignores all code-level language information, from “lang” attributes to Document Type Definitions (DTD). Some web editing programs create these attributes automatically, and therefore they aren’t very reliable when trying to determine the language of a webpage." [1] So I wouldn't be surprised if semantic HTML is the same deal.)

I've heard it endlessly repeated that semantic HTML helps SEO, and that's why you should use it. But I've never seen concrete evidence of this -- is there anything that actually backs it up?

[1] http://googlewebmastercentral.blogspot.com/2010/03/working-w...

Re: The ﹤main﹥ element

#65
post #40

Earlier quoted context omitted.

Could you show us one of your websites "without divs, spans"?

Still under heavy construction and playing with the layout, so forgive the ugliness of the css at the moment, but here is my personal website which I am attempting to do with good semantics and html5/css3 only, (no js). http://www.warriors-shade.net The actual article area will (should) accommodate the semantic tags well (main, article, aside, figure, etc).

That's pretty lame. It just navigation and some text dumped into the body.

I'm not 100% sure, but I think having outside of is not up to HTML5 standards.

Re: The ﹤main﹥ element

#66

Question: is there any evidence that search engines actually use/respect semantic tags like , , , etc.? Or anyone here who knows firsthand from Google? Just because, if I were writing a search engine, I would already have a bunch of "AI"/heuristics logic to tease these things out, since most sites don't use semantic HTML5 -- and it would probably do a solid job, since it's easy to compare a bunch of pages from a sing…

Offtopic, but I'm not sure means what you think it means. It could be an article like in a magazine, but according to the spec it's for any "self-contained composition in a document" like a widget or a comment. Each page could have many s. It's definitely not intended to indicate "this is the main content of the page."

Lots of people are confused though. This is one of the many problems with semantic markup in the real world.

Re: The ﹤main﹥ element

#67
post #28
post #13

Earlier quoted context omitted.

Flexbox[1] addresses the issue you're talking about - of course, browser support is still a little lacking (No support for IE9 or below, and IE10 doesn't conform to the current spec). [1]: https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Flexi...

In other words, it's useless for now, and for a few more years. God, I wish IE 8 wasn't the latest thing on XP (Still a lot of users on windows XP) and that new features weren't added only in major releases that happens rarely for Microsoft. Rarely, that is, compared to other vendors on the market.

I give Google a lot of credit with how they set up Chrome. The first thing they built out was a really nice auto-update function.

Re: The ﹤main﹥ element

#68
post #57

Earlier quoted context omitted.

But that is not was I was looking for. In your example navigation is the first thing in the markup, when content should be the first thing. Also, navigation does not belong to article, it belongs to site. And the same goes for footer. And those skip to content -links just the kind of hack we should not have to do. There should not be anyhting before the content, markup-wise.

Not necessarily. Nav inside article functions the same as the contents list in a Wikipedia article so if you don't want that, you can remove it from the article. If you want secondary links to other related content, those should go in a different nav in aside. If you want site-wide links, you can create a separate nav outside the article. Also of note, footer can be for the article or the whole page. If you like, you…

In my example there was a site navigation, not article navigation. And with article navigation, the same problem exists. The article should be before the navigation. But it's not practical at all to implement.

And what comes to skip to content -links, those definetly are hacks. What they mean is "Dear user, we would have put the content first in the source, but since CSS is not a layout definition language, it was not possible, take this link instead."

Re: The ﹤main﹥ element

#69

Question: is there any evidence that search engines actually use/respect semantic tags like , , , etc.? Or anyone here who knows firsthand from Google? Just because, if I were writing a search engine, I would already have a bunch of "AI"/heuristics logic to tease these things out, since most sites don't use semantic HTML5 -- and it would probably do a solid job, since it's easy to compare a bunch of pages from a sing…

From what I understand, the short answer is "No, they don't". The long answer is "They don't yet, but if we keep telling people they do and everyone starts using semantic HTML, they will".

Re: The ﹤main﹥ element

#70

Question: is there any evidence that search engines actually use/respect semantic tags like , , , etc.? Or anyone here who knows firsthand from Google? Just because, if I were writing a search engine, I would already have a bunch of "AI"/heuristics logic to tease these things out, since most sites don't use semantic HTML5 -- and it would probably do a solid job, since it's easy to compare a bunch of pages from a sing…

A few years ago I worked on a digital library system and we would sweat over including proper metadata about articles in meta tags (derived from the Dublin Core attributes entered by the authors). That was until we met with someone at Google who worked on Scholar. He said there was no harm in including that metadata, but they usually had more success inferring things like authors, title, etc from the HTML content of the page so they ignored it for the purposes of indexing. Things may have changed, but basically I think you're right that semantic markup is easy to game so probably doesn't affect SEO. Doesn't mean it's not worth doing though :)
Post reply on HN