diff --git a/packages/govuk-frontend-review/src/views/examples/typography/index.njk b/packages/govuk-frontend-review/src/views/examples/typography/index.njk index 073d1dec23..b7d1b59f46 100644 --- a/packages/govuk-frontend-review/src/views/examples/typography/index.njk +++ b/packages/govuk-frontend-review/src/views/examples/typography/index.njk @@ -536,7 +536,74 @@ +
+

Visually hidden text

+ +

Heading with visually hidden text at the beginning

+ +

Countries starting with A

+ +

Heading with visually hidden text at the end

+ +

Search all content

+ +

Heading that is visually hidden

+ +

Navigation menu

+ +
+ +

Paragraph that contains visually hidden text

+ +

This is a paragraph with some visually hidden text.

+
+ +

Table with visually hidden text

+ + {{ govukTable({ + caption: "2019", + captionClasses: "govuk-!-margin-bottom-4", + head: [ + { + text: "Date", + classes: "govuk-visually-hidden" + }, + { + text: "Day", + classes: "govuk-visually-hidden" + }, + { + text: "Name", + classes: "govuk-visually-hidden" + } + ], + rows: [ + [ + { + text: "19 April" + }, + { + text: "Friday" + }, + { + text: "Good Friday" + } + ], + [ + { + text: "22 April" + }, + { + text: "Monday" + }, + { + text: "Easter Monday" + } + ] + ] + }) }} +
{% endblock %} diff --git a/packages/govuk-frontend/src/govuk/helpers/_visually-hidden.scss b/packages/govuk-frontend/src/govuk/helpers/_visually-hidden.scss index 010362c99e..ffdc7d608c 100644 --- a/packages/govuk-frontend/src/govuk/helpers/_visually-hidden.scss +++ b/packages/govuk-frontend/src/govuk/helpers/_visually-hidden.scss @@ -16,6 +16,18 @@ @mixin govuk-visually-hidden($important: true) { position: absolute if($important, !important, null); + // Absolute positioning has the unintended consequence of removing any + // whitespace surrounding visually hidden text from the accessibility tree. + // Insert a space character before and after visually hidden text to separate + // it from any visible text surrounding it. + &::before { + content: "\00a0"; + } + + &::after { + content: "\00a0"; + } + width: 1px if($important, !important, null); height: 1px if($important, !important, null); // If margin is set to a negative value it can cause text to be announced in