Layout in HTML
? Layout in HTML
HTML provides the structure for your webpage’s layout, but layout design is mainly controlled by CSS. However, HTML offers important elements to help organize content visually.
Basic HTML Elements for Layout
| Element | Purpose |
|---|---|
<div> | Generic container to group elements |
<section> | Defines a section in a document |
<header> | Defines a header for a document/section |
<footer> | Defines a footer for a document/section |
<nav> | Defines navigation links |
<article> | Represents independent content like a blog post |
<aside> | Sidebar content related to the main content |
How to Create Layout Structure
HTML is like the skeleton, and CSS is like the style & positioning.
Example HTML Layout
<body> <header> <h1>Website Title</h1> </header> <nav> <!-- Navigation links --> </nav> <section> <article> <h2>Article Title</h2> <p>Content goes here.</p> </article> <aside> <h3>Sidebar</h3> <p>Additional info.</p> </aside> </section> <footer> <p>© 2025 My Website</p> </footer></body>Layout with CSS
Use Flexbox (
display: flex;) or Grid (display: grid;) for advanced layouts.Control positioning with
margin,padding,width,height, andpositionproperties.
Summary
Use semantic HTML elements for meaningful layout structure.
Use containers like
<div>and<section>to group content.Apply CSS for visual arrangement and responsiveness.
Want me to show examples using CSS Flexbox or Grid for layout?