4 min read•july 31, 2024
HTML structure and semantics form the backbone of web development. They're like the skeleton and muscles of a webpage, giving it shape and meaning. Without them, your content would be a jumbled mess.
Understanding these concepts is crucial for creating well-organized, . Proper HTML structure and semantic elements not only make your code easier to read but also boost your site's SEO and user experience. It's the foundation you need to build awesome web projects.
[<html>](https://www.fiveableKeyTerm:<html>)
root element
[<head>](https://www.fiveableKeyTerm:<head>)
contains metadata about the document[<body>](https://www.fiveableKeyTerm:<body>)
section holds the visible content of the web page<!DOCTYPE html>
declaration must appear as the first line of an document specifying the document type and versionname="value"
<head>
element encompasses metadata about the document
<[title](https://www.fiveableKeyTerm:title)>
, [<meta>](https://www.fiveableKeyTerm:<meta>)
, and <[link](https://www.fiveableKeyTerm:link)>
<body>
element contains all visible content of the web page
<!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> [<h1>](https://www.fiveableKeyTerm:<h1>)Welcome to My Website</h1> <p>This is a paragraph.</p> </body> </html>
[<header>](https://www.fiveableKeyTerm:<header>)
element represents introductory content or navigational links at the beginning of a section or page[<nav>](https://www.fiveableKeyTerm:<nav>)
element defines a set of navigation links within a document[<main>](https://www.fiveableKeyTerm:<main>)
element specifies the primary content of a document unique to the document excluding repeated content[<footer>](https://www.fiveableKeyTerm:<footer>)
element represents a footer for its nearest sectioning content or sectioning root element typically containing authorship, copyright, or contact information[<article>](https://www.fiveableKeyTerm:<article>)
element represents a self-contained composition in a document (blog posts, news stories, forum posts)<section>
element defines a thematic grouping of content typically with a heading within a documentelement used for content tangentially related to surrounding content (sidebars, pull quotes)
<header> <nav> <[ul](https://www.fiveableKeyTerm:ul)> [<li>](https://www.fiveableKeyTerm:<li>)<a href="#home">Home</a></li> <li><a href="#about">About</a></li> </ul> </nav> </header> <main> <article> <h1>Article Title</h1> <p>Article content...</p> </article> <aside> [<h2>](https://www.fiveableKeyTerm:<h2>)Related Links</h2> <ul> <li><a href="#">Link 1</a></li> <li><a href="#">Link 2</a></li> </ul>
<h1>
to [<h6>](https://www.fiveableKeyTerm:<h6>)
) to organize content and improve accessibility<ul>
, [<ol>](https://www.fiveableKeyTerm:<ol>)
, and <li>
) to group related items and create a clear structure for content<!-- comment -->
) to explain complex structures or provide notes for future reference or collaboration<!-- Header Section --> <header class="site-header"> <nav class="main-navigation"> <!-- Navigation items --> </nav> </header> <!-- Main Content --> <main class="content"> <article class="blog-post"> <h1 class="post-title">Article Title</h1> <p class="post-content">Article content...</p> </article> <aside class="sidebar"> <!-- Sidebar content --> </aside> </main> <!-- Footer Section --> <footer class="site-footer"> <!-- Footer content --> </footer>
<meta>
tag specifies metadata about an HTML document (character encoding, viewport settings, description)<meta>
tag specifies the character encoding for the HTML document typically set to "UTF-8" for modern web pages<meta>
tag crucial for controlling how a page displays on mobile devices<head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content="A brief description of the page content"> <title>Page Title</title> </head>
<link>
element defines relationships between the current document and external resources (stylesheets, favicons)<a>
(anchor) element creates hyperlinks to other web pages, files, or locations within the same page[<img>](https://www.fiveableKeyTerm:<img>)
element embeds images in an HTML document with the src attribute specifying the image source and the providing alternative text for accessibility<img>
element or by using the <picture>
element for more complex scenarios<link rel="stylesheet" href="styles.css"> <a href="https://example.com">Visit Example.com</a> <img src="image.jpg" alt="Description of the image" width="300" height="200"> <picture> <source media="(min-width: 650px)" srcset="img_pink_flowers.jpg"> <source media="(min-width: 465px)" srcset="img_white_flower.jpg"> <img src="img_orange_flowers.jpg" alt="Flowers" style="width:auto;"> </picture>