HTML Document Design Pattern Code
HTML Code for a Web Document
<?xml version="1.0" encoding="UTF-8"?> ... see Web Site Template Design Pattern ... <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title><#Your Title#></title> </head> <body> ... see other HTML Design Patterns ... </body> </html>
When creating HTML code, it should be kept in mind that the document may be processed in any one of three different ways depending on the type of browser or parser reading the code:
- as legacy HTML;
- as xHTML, the XML serialization of HTML that is compatible with the 2000-2010 Recommendations from the W3C HTML Working Group and is used by most modern browsers such as Firefox, Opera, Chrome and Safari; or
- as pure XML (for example, by a search engine looking for a Breadcrumb Trail).
The <?xml> declaration is used by xHTML and pure XML parsers to determine what encoding it to be used to read the document. The <!DOCTYPE html> declaration indicates that the document is using HTML 5 or later HTML code. All HTML elements must be allocated in the http://www.w3.org/1999/xhtml namespace is assigned to all HTML elements, which is done automatically in legacy HTML parsers but for all other types of parsers the xmlns attribute on the <html> tag is explicitly required.
The starting <head> tag and ending </head> tag define the head section of the HTML document. The <title> tag is a required element in the head section.
The starting <body> tag and ending </body> tag define the body section of the HTML document. The HTML code for the visible content of the document goes inside that.