You design a website layout in HTML by building the page’s structure first and leaving appearance mostly for CSS: sketch the areas, choose semantic landmarks such as header, nav, main, and footer, group related content into sections and articles, add one h1 that states the page topic, then order everything so it still reads correctly with styles removed. The layout is “done” when the content sequence makes sense on its own and the containers can be repositioned by CSS without rewriting the markup. HTML answers what the pieces are; CSS decides where they sit.

That division matters because layouts break most often when structure and styling get tangled. A page built from a dozen nested divs can look fine on a wide screen and fall apart the moment the viewport narrows, a screen reader tries to navigate it, or a font-size preference enlarges the text. Keeping HTML meaningful makes every later step—grid, flexbox, breakpoints—easier to change. This guide walks through a workable design order, starting from the content model and ending with a checked, accessible responsive shell.

Start With Content Areas and a Wireframe, Not Code

Before typing tags, list what the page must carry and how the pieces relate. A typical marketing or publication page has a top area for identity and navigation, a main column for the primary content, a secondary column or strip for related material, and a footer for legal and contact details. An application screen might have a persistent sidebar, a toolbar, and a scrollable work area. The point is to name the regions and rank them, because HTML landmarks mirror that ranking.

A quick wireframe—boxes drawn on paper or in any drawing tool—forces three decisions early:

Priority. Which area must the visitor see first? On a news article, that’s usually the headline and the story; on a product page, the product name, price, and buy action. Repetition. Does the page need repeated units, like cards, list rows, or comment entries? Repeated units become a list or a set of articles, not a stack of divs. Independence. Which blocks could move or disappear on a small screen? Knowing this now prevents a layout that only works in one arrangement.

Label the boxes with content, not visuals. “Site header,” “section navigation,” “latest articles,” “newsletter signup,” “footer.” If a box only exists to hold a background color or a shadow, it isn’t a layout region—that’s a styling job later. Any box that survives this test is a candidate for a semantic element.

This stage also sets the page’s tone for structure: a mostly linear reading flow (article, documentation page, policy) belongs in a single main column, while a dashboard with parallel panels leans on complementary regions. Both are valid; they just produce different landmark patterns.

Choose Semantic Landmarks Before Divs

Semantic elements describe the role of a region, and browsers, assistive technology, and search engines all use those roles. The core set for a page layout is small and stable:

for introductory material of the page or of a section. A page-level header usually holds the site name, a logo link, and primary navigation.

for closing material: copyright, contact, related links.

for a thematic grouping that would sensibly appear in an outline, usually with a heading.

for a self-contained unit that would make sense syndicated on its own—a blog post, a product card’s content, a forum entry.

A simple page shell using them looks like this:

Two refinements prevent common problems. First, when several nav elements exist (primary, breadcrumb, footer), give each a distinct aria-label so assistive technology can tell them apart. Second, remember that header and footer also apply inside sections and articles; a card’s article can have its own header holding the title and byline. That nesting is legitimate and keeps repetitive units clean.

Divs still have a place: as pure styling wrappers when no semantic element fits, or as grouping hooks for CSS Grid and Flexbox. The rule of thumb is to use the most specific element that describes the content, and fall back to only when nothing more precise applies. Avoid “divitis”—wrapping every heading and paragraph in its own div—because it adds nesting without meaning.

Check your work: temporarily remove all CSS in the browser’s developer tools. The page should read top to bottom in a logical order, headings should form a clear outline, and every interactive control should still work. If that holds, your structural foundation is sound.

Order the DOM for Reading and Keyboard Flow

The order of elements in the HTML source is the order screen readers announce and the order a keyboard’s Tab key follows. Visual position, set by CSS, is not guaranteed to match. That gap is where many layouts fail accessibility: a sidebar that visually sits on the left but appears after the main content in the source is fine for reading order, but links placed visually above content while coded below will frustrate keyboard users.

Design the source order around importance and logic:

1: Page header and primary navigation. 2: The main heading and primary content. 3: Supporting asides and related material. 4: Footer.

Within the main content, follow the reading sequence a person would use: intro, body sections with their headings, calls to action where they naturally occur. If your visual design needs a sidebar on the right, code it after main in the source; CSS Grid can place it to the side. If a “skip to content” link is useful—and on sites with long navigation it usually is—put it as the first focusable element and have it target the main region.

