Is there any *good* HTML-mode for emacs?

I had the same problem as you so I decided to write web-mode.

enter image description here

Web-mode.el is a major mode for Emacs that is intended for editing mixed web templaces (HTML with Java/JSP, PHP, CSS, JavaScript).

It doesn't rely on any other mode. It does syntax highlight et indenting according to the code block type. I've written a little HOWTO page on

About

  • web-mode.el is a major-mode for editing web templates (HTML with PHP, Java/JSP, JavaScripts, CSS styles).
  • web-mode.el is will never be a full featured PHP or JS mode. (We don’t encourage multi-lines blocs of code in templates !).

Native Features

  • smart indentation (according to the context : HTML, PHP, Java/JSP, JavaScript or CSS)
  • code navigation : C-c C-n between opening and closing HTML tag or between PHP controls > - if ... else ... endif, for ... endfor
  • HTML tag autoclosing (after
  • syntax highlighting (according to the type of bloc)
  • snippet insertion C-c C-i (auto indented, aware of text selection)
  • auto-inserts (ex. ?> after <?php)

Have you checked out Emacs Wiki html page? nxhtml in particular looks useful.


I've been dissatisified with the available modes, but I have found happiness recently using plain old html-mode augmented with yasnippet and tidy.el. As the other answers have mentioned nxhtml mode is useful if you are writing xhtml.

If you are wanting to get highlighted php and javascript, you might want to look at mmm-mode, which will allow you to run multiple major modes at once. I've never used it, so I don't know who it handles conflicting key bindings, etc... so you'll have to feel your way around there.