
Once your page structure is complete, and your users can navigate from page to page, you can focus on what makes your site unique: its content.
The content of your page can include:
Text (such as the course material you're currently reading š ).
The structure of your page created by your heading hierarchy.Ā
ImagesĀ and icons, either informative or decorative.Ā
Other content such as videos, forms, etc.Ā Ā Ā
In this chapter, weĀ will focus on the text content and its hierarchy, as well as images.
The proper integration of headings enables good SEO results and allows assistive technologies to communicate your page's structure correctly. It also allows assistive technology users to navigate the page content more efficiently by jumping from heading to heading.
As you might remember,Ā HTML headings are used with the Ā hĀ tag for levels ranging from Ā h1Ā (the most important title) to Ā h6. It is important to maintain logic in the hierarchy of your page. So you should not skip tags by going from an Ā h2Ā tag to an Ā h4Ā tag.
In some cases, the first heading on the page may not be an h1 level heading. For example, when a page has a mega menu with navigation items grouped under headings, these headings may be h2 level headings, but appear before the first h1 level heading in the page structure.
Ideally, your page should contain a single h1 level heading that should identify the page's overall topic, and all subsequent headings should be nested hierarchically.
Images in many formats are everywhere on the web, whether they provide information or decorate a page.
The most common image formats are:
PNG - most often a design or an illustration.
JPG - primarily a photo format.
GIF - used for animated images.
SVG - a scalable vector format, which is gradually replacing PNG for logos and other images.
Letās start by focusing on the role of images and when they must be integrated using HTML or CSS.
If you compare the two images below, which do you think is informative and which is decorative?Ā
Ā 

The first image is in the background of our navigation menu. It does not provide any information to the user. In general, try to integrate decorative images using CSS. It helps to avoid overloading HTML with images that have no informative value. Bear in mind that the image will not be perceptible to assistive technologies when integrated with CSS, so only use it for decorative visuals.
Weāll add the second image using HTML so that we can include an alt attribute.
This brings us to the accessibility of images. The good news is that when you embed an image on your site using the Ā imgĀ tag, the Ā altĀ attribute is enough for accessibility. You do not need to add additional ARIA attributes.
There are a few things you should keep in mind when it comes to the Ā altĀ attribute:
If the image is decorative, and you have no choice but to embed it using HTML, you should leave the Ā altĀ attribute blank (alt="").
If the image is informative and, for example, is a photo of a cat playing with a ball of yarn, you do not have to add the words "photo of" or "image of": assistive technologies already know this from the Ā imgĀ tag. You can simply enter: Ā alt ="cat playing with a ball of yarn".
If the image is a link that leads to the homepage, this information needs to be included in the alt text. For instance,Ā alt="W3C - Home page"; the destination of the link is more important than whatās shown in the image.
Finally, the description of the image must be short, so keep it concise (no more than 250 characters).
Before we put things to practice, letās discuss icons and the SVG format.
Icons areĀ commonly used, both on smartphoneĀ and computer. They must also be integrated accessibly.
Icons are often purely decorative.Ā If the icon is purely decorative and does not contain links, you can hide it from assistive technologies using the Ā aria-hidden=trueĀ attribute.
<a href="/search">
<!-- Here the icon will be read by the screen reader -->
<i class="fas fa-search" aria-hidden="true"></i>
</a>But if your icon performs a function, you should add a text description. You can use a Ā spanĀ tag or add an Ā aria-labelĀ ,Ā as discussed in the previous chapter.
<i class="fas fa-coffee" aria-hidden="true"></i>
<!-- Here the span is read by the screen reader -->
<span class="screenreader-text">Consumption of coffee:</span>The Ā spanĀ tag won't be displayed visually on the page, so only assistive technology users will perceiveĀ its content.
The SVGĀ format is primarily used for icons and logosĀ and is increasingly replacing PNG for designs.
SVG is very powerful and practical. Requiring less memory than a conventional image, it is also well optimized for the web and makes it possible to reduce the number of HTTP requests.
Finally, SVG can be animated, and colors can be modified using HTML and CSS.
Unlike PNG and JPG, you cannot use SVG with theĀ imgĀ tag, which means you canāt use the alt attribute.Ā
Instead of the alt attribute, you can use the following tags and attributes:
titleĀ - Use theĀ titleĀ tag to describe the SVG. If it is a shopping cart (in an e-commerce site), you can write: Ā <title>Shopping cart</title>.
desc- In addition to the Ā titleĀ tag, you can use theĀ descĀ tag that will allow you to add an additional description. For example, Ā <desc>a supermarket shopping cart</desc>.
aria-describeby- You can also use theĀ aria-describebyĀ attribute and link it to anĀ idĀ attribute. You can find an example in the implementation below.
role=imgĀ - Finally, you can add Ā role=imgĀ to the SVG allowing allow assistive technologies to indicate that the element is an image.
<svg
aria-describedby="title description"
clip-rule="evenodd"
fill-rule="evenodd"
role="img"
stroke-linecap="round"
stroke-linejoin="round"
stroke-miterlimit="1.5"
viewBox="0 0 100 100"
xmlns="http://www.w3.org/2000/svg"
>
<title id="title">
Coeur
</title>
<desc id="description">
The shape of a red heart
</desc>
<path d="M50 (...) 8.585z" fill="#dc0000" stroke="#dc0000"/>
</svg>Good news! Our project has several images. Some of them are decorative, while others bring meaning to the document. The project also includes a few different image formats (PNG, SVG).
All these cases will allow you to understand how to integrate images. š
Letās start with the Batman logo located in the projectās header. This logo is an SVG and directly integrated into the HTML so that the browser will read it. The image serves as a link, so its function is more important than the appearance, which is what we want to communicate to the user.Ā To do this, weāve added an aria-label=āTonight in Gothamā, since thatās the destination of the link. We then gave the svg role=ānoneā, and aria-hidden=ātrueā so assistive technology users will only hear the link and its label.
The other image in the header is purely decorative, so itās displayed via the CSS:
.header-wrapper {
background-image: url('../images/header-bg.jpg');
height: 300px;
}Therefore, it will not be perceived by assistive technologies.
Now let's look at the content of the project in the Ā mainĀ tag:
You can see that it has several heading levels whose size is expressed in Ā emĀ (we will come back to this in the chapter dedicated to CSS).
Each link is clearly identified by highlighting and bold font.
The second Batman icon image is integrated via SVG in the HTML, just like the header icon, but this time it doesnāt serve a function or provide any information. It is purely decorative, so we want assistive technologies to ignore it. Once again, if this were an Ā imgĀ element, we could give it a blank alt attribute (alt=āā), but because it is an SVG we can accomplish the same thing by giving it role=ānoneā and aria-hidden=ātrueā. This way, assistive technology users will skip the decorative element.Ā
Finally, the footerās navigation links are highlighted, and the social media icons have an opacity that changes if they are in focus or hovered over.
You can also see that each social network has a Ā spanĀ with the name of the social network. This name is displayed only to assistive technologies and hidden via CSS (we will come back to this in the section dedicated to CSS).
Lastly, the Gotham Police logo is a PNG image directly integrated into the HTML. The image is informative, so we want to make sure it includes an alternative text description (alt=ā City of Gotham Police Departmentā).
Set up a suitable heading hierarchy at a very early stage.
Images can be either informative or decorative. Try as much as possible to integrate decorative images using CSS.
Add alternative text descriptions to images using an Ā altĀ text attribute if you are using an Ā imgĀ tag, and an Ā aria-labelĀ or hidden Ā spanĀ element if youāre using Ā svgĀ .Ā
If youāre using an SVG, give the Ā svgĀ element a Ā role=āimgāĀ , add a Ā titleĀ attribute, and point to their content using Ā aria-describedbyĀ or Ā aria-labelledbyĀ . You can also use a Ā descĀ attribute to provide additional information about the image.Ā
If you have a decorative SVG and want assistive technologies to ignore it, you can give it a Ā role=ānoneāĀ and Ā aria-hidden=ātrueāĀ .Ā
You can use SVG and icons as long as you follow the accessibility rules.
Next, letās have a look at tables and how to make them accessible.