This ordering discipline pays off later. When you rearrange blocks with grid or flexbox, you never have to worry that the visual order has silently contradicted the accessible order. A quick test: Tab through the page from the address bar. Focus should move in a sensible sequence, and every link or button should show a visible focus indicator.

One caveat worth knowing: CSS can reorder flex and grid items visually, and it can even reorder items with the order property. Use that power sparingly. Reordering should refine layout, not invert reading order. A “back to top” link belongs at the end of the content where it’s needed, not visually relocated to the start.

Group Content With Sections, Articles, and Headings

Sections and articles aren’t just containers; they’re the page’s outline. A well-structured page has one h1, then h2 for major sections, h3 beneath them, and so on, without skipping levels. Headings make the page scannable for sighted readers and navigable by heading for screen-reader users.

Inside each section, put the heading first, then the content it labels. A section without a heading is suspicious: either it’s not really a thematic group (use a div) or it’s missing a label that would help readers. For repeated units—news cards, product tiles, search results—use a list ( or ) of article elements, each with its own heading. This communicates “here is a collection of independent items” in a way a pile of divs never does.

Consider a “latest articles” block. The clear structure is:

Now the section is labeled by its heading, each item is an independent article, and the list conveys grouping. CSS can turn the into a grid of cards with a single rule; no markup changes required.

The article element has a nuance: it should be used for content that stands alone, like a full post or a distributable card. If a block only makes sense in context—a subscription form, a caption, a decorative banner—it isn’t an article. When in doubt, prefer section with a heading or a plain div for styling.

Add Controls and Content Blocks Without Breaking the Structure

Layouts are more than regions; they’re full of controls and content blocks. A few HTML habits keep those from undermining the structure.

Forms. Every input needs a label. Use tied to the input’s id, or wrap the input inside the label. Group related controls with and , especially radio buttons and checkboxes. A search box in the header, for example, should have a visible label or an accessible name, plus a submit button that actually says something like “Search.” Placeholder text alone is not a label; it disappears as soon as the user types.

Images. Give every meaningful image an alt attribute that describes its purpose in context. Decorative images get an empty alt="" so assistive technology skips them. Set width and height attributes (or an aspect ratio in CSS) so the layout reserves space and doesn’t jump when images load.

