A web page is more than headings and paragraphs. Add images with useful alternative text and group content using semantic elements that describe the purpose of each region.
The <img> element displays an image. Its src attribute identifies the file or URL, and its alt attribute provides a text alternative. Write alt text that communicates the information the image contributes.
Use a meaningful relative path when the image is part of your project, such as images/campus.jpg. A broken path means the browser cannot locate the file. The image file must actually exist at that location.
Elements such as <header>, <nav>, <main>, <section> and <footer> describe the role of content. They do not automatically create a visual layout; CSS controls how those regions look.
Use <main> for the page’s primary content. Use <nav> around major navigation links. A section should normally have a heading that explains what the section contains.
Alternative text is not a place for keyword stuffing. For a decorative image, an empty alt="" can keep screen readers from announcing unnecessary information. For an informative image, describe its relevant purpose.
Do not use a generic <div> for every part of the page. Semantic HTML gives browsers and assistive technologies more useful information and makes your code easier for other developers to understand.
<header>
<h1>Code Campus</h1>
<nav><a href="index.html">Home</a> <a href="courses.html">Courses</a></nav>
</header>
<main>
<section>
<h2>Our department</h2>
<p>Learn the foundations of computing.</p>
<img src="images/campus.jpg" alt="Students working in a computer lab">
</section>
</main>
<footer><p>Code Campus</p></footer>
<figure>
<img src="images/lab.jpg" alt="A computer laboratory with desktop workstations">
<figcaption>Practical learning in the computer lab.</figcaption>
</figure>
Create a page with a header, navigation, main section, an image with alt text and a footer. Use section for the main content group.
<header><h1>My Portfolio</h1></header> <nav><a href="index.html">Home</a></nav> <main><section><h2>About</h2><img src="profile.jpg" alt="Profile portrait"></section></main> <footer>Made for practice</footer>