4 ms·
I think this blog post makes things more complicated than they need to be. You don't need to use either <article> or <section>. Outside of accessibility, sema
by ravenstine 4y ago
I think this blog post makes things more complicated than they need to be. You don't need to use either <article> or <section>. Outside of accessibility, semantic HTML isn't really worth thinking a lot about. Is it going to matter if you accidentally use <article> and <section> like any <div>? Probably not.
> Should I Bother? Yes, you absolutely should. [...] Firstly, this article by Mandy Michael reveals that browsers pay attention to your HTML structure to generate a Reader mode which strips the page of unnecessary information, images and background.
Reader mode is not a universally good reason to be using article and section elements. It only matters if you care that much about Reader mode, and Reader mode is not a part of any web standard. Make your webpage so readable that Reader mode isn't necessary.
> Secondly, It helps you actively think about how you present your content.
Depends on if it does. I've used both article and section since time immemorial and I honestly couldn't tell you if they helped me create better markup. I just use them because they seem logical and they're there, but I wouldn't really miss them if they were deprecated. Article is only really useful if you have multiple article-like places in your markup, since it actually has an "article" role, but sections are just like any other region in terms of accessibility and aren't that useful.
- squidbeak 4y ago> Outside of accessibility, semantic HTML isn't worth thinking a lot about. There is no 'outside of accessibility' - or shouldn't be.
- ravenstine 4y agoYou mean people don't read webpages without a screen-reader? There's no such thing as Reader mode? Web developers don't read HTML and want to write it in an organized way? Sure, there should be nothing outside of accessibility. /s If you read the post (and I can't really blame you for not reading it all the way through), you'd see that the author is suggesting that there are reasons besides supporting accessibility features for using these semantic HTML tags. I just don't agree that they are objectively good reasons for why one "should" do so. Oh yeah, and semantic HTML is by no means the only way to write pages that are accessible. Everything that a semantic tag can do, the role attribute can do, too. I never said to not care about accessibility.
- bXVsbGVy 4y agoThere is also portability. If you use main, article, etc is easier to write apps to process the page. Firefox reader mode use the main element to know how get the text from the page.
- extra88 4y ago> Everything that a semantic tag can do, the role attribute can do, too. <button> does far more than <div role=button> can do. Even if you meant to only refer to landmark roles, why write <div role=main> or <div role=region> when you can write <main> and <section>? As someone else pointed out, Reader modes don’t recognize roles and user stylesheets don’t either.
- chiefalchemist 4y agoAmen! I would give you a 1,000 of my HN karma points if I could.
- marginalia_nu 4y agoThat's kind of ridiculous. If it actually was true, that accessibility is not only an important concern when designing a website, but the singular overriding concern, then surely all websites ought to consist of a blank page with code like <html/> That's the most accessible website in the world. You can print it without paper, character encoding is no issue, RTL is no issue, you can see it when you are blind, you can listen to it spoken without connecting your headphones, even if you are deaf you can hear it spoken, it's printed in braille on the screen (or any flat surface), it works in all languages spoken and written and sign language. It really is the pinnacle of accessibility. It's even available in dead languages such as Linear A and Etruscan. Every website with any sort of content is strictly less accessible than this website (which also is as utterly useless as it is accessible).
- chrismorgan 4y agoJust to take a ridiculous idea seriously, because it’s fun⸺ The minimal “valid” HTML page is actually this: <!DOCTYPE html> … though it’s only valid in contexts that don’t require an in-document title, such as email text/html parts (the Subject header from the MIME message is used) or frames (no title is needed); for a top-level page in a web browser, to be “valid” it needs a non-empty title, such as <!DOCTYPE html><title>x</title> In both of these, the <html> open and close tag are omitted, as they’re both optional in HTML syntax. If you’re not caring about validity or quirks mode, then you might as well just serve a zero-byte text/html body. As for XML syntax which you seem to have tried to use, <html/> wouldn’t be a valid HTML document because you haven’t used the http://www.w3.org/1999/xhtml http://www.w3.org/1999/xhtml namespace.
- marginalia_nu 4y agoEh, my example renders perfectly well in every browser.
- xigoi 4y agoSo does a completely empty file.
- bluSCALE4 4y agoThe first point really paints you in a bad light. Be better.
- GlitchMr 4y agoAccessibility matters. If nothing else because it is a legal requirement with laws such as US's Americans with Disabilities Act, UK's Disability Discrimination Act, EU's European Accessibility Act, Australia's Disability Discrimination Act, and Ontario's Accessibility for Ontarians with Disabilities Act.
- ravenstine 4y ago> Accessibility matters. I never said that it doesn't. > If nothing else because it is a legal requirement Whether something is a law or not has nothing to do with whether something is a moral obligation or a correct decision.