-
Notifications
You must be signed in to change notification settings - Fork 317
Remove unnecessary code class and pre xml:space attributes from informative docs #4611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Deploy Preview for wcag2 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
</head> | ||
<body> | ||
<h1>Using <code class="language-html">role=heading</code> to identify headings</h1> | ||
<h1>Using <code>role=heading</code> to identify headings</h1> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this may be one of those inline uses that would benefit from highlighting, if that's possible
<p>The purpose of this technique is to provide a way for Assistive Technologies (AT) to identify | ||
a piece of content as a heading. Applying <code class="language-html">role="heading"</code> to an element causes an AT (like a screen reader) to treat it as though it were a heading. The <code class="language-html">role="heading"</code> property must be paired with the <code class="language-html">aria-level</code> property to define the heading level.</p> | ||
<p>When possible, <a href="https://www.w3.org/TR/using-aria/#rule1">use native heading markup</a>. For example, it is preferable to use an <code class="language-html">h1</code> element, rather than using <code class="language-html"><div role="heading" aria-level="1"></code>. Native <abbr title="HyperText Markup Language">HTML</abbr> elements have implicit styling and features that won't necessarily be replicated with ARIA equivalents. For instance, heading elements will have specific styling adjustments made when viewing a page in a browser's Reader Mode. Whereas a <code class="language-html"><div role="heading" aria-level="1"></code> will not be styled as a heading, because the underlying element is a <code class="language-html">div</code>. ARIA only modifies the way an element is exposed to assistive technology, it does nothing to change the implicit style or functionality of the element it is applied to.</p> | ||
a piece of content as a heading. Applying <code>role="heading"</code> to an element causes an AT (like a screen reader) to treat it as though it were a heading. The <code>role="heading"</code> property must be paired with the <code>aria-level</code> property to define the heading level.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the role ones may benefit from highlighting if possible
a piece of content as a heading. Applying <code class="language-html">role="heading"</code> to an element causes an AT (like a screen reader) to treat it as though it were a heading. The <code class="language-html">role="heading"</code> property must be paired with the <code class="language-html">aria-level</code> property to define the heading level.</p> | ||
<p>When possible, <a href="https://www.w3.org/TR/using-aria/#rule1">use native heading markup</a>. For example, it is preferable to use an <code class="language-html">h1</code> element, rather than using <code class="language-html"><div role="heading" aria-level="1"></code>. Native <abbr title="HyperText Markup Language">HTML</abbr> elements have implicit styling and features that won't necessarily be replicated with ARIA equivalents. For instance, heading elements will have specific styling adjustments made when viewing a page in a browser's Reader Mode. Whereas a <code class="language-html"><div role="heading" aria-level="1"></code> will not be styled as a heading, because the underlying element is a <code class="language-html">div</code>. ARIA only modifies the way an element is exposed to assistive technology, it does nothing to change the implicit style or functionality of the element it is applied to.</p> | ||
a piece of content as a heading. Applying <code>role="heading"</code> to an element causes an AT (like a screen reader) to treat it as though it were a heading. The <code>role="heading"</code> property must be paired with the <code>aria-level</code> property to define the heading level.</p> | ||
<p>When possible, <a href="https://www.w3.org/TR/using-aria/#rule1">use native heading markup</a>. For example, it is preferable to use an <code>h1</code> element, rather than using <code><div role="heading" aria-level="1"></code>. Native <abbr title="HyperText Markup Language">HTML</abbr> elements have implicit styling and features that won't necessarily be replicated with ARIA equivalents. For instance, heading elements will have specific styling adjustments made when viewing a page in a browser's Reader Mode. Whereas a <code><div role="heading" aria-level="1"></code> will not be styled as a heading, because the underlying element is a <code>div</code>. ARIA only modifies the way an element is exposed to assistive technology, it does nothing to change the implicit style or functionality of the element it is applied to.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the examples with div role may benefit from highlighting if possible
<h3>Simple headings</h3> | ||
<p>This example demonstrates how to implement headings using <code class="language-html">role="heading"</code> and <code class="language-html">aria-level</code>.</p> | ||
<pre xml:space="preserve"><code class="language-html"><div role="heading" aria-level="2">Global News Items</div> | ||
<p>This example demonstrates how to implement headings using <code>role="heading"</code> and <code>aria-level</code>.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
role ones may benefit from highlighting
|
||
<p>This example demonstrates how to implement a level 7 heading using <code class="language-html">role="heading"</code> and the <code class="language-html">aria-level</code> attribute. Since HTML only supports headings up to level 6, there is no native element to provide these semantics.</p> | ||
<pre xml:space="preserve"><code class="language-html"><h5>Fruit Trees</h5> | ||
<p>This example demonstrates how to implement a level 7 heading using <code>role="heading"</code> and the <code>aria-level</code> attribute. Since HTML only supports headings up to level 6, there is no native element to provide these semantics.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
role one may benefit from highlighting
<h3>Procedure</h3> | ||
<ol> | ||
<li>Examine each element with the attribute <code class="language-html">role="heading"</code>.</li> | ||
<li>Examine each element with the attribute <code>role="heading"</code>.</li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may benefit from highlighting
<p>In some situations, elements can be given the attribute <code>aria-label</code> to provide an accessible name for situations when there is no visible label due to a chosen design approach or layout but the context and visual appearance of the control make its purpose clear.</p> | ||
|
||
<p>In other situations, elements can be given the attribute <code class="language-html">aria-label</code> to provide an accessible name when the native HTML labeling element is not supported by the control - for example, when a <code class="language-html">div</code> set to <code class="language-html">contentEditable</code> is used instead of native form elements such as <code class="language-html">input type="text"</code> or <code class="language-html">textarea</code> in order to provide a richer text editing experience.</p> | ||
<p>In other situations, elements can be given the attribute <code>aria-label</code> to provide an accessible name when the native HTML labeling element is not supported by the control - for example, when a <code>div</code> set to <code>contentEditable</code> is used instead of native form elements such as <code>input type="text"</code> or <code>textarea</code> in order to provide a richer text editing experience.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
input type may benefit from highlighting
|
||
<p>On a page, a link displays a pop-up box (a <code class="language-html">div</code>) with additional information. The 'close' element is implemented as a <code class="language-html">button</code> containing merely the letter 'X'. The property <code class="language-html">aria-label="close"</code> is used to provide an accessible name to the <code class="language-html">button</code>.</p> | ||
<pre xml:space="preserve"><code class="language-html"><div id="box"> | ||
<p>On a page, a link displays a pop-up box (a <code>div</code>) with additional information. The 'close' element is implemented as a <code>button</code> containing merely the letter 'X'. The property <code>aria-label="close"</code> is used to provide an accessible name to the <code>button</code>.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aria-label may benefit from highlighting
<p>The group can be labeled using <code class="language-html">aria-labelledby</code>.</p> | ||
<p>This technique is not meant for wrapping all controls on a form within a single container with <code class="language-html">role="group"</code>.</p> | ||
<p>The objective of this technique is to mark up a set of related controls within a form as a group. Any label associated with the group also serves as a common label or qualifier for individual controls in the group. Assistive technologies can indicate the start and end of the group and the group's label as one navigates into and out of the group. This is a viable alternative for grouping form controls programmatically when the user interface's design makes it difficult to employ the <code>fieldset</code> / <code>legend</code> technique (<a href="../html/H71">H71</a>).</p> | ||
<p>For a group of radio buttons, one should use <code>role="radiogroup"</code> instead of <code>role="group"</code>.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
role ones may benefit from highlighting
<p>The objective of this technique is to mark up a set of related controls within a form as a group. Any label associated with the group also serves as a common label or qualifier for individual controls in the group. Assistive technologies can indicate the start and end of the group and the group's label as one navigates into and out of the group. This is a viable alternative for grouping form controls programmatically when the user interface's design makes it difficult to employ the <code>fieldset</code> / <code>legend</code> technique (<a href="../html/H71">H71</a>).</p> | ||
<p>For a group of radio buttons, one should use <code>role="radiogroup"</code> instead of <code>role="group"</code>.</p> | ||
<p>The group can be labeled using <code>aria-labelledby</code>.</p> | ||
<p>This technique is not meant for wrapping all controls on a form within a single container with <code>role="group"</code>.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
role may benefit from highlighting
<h3>Social Security Number</h3> | ||
<p>Social security number fields which are nine digits long and broken up into three segments can be grouped using <code class="language-html">role="group"</code>.</p> | ||
<pre xml:space="preserve"><code class="language-html"><div role="group" aria-labelledby="ssn1"> | ||
<p>Social security number fields which are nine digits long and broken up into three segments can be grouped using <code>role="group"</code>.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
role may benefit from highlighting
|
||
<p>This example demonstrates use <code class="language-html">role=radiogroup</code>. Note also that the radio buttons are custom controls with <code class="language-html">role=radio</code>. One may optionally employ CSS to place a border around groups of such fields to visually reinforce the group relationship. The CSS properties are available below the form.</p> | ||
<pre xml:space="preserve"><code class="language-html"><h3>Set Alerts for your Account</h3> | ||
<p>This example demonstrates use <code>role=radiogroup</code>. Note also that the radio buttons are custom controls with <code>role=radio</code>. One may optionally employ CSS to place a border around groups of such fields to visually reinforce the group relationship. The CSS properties are available below the form.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
roles may benefit from highlighting
<ol> | ||
<li> Check that the group of logically related input or select elements are contained within an element with <code class="language-html">role=group</code>, or <code class="language-html">role=radiogroup</code> depending on the type of elements the group contains.</li> | ||
<li> Check that this group has an accessible name defined using <code class="language-html">aria-label</code> or <code class="language-html">aria-labelledby</code>.</li> | ||
<li> Check that the group of logically related input or select elements are contained within an element with <code>role=group</code>, or <code>role=radiogroup</code> depending on the type of elements the group contains.</li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
roles may benefit from highlighting
<p>Technologies that support <a href="https://www.w3.org/TR/wai-aria/">Accessible Rich Internet Applications (WAI-ARIA)</a>. </p> | ||
</section><section id="description"><h2>Description</h2> | ||
<p>The purpose of this technique is to alert people that an input error has occurred. Using <code class="language-html">role="alertdialog"</code> creates a notification. This notification should be modal with the following characteristics: | ||
<p>The purpose of this technique is to alert people that an input error has occurred. Using <code>role="alertdialog"</code> creates a notification. This notification should be modal with the following characteristics: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
role may benefit from highlighting
|
||
<p>This example shows how a notification using <code class="language-html">role="alertdialog"</code> can be used to notify someone they have entered invalid information.</p> | ||
<pre xml:space="preserve"><code class="language-html"><div role="alertdialog" aria-labelledby="alertHeading"> | ||
<p>This example shows how a notification using <code>role="alertdialog"</code> can be used to notify someone they have entered invalid information.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
role may benefit from highlighting
<section class="procedure"><h3>Procedure</h3> | ||
<ol> | ||
<li>Determine that an empty error container <code class="language-html">role=alert</code> or <code class="language-html">aria-live=assertive</code> attribute is present in the DOM at page load.</li> | ||
<li>Determine that an empty error container <code>role=alert</code> or <code>aria-live=assertive</code> attribute is present in the DOM at page load.</li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
role and aria-live may benefit from highlighting
<div class="note"> | ||
<p>Use of <code class="language-html">aria-required="true"</code> might be beneficial even when an asterisk or other text symbol is programmatically associated with the field as it may reinforce its <code class="language-html">required</code> property for some assistive technology users.</p> | ||
<p>The fact that the element is required is often visually presented (such as a sign or symbol after the control). Using the <code class="language-html">aria-required</code> property in addition to the visual presentation makes it much easier for user agents to pass on this important information to the user in a user agent-specific manner. Refer to <a href="https://www.w3.org/TR/html-aria/">ARIA in HTML</a> for information on how to provide WAI-ARIA States and Properties with HTML. WAI-ARIA States and Properties are compatible with other languages as well; refer to documentation in those languages. </p> | ||
<p>Use of <code>aria-required="true"</code> might be beneficial even when an asterisk or other text symbol is programmatically associated with the field as it may reinforce its <code>required</code> property for some assistive technology users.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aria-required may benefit from highlighting
|
||
<p>This example uses custom radio buttons with <code class="language-html">role=radio</code>. The CSS properties are available below the form.</p> | ||
<pre xml:space="preserve"><code class="language-html"><form> | ||
<p>This example uses custom radio buttons with <code>role=radio</code>. The CSS properties are available below the form.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
role may benefit from highlighting
|
||
<p>A section on the home page of a news website that contains a poll that changes every week is marked up with <code class="language-html">role="region"</code>. The <code class="language-html">h3</code> above the form is referenced as the region's name using <code class="language-html">aria-labelledby</code>.</p> | ||
<pre xml:space="preserve"><code class="language-html"><div role="region" aria-labelledby="pollhead"> | ||
<p>A section on the home page of a news website that contains a poll that changes every week is marked up with <code>role="region"</code>. The <code>h3</code> above the form is referenced as the region's name using <code>aria-labelledby</code>.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
role may benefit from highlighting
|
||
<p>A user can expand links on a bank website after logging in to see details of term deposit accounts. The details are within a <code class="language-html">span</code> marked up with <code class="language-html">region</code> role. The heading for the region has <code class="language-html">role=heading</code> and is included in the <code class="language-html">aria-labelledby</code> that names the region.</p> | ||
<pre xml:space="preserve"><code class="language-html"><ol> | ||
<p>A user can expand links on a bank website after logging in to see details of term deposit accounts. The details are within a <code>span</code> marked up with <code>region</code> role. The heading for the region has <code>role=heading</code> and is included in the <code>aria-labelledby</code> that names the region.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
role may benefit from highlighting
</section><section id="tests"><h2>Tests</h2> | ||
<section class="procedure"><h3>Procedure</h3> | ||
<p>For each section marked up with <code class="language-html">role="region"</code>:</p> | ||
<p>For each section marked up with <code>role="region"</code>:</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
role may benefit from highlighting
This reverts commit e33ab7c. I indicated in the PR description why I intentionally did not change these.
This reverts commit c1b0821.
This reverts commit 64d99a6.
This reverts commit 603796e.
This reverts commit a31d8fc.
This reverts commit 053cf5d. (Java shouldn't be highlighted because we don't have the syntax installed for it)
This reverts commit 1247a8e. (Java shouldn't be highlighted because we don't have the syntax installed for it)
This reverts commit fe917ab. (I had intentionally removed these, because our highlight.js instance does not have syntax highlighting for the relevant languages)
This reverts commit 6ab4af6. (I had intentionally left these alone, because our highlight.js instance does not have the relevant languages and these techniques are obsolete)
And a few other fixes related to Patrick's edits
out of interest then ... why do we have those naked |
@patrickhlauke I backed out a few of your changes, as some of them contradicted changes I intentionally did not make:
I've looked through some of your comments RE instances where syntax highlighting inline Edit: I am also adding to my to-do list to investigate updating our build of highlight.js to support the languages I mention above that weren't in ours, in which case I can test un-reverting Patrick's Flash/Silverlight/SVR changes, either here or in a separate branch (because I am wary of increasing the scope of this PR). |
I've performed some testing with regard to highlighting inline
As an example of the first bullet, see how every The vast majority of cases of inline I would much rather move ahead with removing classes from inline code tags to clean them up, than add highlight.js processing to them which opens a new can of worms with significant maintenance overhead. (Reminder: the cleanup causes no visual difference with what is currently published.) If you're curious, here's a full list of inline code tags' contents and classes currently found on the |
sure but semantically, those are code blocks, not just "there's some random preformatted content here, dunno". so from a markup point of view, regardless of highlighting or not, i feel like they should be wrapped in |
and sure, the cases where there's methods/attributes with |
From the perspective of functional repercussions of highlight.js, we effectively have 2 options for cases that should not get syntax highlighting:
In the case of #4604, the Sorry for initially yanking them this morning - I was trying to preserve the intended scope of this PR. I might still argue not to bother touching up the fully-obsolete Flash and Silverlight pages, but I will at least do an initial test as it relates to the server-side script techniques. And thanks for poking around on the inline cases - indeed that bit was an experiment for the both of us. |
nah, all good. i think i fell down too much of a rabbithole on saturday and should have checked first before barging in all over your PR :) |
I am planning to re-do this and split it into separate PRs:
The most notable change from this PR to the sequence I just outlined is that I will not be removing classes from |
Discussed on TF call 9/19/2025. |
This removes classes from `code` elements that appear inline within prose. These classes have no effect, and based on local testing, it would be unrealistic to expect highlight.js to provide meaningful syntax highlighting in the vast majority of these cases due to insufficient context. See #4611 (comment) for more details. I have looked over this changeset and also ran screenshot diffs; this causes no visible changes.
This fixes instances where we had specified the wrong `language-...` class in `<pre><code class="...">`, causing highlight.js to highlight code incorrectly. (Originally fixed/reported in #4611, which is being split up and closed)
This removes:
xml:space
attributes frompre
elements, which are no longer needed since the XSLT build system was retiredatt
,el
,obj
,prop
, andpropval
classes fromcode
elements, which don't have any associated styleslanguage-*
classes from inlinecode
elements, which have no effect because highlight.js does not run on themlanguage-*
classes oncode
elements insidepre
, except where highlight.js guesses incorrectly without itThis fixes the following highlight.js instances, which had been manually overridden to the wrong values:
html
incorrectly overridden tocss
in C35 (2x), C36, F2, F100html
incorrectly overridden tojavascript
in SCR14, F3, F37, F50css
incorrectly overridden tohtml
in ARIA24 (2x), G188php-template
incorrectly overridden tohtml
in C29 (2x)php-template
(with HTML also highlighted) incorrectly overridden tophp
(HTML not highlighted) in SVR3, SVR4All other instances are unaffected, as auto-detection matches the removed override.
Note this will also benefit from #4520, which will further prevent slightly-inaccurate-but-mostly-harmless auto-detection of CSS as Less (which is present in the external highlight.js loaded in those files, but not present in our own
highlight.min.js
).How I determined where language-* classes were required
highlightAll
:pre code
through playwright: