Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

💄 Accessible light and dark syntax highlighting themes

License

NotificationsYou must be signed in to change notification settings

ericwbailey/a11y-syntax-highlighting

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Accessible light and dark syntax highlighting themes. SupportsWCAG level AA contrast requirements (good for most websites and apps).

Use

You candownload the files directly, oruse NPM. After that you can either link to the CSS you need directly, or incorporate it into your build sustem.

Otherservices are also supported.

Supported

Libraries

Applications

Misc

  • Carbon (remember to include alt text with your image!)
  • JSON

Themes

a11y-dark

The a11y-dark theme being applied to the HTML of the Prism.js website. Screenshot.

  • Light text on a dark background.
  • Background color of#2B2B2B.
  • WCAG AAA compliant for color contrast.
ColorHexRatioNormal TextLarge Text
Background#2B2B2BN/AN/AN/A
No token#F8F8F213.28:1AAAAAA
Comment#D4D0AB9.04:1AAAAAA
Blue#6BBEFF7.03:1AAAAAA
Cyan#66DDEC8.84:1AAAAAA
Green#ABE3389.28:1AAAAAA
Gray#F8F8F213.28:1AAAAAA
Orange#F5AB327.25:1AAAAAA
Purple#DCC6E08.89:1AAAAAA
Red#FFA07A7.12:1AAAAAA
Yellow#FFD70010.09:1AAAAAA

a11y-light

The a11y-light theme being applied to the HTML of the Prism.js website. Screenshot.

  • Dark text on a light background.
  • Background color of#FEFEFE.
  • WCAG AA compliant for color contrast. WCAG AAA compliance forces the values on a light background to be too similar to each other to be used effectively for syntax highlighting.
ColorHexRatioNormal TextLarge Text
Background#FEFEFEN/AN/AN/A
No token#5454547.5:1AAAAAA
Comment#8022009.69:1AAAAAA
Blue#326BAD5.41:1AAAAA
Cyan#1F7C934.77:1AAAAA
Green#0080005.09:1AAAAA
Gray#6969695.44:1AAAAA
Orange#A85D004.92:1AAAAA
Purple#9400D36.5:1AAAAA
Red#D91E185.01:1AAAA
Yellow#8565145.38:1AAAAA

Forced Colors mode

Both themes have enhanced support forWindows High Contrast Mode when possible:

The a11y-dark theme responding to Windows High Contrast Mode. Screenshot.

FAQ

Can you explain what the filenames mean?

  • a11y-light-on-light-dark-on-dark: This theme contains both light text on a dark background and dark text on a light background visual treatments for code. It is set to show a light background color for code when your operating system's light mode is active, and a dark background color when your operating system's dark mode is active.
  • a11y-dark-on-light-light-on-dark: This theme contains both light text on a dark background and dark text on a light background visual treatments for code. It is set to show a dark background color for code when your operating system's light mode is active, and a light background color when your operating system's dark mode is active.
  • a11y-light: This theme uses a light background color for code for an operating system's light and dark modes.
  • a11y-dark: This theme uses a dark background color for code for an operating system's light and dark modes.
  • Files that end with.min.css: These themes have had their contents compressed to be used in production environments.
  • a11y-dark-legacy.css,a11y-dark-legacy.min.cssa11y-light-legacy.css,a11y-light-legacy.min.css: These files are for Internet Explorer support.

What's the difference between non-legacy and legacy files?

The current version of each syntax file uses features not supported by Internet Explorer. These features include:

Only use the legacy files if you need to support Internet Explorer. Otherwise, syntax highlighting will not work for this browser.

How do I only use light text on a dark background visual treatment, or vice-versa?

Don't usea11y.css ora11y.min.css, as they use theprefers-color-scheme media query. Pick eithera11y-light-on-dark.min.css ora11y-dark-on-light.min.csss depending on what you want.

What happened to the old color names?

Naming things is hard. I had to redo them to have better control between light and dark modes, as well as normalization across different services.

What's the difference between-ms-high-contrast andforced-colors?

forced-colors is a cross-browser standard derived from the propritary-ms-high-contrast declaraction. It has a slightly different syntax, but will also honor legacy-ms-high-contrast code.

-ms-high-contrastwill not honorforced-colors code. The situation is a bit of a mess, honestly. You can read more aboutthe difference between Windows High Contrast Mode and cross-browser Forced Colors mode in this Smashing Magazine article.

I noticed that the colors in the Forced Color Mode screenshot don't all look like they have high enough contrast?

This is by design. These colors are dynamic, and can be adjusted by the person using the theme to make the experience work for their vision needs.

Something strange is going on with inheriteance, can you help?

Check your Cascade Layer order. These themes use thevendor-prism andvendor-highlight namespaces, respectively.

Will you consider supporting this service I use?

Possibly!Raise an issue and let's talk about it.

I don't like these colors, can you change them?

I'm not interested in that, but modifying the CSS Custom Property values is a good starting point. Just make sure tocheck the foreground's color value against the background color value to make sure it passes level AA.

Roadmap

Used by

Run across it being used elsewhere?Let me know!

Thanks

Packages

No packages published

Languages

  • HTML95.8%
  • CSS4.2%

[8]ページ先頭

©2009-2025 Movatter.jp