HTML and CSS · Lesson 2 of 12

Text, links and images

Most of the web is text, links and pictures. Use the element that says what the thing is, and the browser, search engines and screen readers all understand your page.

Headings, paragraphs and lists

Headings go from <h1> (the page's main title, once per page) to <h6>; don't skip levels just to get a smaller size: that's CSS's job. Paragraphs are <p>. Lists are <ul> (bullets) or <ol> (numbers), with an <li> for each item.

Try itEdit the code: the page updates as you type

<a href="…"> makes a link. An absolute address has the full URL (https://example.com/page); a relative one is relative to the current page (about.html, /contact/). href="#faq" jumps to the element with id="faq". Add target="_blank" to open a new tab.

Write link text that makes sense on its own: "Read the placement plan", not "click here".

Try itEdit the code: the page updates as you type

Images

<img src="photo.jpg" alt="…"> shows an image. The alt text is read aloud by screen readers and shown when the image can't load, so describe what matters in it; for a purely decorative image, use alt="". Give width and height so the page doesn't jump when the image arrives.

Try itEdit the code: the page updates as you type

Your turn

Make a short "About me" page: a heading, a paragraph, a list of three skills, and a link to your GitHub that opens in a new tab.

ExerciseEdit the code: the page updates as you type
Show a solution
<h1>About me</h1>
<p>Final-year student who likes building small web apps.</p>
<ul>
  <li>JavaScript</li>
  <li>SQL</li>
  <li>Git</li>
</ul>
<a href="https://github.com/" target="_blank" rel="noopener">My GitHub</a>

In the interview

Why does alt text matter?

Screen readers read it to people who can't see the image, it shows when the image fails to load, and search engines use it to understand the image. Decorative images get an empty alt so they're skipped.

What is the difference between an absolute and a relative URL?

An absolute URL has the protocol and domain (https://example.com/a/); a relative one is resolved from the current page (a/ or /a/). Relative links keep working when the site moves to another domain.

Why use rel="noopener" with target="_blank"?

Without it, the new page could reach back to your page through window.opener and change it (for example, to a phishing page). Modern browsers apply noopener by default, but writing it keeps older ones safe.

Your progress stays on this device.