Skip to content

Instantly share code, notes, and snippets.

@fstorr
Last active February 9, 2022 22:51
Show Gist options
  • Save fstorr/02da084c0b6da62fa71dae9166918ce1 to your computer and use it in GitHub Desktop.
Save fstorr/02da084c0b6da62fa71dae9166918ce1 to your computer and use it in GitHub Desktop.
highlight headings (HTML and ARIA)
:is(h1,h2,h3,h4,h5,h6)::after,
:is(h1,h2,h3,h4,h5,h6):empty::after,
[role="heading"]::after,
[role="heading"]:is([aria-level="1"],[aria-level="2"],[aria-level="3"],[aria-level="4"],[aria-level="5"],[aria-level="6"])::after{
background: #ff8f51;
border:1px solid #e96115;
border-radius:4px;
color:#000;
display: inline-block;
margin:0 0.2em;
padding:0.02em;
}
:is(h1,h2,h3,h4,h5,h6):empty::after{
content:" empty ";
}
[role="heading"]::after{
content:" h2 (implied) "
}
h1::after, [role="heading"][aria-level="1"]::after{
content:" h1 ";
}
h2::after, [role="heading"][aria-level="2"]::after{
content:" h2 ";
}
h3::after, [role="heading"][aria-level="3"]::after{
content:" h3 ";
}
h4::after, [role="heading"][aria-level="4"]::after{
content:" h4 ";
}
h5::after, [role="heading"][aria-level="5"]::after{
content:" h5 ";
}
h6::after, [role="heading"][aria-level="6"]::after{
content:" h6 ";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment