Emacs HTML history
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: Xah HTML Mode Tutorial
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
This is what i use to write blogs and my websites.
XML and XHTML
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 (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 Init: 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:
mhtml-mode
bundled in emacs 26 (year 2018). It supports mixed JavaScript, CSS, HTML. (its paren mode ishtml-mode
.).- web-mode http://web-mode.org/ is new, becoming popular around 2012. You might try it. Install it from MELPA. [see Emacs: Install Package with ELPA/MELPA]
- html-helper-mode [http://www.emacswiki.org/cgi-bin/wiki/HtmlHelperMode ]
- nXhtml mode [http://www.emacswiki.org/emacs/NxhtmlMode ]. (nXhtml mode is based on nxml mode, but as of mid 2009, i did not find this package robust.)