I am about to design a (light) syntax highlighting color theme. Are there any conventions (apart from accessibility) I should take in account.

Comments quite often appear in a bright grey for example. Are there similar patterns for strings, numbers, keywords, …

  • I’ll throw the term “Design Patterns” into the mix... Jun 3, 2019 at 17:44

2 Answers 2


Are there any conventions (apart from accessibility) I should take in account.

  1. Linus Åkesson argues against syntax highlighting in his article: "A case against syntax highlighting", so be certain it can be disabled.

  2. Dark color schemes are popular, be certain to include at least one.

  3. This question is asked and answered on our other site Software Engineering: "Syntax-highlighting color scheme studies", the top answer is provided by user ocodo whom suggests looking at Ethan Schoonover's Solarized project using the principles of: selective contrast, a variety of five color palettes (four base monotones plus one accent color), and symmetric CIELAB lightness differences. The webpage is too lengthy to quote or offer examples (as he provides templates for so many themes and applications) but the latest download is here: .ZIP File. The other answers are worth a look.

  4. Allow people to fully customize the settings, possibly chosen from one of your templates, and save it to a named file.

  5. Format your files the same as another popular file format, that permits you to reuse code and opens a large library of existing themes to your users. For example GitHub uses Oceanic Next as their default theme.

There are simply too many preferences to suggest that one must use a particular color for a particular part of code. It's like a theme for a cellular phone, if there's only a single choice it had better be good or it will be rejected for something else, with so many themes the chance of yours being the most favorite is a difficult challenge.

Visual Studio Code offers a "Syntax Highlight Guide" explaining how to parse code and tokenize using TextMate grammars.

You need to choose colors that don't clash and are distinguished from each other without being too bright or dark compared with the background. A checkbox to enable automatic contrast adjustment based on a sensor (such as laptop camera or cellphone ambient light sensor) would be a great luxury feature.

  • 1
    Very useful. Thank you very much!
    – simo
    Jun 5, 2019 at 7:18

If you are referring to a color theme that can be used within a code complier then I would suggest that you get a custom open source theme that has already been created and start editing from that. This will at lease ensure that you have all the bases covered to a large degree.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.