Price vocalization

Associated themes :
  • Component

Showing and vocalizing prices

Introduction

Price display can sometimes be problematic for visually impaired people who use a screen reader. This is especially true when you want a particular layout or display promotions (strikethrough price).

Examples with vocalisation problems

Example 1

Using a screen reader, the following example is vocalized as three distinct elements:

  • "from 120"
  • "90 euros"
  • "slash month"

We do not know if the price is 120 € or 90 €, while the real price is 120.90 €.

from 120.90 €/month

Sample code

from
<span class="price">
    120<sup>.90€</sup><sub>/month</sub>
</span>

Example 2

The following example is vocalized:

  • Orange phones
  • from 1 euro asterisk 129 euros
  • asterisk see condition

The user is not informed that the price 129.90 euros is crossed out.

Orange phones

From 1€* 129.90€
*see conditions


Sample code

<div class="example2">
<img src="./images/phone.png" alt="Orange phones">
<p>
    <strong>From </strong><span class="price">1€*</span>
    <s>129,90€</s><br>
    *see conditions
</p>
</div>

Solution to correct vocalization

To fix these problems the easiest way is to ignore the price displayed on the screen and add accessible hiding text containing the price to be vocalized.

To hide an element from speech synthesis, just use the aria-hidden attribute. To add text in accessible hiding (text that is vocalized but not displayed), you only need to use an accessible CSS class (for example, the class visually-hidden if you use the framework boosted).

starting from 120.90 € per month

Vocalized element "from 120 euros 90 per month"


<p class="example" aria-hidden="true">
From
<span class="price">
    120<sup>.90€</sup><sub>/mois</sub>
</span>
<p>
<span class="visually-hidden">from 120.90€ per month</span>
Orange phones From 1 € instead of 129.90 € see conditions

Élément vocalisé :

  • Orange phones
  • from 1 € instead of 129.90 € see conditions

<div class="example2">
<img src="./images/phone.png" alt="Orange phones">
<p aria-hidden="true">
    <strong>From </strong><span class="price">1€*</span>
    <s>129,90€</s><br>
    *see conditions
</p>
<span class="visually-hidden">From 1 € instead of 129.90 € see conditions</span>
</div>

Importance of semantics

The accessible text-based hiding solution work with all the assistive technologies, however it is important to pay particular attention to the HTML tags used.

Adding semantics to the HTML code improves support for assistive technologies now and for the futur. It is possible to display a strikethrough text using a <span> tag and a CSS class, but the use of an appropriate tag <s> or <del> brings meaning to your code. The NVDA screen reader, for example, automatically indicates that text is strikethrough when inserted into a <del>tag. Although support for these tags is not yet complete, it is important to ensure that you choose the appropriate HTML tags based on your needs.