I often edit articles in web-mode (using PHP). Is there some way of fontifying HTML entities (like –, é, and so on)? I'd like them to be a lighter color so that they're easier to see.

I've tried changing the font-lock settings, but the font-lock code in web-mode.el is confusing to me since it deals with lots of different web-mode flavors. (I only really care about the PHP mode, if that makes things easier.) I've tried the following, to no avail:

(add-to-list 'web-mode-html-font-lock-keywords
             '("\\&#x?[0-9a-fA-F][0-9a-fA-F]*;?" . font-lock-comment-face))

(add-to-list 'web-mode-php-font-lock-keywords
             '("\\&#x?[0-9a-fA-F][0-9a-fA-F]*;?" . font-lock-comment-face))

I have a feeling I'm just not fiddling with the right variable, but I'm not sure how to find out which one is right.


Thanks to @fxbois, it's now super easy: in your config, just do

(setq web-mode-enable-html-entities-fontification t)

and customize the face web-mode-html-entity-face.

1 Answer 1


web-mode does not currently support this feature. Could you post a feature request on the git repo, please? I'll have to modify some of web-mode.el to handle this.


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.