This page is a tutorial on working with HTML.
When you open a file ending in “html”, it'll automatically open in
html-mode. This is a basic HTML mode. It is writen by SGML/XML expert James Clark, in 1990s.
If your code is valid XML, you should use
nxml-mode. “nxml-mode” is a mode for editing XML documents, also written by SGML/XML expert James Clark, in 2000s. It has the feature of real-time XML validation.
nxml-mode comes with emacs 23.1.1, but is not the default mode loaded when you open a file ending in “.xml”. (This is fixed in 23.2.x) To load “nxml-mode”, just type 【Alt+x nxml-mode】. To set emacs to always use nxml when files ending in “.xml” is opened, see:
Emacs: How to Associate a File with a Major Mode?, or simply set a alias like this:
(defalias 'xml-mode 'nxml-mode).
〔➤ Emacs: Defining Alias to Increase Productivity〕
The following tips are about using
html-mode. However, this page also gives you several custom commands written in elisp. These elisp commands can be useful regardless which HTML/XML mode you use.
See: Inserting HTML Tags with Emacs.
How to delete a tag?
sgml-delete-tag 【Ctrl+c Ctrl+d】. This will delete both start/end tags where the cursor is on.
WARNING: if your HTML tags do not always have ending tags, it might delete the wrong tag.
How to make the cursor jump to ending tag?
sgml-skip-tag-forward 【Ctrl+c Ctrl+f】.
sgml-skip-tag-backward 【Ctrl+c Ctrl+b】.
How to replace
How to preview in a browser?
browse-url-of-buffer 【Ctrl+c Ctrl+v】.
sgml-tags-invisible 【Ctrl+c Tab ↹】, which will hide all the tags. Call again to show tags.
You can define a command to compact CSS code. See: Emacs Lisp: CSS Compressor.
See: Emacs: Working with CSS Color Values.
How to view the image in a image tag?
Suppose this is your text:
Move your curser on the file path, then call
find-file-at-point) You can also
create a shortcut
such as F8 key for this.
How to view image thumbnails in a directory?
How to open the current directory in OS's desktop?