You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ad459c0
Browse filesBrowse the repository at this point in the historyBrowse files
<!DOCTYPE html><htmllang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"><head><title>Using CSS to hide a portion of the link text </title><linkrel="stylesheet" type="text/css" href="../../css/sources.css" class="remove"></link></head><body><h1>Using CSS to hide a portion of the link text </h1><sectionclass="meta"><pclass="id">ID: C7</p><pclass="technology">Technology: css</p><pclass="type">Type: Technique</p></section><sectionid="applicability"><h2>When to Use</h2>
<p>The objective of this technique is to supplement the link text by adding additional text that describes the unique function of the link and styling the additional text so that it is not rendered on the screen by user agents that support CSS. When information in the surrounding context is needed to interpret the displayed link text, this technique provides a complete description of the link's input function while permitting the less complete text to be displayed.</p>
5
-
<p>This technique works by creating a CSS selector to target text that is to be hidden. The rule set for the selector places the text to be hidden in a 1-pixel box with overflow hidden, and positions the text outside of the viewport. This ensures the text does not display on screen but remains accessible to assistive technologies such as screen readers and braille displays. Note that the technique does not use visibility:hidden or display:none properties, since these can have the unintentional effect of hiding the text from assistive technology in addition to preventing on-screen display.</p>
20
+
<p>This technique works by creating a CSS selector to target text that is to be hidden. The rule set for the selector places the text to be hidden in a 1-pixel box with overflow hidden. This ensures the text does not display on screen but remains accessible to assistive technologies such as screen readers and braille displays. Note that the technique does not use visibility:hidden or display:none properties, since these can have the unintentional effect of hiding the text from assistive technology in addition to preventing on-screen display.</p>
21
+
<p>This technique is <strong>not</strong> a method for hiding complete links, only a section of text within a link. The <ahref="#resources">resources</a> below include methods for hiding and showing links aimed at screenreader users.</p>
6
22
<divclass="note">
7
23
<p>This technique to hide link text has been advocated by some screen reader users and corporate Web authors. It has proved effective on some Web sites. Other screen reader users and accessibility experts don't recommend this as a general technique because the results can be overly chatty and constrain the ability of the experienced screen reader user to control the verbosity. The working group believes the technique can be useful for Web pages that do not have repetitive content in the hidden text areas.</p>
8
24
<p>This technique can be used in combination with a style switching technique to present a page that is a <a>conforming alternate version</a> for non-conforming content. Refer to <ahref="#C29"></a> and <ahref="https://www.w3.org/WAI/WCAG21/Understanding/conformance#conforming-alt-versions">Understanding Conforming Alternate Versions</a> for more information. </p>
9
25
</div>
10
-
</section><sectionid="examples"><h2>Examples</h2>
26
+
</section>
27
+
<sectionid="examples">
28
+
<h2>Examples</h2>
11
29
<p>The following examples use the CSS selector and rule set below:</p>
12
-
<pre><code>a span {
13
-
height: 1px;
14
-
width: 1px;
15
-
position: absolute;
16
-
overflow: hidden;
17
-
top: -10px;
30
+
<pre><code>.visually-hidden {
31
+
clip-path: inset(100%);
32
+
clip: rect(1px, 1px, 1px, 1px);
33
+
height: 1px;
34
+
overflow: hidden;
35
+
position: absolute;
36
+
white-space: nowrap;
37
+
width: 1px;
18
38
}</code></pre>
19
39
20
40
<sectionclass="example">
21
41
22
42
<p>This example describes a news site that has a series of short synopsis of stories followed by a link that says "full story". Hidden link text describes the purpose of the link.</p>
23
43
24
-
<prexml:space="preserve">
25
-
<?xml version="1.0" encoding="UTF-8"?>
26
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<p>This example describes a resource that has electronic books in different formats. The title of each book is followed by links that say "HTML" and "PDF." Hidden text describes the purpose of each link.</p>
51
+
<p>This example describes a resource that has electronic books in different formats. The title of each book is followed by links that say "HTML" and "PDF." Hidden text describes the purpose of each link.</p>
45
52
46
-
<prexml:space="preserve">
47
-
<?xml version="1.0" encoding="UTF-8"?>
48
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
0 commit comments