The DOCTYPE element informs the browser the HTML version number of your document. It is the fist declaration in the HTML 5 document before any other HTML code is written. By using a DOCTYPE, the browser is able to be more precise in the way it interprets and renders your pages. It is highly recommended to use a DOCTYPE at the beginning of all HTML documents.The new HTML 5 DOCTYPE declaration is as follows:
<!DOCTYPE html>
Not only is this syntax valid for the DOCTYPE for HTML 5, but it is also the DOCTYPE for all future versions of HTML. This DOCTYPE is compatible even with the older browsers. The following example shows the use of the new document type specification.
Example:
<!DOCTYPE html>
Basic Tags:
An HTML document is made up of different elements, tags, and attributes, which specify the content and its format. Therefore, HTML is both a structural and presentation markup language. Structural markup specifies the structure of the content, while the representational markup specifies the format.
An HTML page is saved with the html extension. The basic structure of an HTML document mainly consists of seven basic elements. These are as follows:
The HTML element is the root element that marks the beginning of an HTML document. It contains the start and end tag in the form of <HTML> and </HTML> respectively. It isthe largest container element as it contains various other elements.The HEAD element provides information about the Web page such as keywords and language used, which is not displayed on the Web page. Keywords are important terms existing in a Web page used by the search engines to identity the Web page with respect to the search criterion. The TITLE element allows you to specify the tile of the Web page under the <TITLE> and </TITLE> tags. The tile is displayed on the Title bar of the Web browser. The TITLE element is included within the HEAD element.
The meta tag is used for displaying information about the data. In HTML 5, the content meta tag which was used for specifying the charset or character encoding has been simplified. The new <meta> tag is as follows:
<meta charset="utf-8" />UTF-8 is the most commonly used character coding that supports many alphabets. UTF-8 is also being promoted as the new standard.
There are several other attributes associated with the meta tag that can be used to declare general information about the page. This information is not displayed in the browser. Meta tags provide search engines, browsers, and Web services the
information that is required to preview or acquire a summary of the relevant data of your document.
In HTML 5, it is not very important to self-close tags with a slash at the end. Though self-enclosing is recommended for compatibility reasons.
The <link> tag is used to define the association between a document and an external resource. It is used to link stylesheets. Its type attribute is used to specify the type of link such as 'text/css' which points out to a stylesheet.
<link type="text/css" rel="stylesheet" href="fist.css">
The type attibute is not included in HTML5. The reason is that CSS has been declared as the default and standard style for HTML 5. So, the new link is as follows:
<link rel="stylesheet" href="fist.css">
With HTML 5, JavaScript is now the standard and default scripting language. Hence, you can remove the type attribute from the script tags too. The new script tag is as follows:
<script src="fist.js"></script>
The following example shows the use of the script tag.
Example:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>HTML Webinar</title>
<link rel="stylesheet" href="fist.css">
<script src="fist.js"></script>
</head>
</html>
No comments: