Links and Images
The bakery's homepage needs a link to the menu, a link to a map, and a photo of the morning's loaves. Links are what make the web a web, and images are often most of what a page downloads. Each comes with one attribute you must never forget.
The rule
Every link needs a destination; every image needs a text alternative.
Links use the <a> (anchor) element. Its href attribute is the destination:
<a href="https://maps.example.com/crumb">Find us on the map</a>
<a href="/menu">See the menu</a>
<a href="menu.html">See the menu</a>
<a href="#opening-hours">Opening hours</a>
<a href="mailto:hello@crumbbakery.com">Email us</a>- An absolute URL includes the scheme and domain:
https://maps.example.com/crumb. Use it for other sites. - A root-relative path starts with
/:/menumeans "the menu page on this same site", wherever you are on the site. - A relative path has no leading slash:
menu.htmlis looked up next to the current page. - A fragment starting with
#jumps to the element with thatidon the page. mailto:andtel:open email or the phone dialler.
The link text itself matters. "See the menu" tells everyone where it goes. "Click here" says nothing, which is a problem for screen-reader users who often browse a list of links on their own.
Images use the void element <img>:
<img src="images/sourdough.jpg"
alt="A round sourdough loaf with a deep golden crust"
width="800" height="600">srcis where the file lives, using the same path rules as links.altis the text alternative: shown if the image fails, read aloud by screen readers, and used by search engines. Describe what the image shows that matters to the page.widthandheightlet the browser reserve space before the file arrives, so the text below does not jump when it loads.
If an image is pure decoration (a swirl between sections, say), write alt="". The empty value tells screen readers to skip it. Leaving alt out entirely is different and worse: some screen readers then read out the file name.