: Learning GNU Emacs, 3rd Edition

8.3.2.3 Inserting an HTML template

8.3.2.3 Inserting an HTML template

HTML helper mode inserts a template for you every time you create a new HTML file.

Type: C-x C-f new.html


HTML helper mode inserts a template with all the basic elements needed for a valid HTML document (Windows).

The template contains all the basic HTML elements. The entire document is surrounded by <html></html> tags. Then the head and the body are separated. Following an <hr> tag that tells the browser to insert a horizontal line, called a horizontal rule, the <address> tag leaves a place for the author to put in his or her email address. In these days of spam, it's unlikely you'll want to do that. (You can leave the <address> tag blank or delete it.)

If you do want to include an email address, enter a line like this in your .emacs file (substituting your own email address, of course):

(setq html-helper-address-string
"<a href="mailto:cdickens@great-beyond.com ">Charles Dickens</a>")

Type: C-x C-f newfile.html


Emacs inserts the HTML template, including the address.

Normally you begin filling out the template by entering title and a level-one header (these are often the same). You can then begin writing paragraphs of text. Before you start typing, press M-Enter. Emacs inserts <p></p> and positions the cursor between them. You can see from the ending paragraph tag that HTML helper mode is working toward XHTML compliance.

Type: M-Enter


Emacs positions the cursor between <p> and </p> so you can start insert text.


: 0.100. /Cache: 0 / 0