Links and buttons. Use for navigation to another page or section, and for actions that change something on the current page. A link styled as a button is still a link; using the right element gives keyboard behavior for free: links activate with Enter, buttons with Enter and Space. Tables. Tabular data belongs in with , , scopes, and . Tables are for data relationships, never for page layout. If you catch yourself wanting a table to position blocks, that’s a signal to use CSS Grid. Blockquotes and figures. for quotations, with for illustrations with captions. These are structural, not decorative, and they help the reading order make sense. A practical habit: whenever you add a block, ask what it is before asking how it should look. This keeps the source clean and makes the visual layer a set of small, reversible overrides. Move From Structure to Visual Layout With CSS With the HTML framework in place, layout becomes CSS work, and the modern tools are Grid and Flexbox. A common, durable pattern is Grid for the page shell and Flexbox for components. For the page shell, a grid on the body or a wrapper can define named regions that match the landmarks: Then, at a breakpoint, change the areas to a single column: This approach is powerful because the HTML never changes; only the CSS grid template does. The source order stays accessible, and the visual arrangement adapts. Notice that the single-column layout keeps the source order intact: header, main, aside, footer. Flexbox handles the inside of components: a header bar with logo left and nav right, a card footer with a button aligned to the edge, a row of tag chips. A typical header rule sets display: flex; align-items: center; justify-content: space-between; gap: 1rem;. Flexbox distributes space along one axis, so it’s ideal for toolbars and rows. Keep the styling layer shallow. A CSS rule that targets a semantic element—main > section or header nav—is easier to reason about than a chain of generated class names, though utility classes have their place in large teams. The test is whether you can change a layout region’s position without editing the HTML structure, and whether you can restyle a component without touching unrelated regions. Grid areas and semantic selectors make both true. One more link between structure and style: don’t hide essential content with CSS in a way that removes it from the source. If a sidebar is irrelevant on mobile, reorder or reflow it; don’t delete it with display: none if the content matters. If it truly doesn’t matter to the page, consider whether it belongs in the HTML at all. Validate, Test, and Fix the Layout’s Weak Points A layout isn’t finished when it renders; it’s finished when it behaves under pressure. A short test routine catches the common failures. Start with a validator. The W3C Markup Validator checks for nesting errors, unclosed tags, and malformed attributes. Clean markup prevents browsers from guessing at structure. Test without styles. Remove CSS or disable it in developer tools. Confirm that the content flows in a logical order and headings outline the page clearly. If the unstyled page is a mess of unlabeled blocks, the markup is probably too div-heavy. Check heading structure. One h1, no skipped levels, and each section heading labeling its content. Some screen-reader users navigate exclusively by headings, so this outline is a primary interface. Run an accessibility audit. Tools like Lighthouse, axe, or WAVE flag missing alt text, missing form labels, insufficient contrast, and other issues. Fix structural problems first—landmarks, labels, headings—then visual ones. Resize the viewport. Squeeze the browser window from wide to narrow. Text should reflow without horizontal scrolling, images should shrink, and controls should stay reachable. Also test with enlarged text—200% zoom is a common baseline—to ensure nothing clips or overlaps. Since layout should follow content, a grid that switches to one column at a chosen breakpoint is a reasonable start, though the correct breakpoint depends on where your content actually breaks, not on device names. Keyboard test. Tab through the page. Focus should move in source order, focus outlines should be visible, and interactive controls should respond to Enter or Space as appropriate. A “skip link” should become visible on focus and move focus to the main content. Slow connection and missing images. Thumbnail the network or block images to see whether the layout holds when media is delayed. Reserving space with width and height attributes keeps the page from jumping. If the visual order on screen disagrees with the keyboard order, the fix is usually in the HTML, not the CSS. Rewriting the source order to match the intended reading order—then using grid areas to place things visually—resolves the mismatch at its root. A Complete Worked Example: Documentation Page Shell A documentation page makes a good end-to-end case because it combines a persistent sidebar, a long reading column, and in-page navigation. Prerequisites: a text editor, a browser, and a folder for the project. No framework is needed. 1: Sketch the regions. Top bar with site name and search; left sidebar with guide navigation; main column with the article; right column with “on this page” links; footer with license text. 2: Write the skeleton. Header with a link and a nav for the search; a wrapper containing aside (guides), main (article), and aside (“on this page”); footer. All landmarks get labels. 3: Add headings and content. One h1 in main, h2 per major topic, short paragraphs, code samples in pre and code. The sidebars use nav with aria-label values like “Guide sections” and “On this page.” 4: Style the shell with Grid. A three-column template on wide screens: grid-template-columns: 16rem minmax(0, 1fr) 14rem; with areas for the sidebars and main. The header and footer span all columns. 5: Go single-column on narrow screens. At a breakpoint, switch to one column and let the source order decide reading order: header, guide nav, main, on-page nav, footer. 6: Test. Validate the markup, remove CSS to check order, run an audit, tab through the page, and resize the viewport. The result is a page whose structure is meaningful and whose arrangement is disposable. You can later move the left nav to the top, drop the right column, or turn the guide nav into a collapsible disclosure, all by changing CSS and a little HTML—not by rebuilding the page. When the Structure Needs Help: Troubleshooting Common Layout Failures Most layout problems trace back to a handful of causes, and the first move is usually a reversible one. If content overflows a container on small screens, the likely cause is a fixed width or a wide element like a preformatted code block. Check for width values in pixels and add min-width: 0 to grid or flex children that should shrink. If a sidebar collapses to zero width, the grid track may be sized with 1fr where minmax(0, 1fr) is needed. If the keyboard order doesn’t match the visual order, suspect CSS reordering or an HTML source order that puts a visually leading block after the main content. Fix the source first. Similarly, if a screen reader skips a region, check that it isn’t marked aria-hidden or hidden with CSS. If the page jumps as it loads, missing width and height on images or fonts swapping in are common causes. Reserve space for media and test with a throttled connection. Stop and bring in an accessibility specialist or a developer when a fix would require rearchitecting landmarks, splitting a huge monolithic page, or addressing complex interactive widgets like date pickers or drag-and-drop interfaces. Those components need careful keyboard and assistive-technology handling beyond a layout tutorial’s scope, and guessing can create barriers that are harder to remove later. Above all, treat the HTML layout as the stable layer and the CSS as the adjustable one. When a visual tweak tempts you to add a div wrapper or a table, first check whether a grid or flex property can do the job. The fewer structural changes a redesign requires, the healthier the page is.