These are the tags required in every Web page. (Note: some are not technically required by the HTML specification, but some browsers will not render correctly without them, so it is always better to leave them in than out - the space you save is not worth the problems you might cause.)
The DOCTYPE element is not really an XHTML element, but rather an identifier for the page. In order to create a valid XHTML document, you need to include the DOCTYPE. The DOCTYPE references a DTD, and there are three DTDs you can use:
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
This is the strict DTD, I wouldn't recommend using this DOCTYPE unless you plan to be very careful with your XHTML
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
This is the transitional DTD; it is the best one to use for most Web sites
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
This is the frameset DTD; if you're going to put up a framed page, you should use this DTD
The first tag that any Web page must have is the <html> tag. It tells the browser that the following text will be marked up in HTML format, and not some other format such as straight text, SGML, or XML. The closing tag </html> is required and is the last tag in your document.
The <head> tag is used to define information for the browser that may or may not be displayed to the user. Tags that belong in the <head> section are <title>, <meta>, <script>, and <style>. The closing tag </head> is required.
The <title> tag belongs in the <head> section of your document. It is the title of your Web page, and is usually displayed by the browser at the top of the browser pane. The closing tag </title> is required.
The <body> tag is where all your HTML information belongs. It defines the primary portion of your Web page. With attributes of the <body> tag, you can define the background color of your Web pages, the text color, the link color, and the active and visited link colors. The closing tag </body> is required.
A sample Web page would look like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title> This is the title of the page. </title> </head> <body> The body text goes here. </body> </html>
Learn more about these and other tags in the HTML Tag Library.