Emacs HTML history

By Xah Lee. Date: .

This page is some outdated info on html modes in emacs. There are written mosly from 2006 to 2015, describing emacs html mode during those times.

For latest, see Emacs, Working with HTML

Which HTML Mode To Use?

Pure HTML4 Source File

Alt+x html-mode is the default html mode for emacs 25 (year ~2017) and before.

html-mode is a basic HTML mode. It works with pure HTML4 code only. (no embedded JavaScript or CSS etc.) It supports only HTML4 tags or before. (that's HTML in the 2000s and before) Its parent mode is sgml-mode.

html-mode and sgml-mode both are writen by SGML/XML expert James Clark, in 1990s.

Pure HTML5

If you work with pure HTML5 code (no embedded JavaScript, CSS), try

Emacs: Xah HTML Mode

This is what i use to write blogs and my websites.


Alt+x nxml-mode is a mode for editing valid XML documents, including xhtml.

nxml-mode is bundled with emacs 23.1.1, [see Emacs 23.1 Features (released 2009-07)]

nxml-mode is not the default mode loaded when you open a file ending in “.xml”. (This is fixed in 23.2.x) To set emacs to always use nxml when files ending in “.xml” is opened, see: Emacs: Set Default Major Mode

nxml-mode is written by SGML/XML expert James Clark, in 2000s. It has the feature of real-time XML validation.

Mixed XHTML/XML/CSS/JavaScript/PHP

For HTML mixed with {CSS, JavaScript, PHP, ASP, JSP}, you have the following choices:

If you have a question, put $5 at patreon and message me on xah discord.
Or support me by Buy Xah Emacs Tutorial