PricingBlog

Top level container

  • felixtanhm-1260199258116849797

    Felix

    1 year ago

    Does the top level container in a page need to be a <div>? It can't be a <main>?
  • andreasmoller-1260205316516089857

    Andreas Møller

    1 year ago

    It Can
  • patrickmast-1260234439414517871

    Patrick Mast

    1 year ago

    Is there a difference? Why should one use <div>, and why <main>?
  • patrickmast-1260238670724858028

    Patrick Mast

    1 year ago

    Claude says:
    When starting a new page choosing between <div> and <main> depends on the purpose and structure of your content. Let me explain the differences and when to use each:

    1. Using <div>:

    <div> is a generic container element used for grouping and structuring content without any semantic meaning. It's versatile and can be used for various purposes.

    Use <div> when:
    - You need a container for styling purposes
    - You're creating a section that doesn't have a specific semantic meaning
    - You're grouping elements together for JavaScript manipulation

    2. Using <main>:

    <main> is a semantic HTML5 element that represents the main content of the document. It should contain the central topic or primary functionality of the page.

    Use <main> when:
    - You're creating the primary content area of your page
    - You want to improve the semantic structure and accessibility of your document
    - You're following HTML5 best practices

    The preferable way:
    In general, using <main> is preferable for the main content of your page because:

    1. It provides better semantics, making your HTML more meaningful and easier to understand for both developers and assistive technologies.
    2. It improves accessibility, as screen readers and other tools can easily identify the main content.
    3. It follows modern HTML5 standards and best practices.

    However, you should only use one <main> element per page. For other structural elements within your page, you may still need to use <div> or other semantic elements like <header>, <footer>, <nav>, or <section>.

    😉
  • andreasmoller-1260238802111303711

    Andreas Møller

    1 year ago

    Spot on
  • felixtanhm-1260422453621162004

    Felix

    1 year ago

    I tried:
    1. Deleting the <div>
    2. Moving the <main> to be above the <div>

    Both approaches didn't work. Should I be doing something else?

    Also I'm assuming every page has a <body> element wrapping it by default?
  • lucasg-1260441794923987055

    Lucas G

    1 year ago

    Select the div and on the right panel, select the 'Attributes' tab
  • (can also press 'S' on your keyboard)
  • And change its tag to <main>
  • 1260441913207558214-image.png