liveBook · Manning

Main

As explained in Build a Website with ChatGPT

A main element is an HTML element that identifies the principal content of a document.

The HTML `<main>` element marks the content unique to the current page. A site’s header, navigation, and footer may repeat across pages; `<main>` holds what makes this page different. Use only one `<main>` element per page, typically after the header and navigation. section 12.2.1

<header>
    <h1>Antediluvian Word Preservation Society</h1>
    <p>Preserving words from the past for the future</p>
</header>
<nav>
    <a href="index.html">Home</a>
    <a href="blog.html">Blog</a>
    <a href="faq.html">FAQ</a>
    <a href="about.html">About</a>
    <a href="contact.html">Contact</a>
</nav>
<main>
    Unique page content goes here
</main>

This HTML example places `<main>` after a header and navigation links, with a placeholder for the page’s unique content. section 12.2.1

What goes inside depends on the page. A book club page can put its introduction, current selection, and next meetup in `<main>`. An online journal can put its entries there. For a hobby site, it can hold a welcome paragraph and sections linking to subtopic pages. section 4.1 section 5.1 section 7.3.2

Ask for a page layout

A beginner-friendly prompt can say: “Write the HTML for a page with a header containing the site title, navigation links, a main element containing an introductory paragraph and a section for each subtopic, and a footer with a copyright notice. Write the CSS separately.” Save the generated HTML as `index.html` and its linked CSS as `styles.css`; check that the files are together. section 7.3.2

For a more detailed layout, `<main>` can contain an `<article>` and an `<aside>` arranged in two columns with CSS Grid. The layout can switch to one column on smaller screens. You can request the page skeleton first and add the article and sidebar writing afterward. section 12.2.10

Tip: specify a maximum width for `<main>` when requesting CSS so lines of text do not grow too long. The page content can change without changing `<main>`’s job: identifying the principal, page-specific area. section 7.3.2 section 12.2.1

How Build a Website with ChatGPT covers it

How deep it goes
Defines placement and the one-per-page rule, then demonstrates content and layouts; does not explore browser internals.
Examples
Uses book club sections, expandable journal entries, and a two-column article with a sidebar as page-specific content.
What it assumes
Starts with a plain-language HTML layout definition and accommodates readers who do not know how to code; some projects assume prepared content or design choices.
What you can do after
Apply it via ChatGPT prompts to generate a page whose main element contains specified content or an article layout.
How it connects
Connects main to HTML header, nav, footer, section, article, and aside elements, plus CSS Grid.

Also explained in

Compare how 3 books explain main →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build a Website with ChatGPT. The section links point to the parts of the book it draws on.