How to section HTML elements笔记

看到一篇文章的笔记

  • sectioning elements: <nav> <aside> <article> <section> <body>
    • difference between <article> and <section>
      • <article> is like B(Block) in BEM while <section> is like E(Element)
      • <article> stores self-contained content which makes sense when placed in a different context
      • <section> is a sub-section that requires context from its parent sectioning element
    • comments sections should be wrapped in an <article>
  • don’t wrap div for a section
    • <div> has no semantic meaning
    • useful for the sake of styling purposes
  • header and footer
    • don’t put header or footer inside header or footer
    • no side bars or navigation in it
    • one <main> element on page visible
  • labeling sections —— one method a time
    1. add an aria-label attribute (cannot translate language)
    2. add a <h#> element
    3. use an aria-labelledby attribute