HTML Document Examples
Examples of web documents in HTML
HTML document without a web site template
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Example Only</title> </head> <body> <p>Hello World!</p> </body> </html>
The <html> tag should always include an xmlns
attribute, which explicitly specifies the namespace of the HTML elements in the document. See the HTML Namespaces for more information.
Since there is no navigation or other hypertext links in this example, it would essentially be just a single-page web site.
HTML document with a web site template
In this example, navigation links could be included in the site template, so it could be the beginning of a full-fledged web site. The only change to the code from the example above is the addition of the <?xml-stylesheet?> instruction between the <?xml> declaration and the <!DOCTYPE html> declaration.
<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="/site-template.xsl"?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Example Only</title> </head> <body> <p>Hello World!</p> </body> </html>
The style sheet with the site template is in a separate file, located in the document root directory (/
) of the server and named site-template.xsl
in this case. See the Web Site Template Design Pattern for details on how to create the template.