![]() |
In this article, we are going to see the difference between Transitional and Strict doctype. Transitional and Strict both are the kinds of doctypes available in HTML 4. Now, what doctype is? A doctype declaration or document type declaration is information to the browser about what document type should it expect. It is not an HTML tag. All the HTML documents that you code should start with a <!DOCTYPE> declaration. The doctype declaration is written just above the <html> tag, at the very start of each document you write. Significance of Doctype declaration:
HTML5 doctype: This is the most latest version of the document type currently used. It has no disadvantages and is easier to implement and recall. It will correctly validate all HTML 5 features, as well as most of HTML 4/XHTML 1.0 features. The older version, HTML 4.01, was completely based on a Standard Generalized Markup Language(SGML). Hence the DOCTYPE declaration in HTML4 was used to create a reference to a document type definition (DTD). The document type definition (DTD) is responsible for specifying the rules for the SGML so that the browser processes the content correctly. But in the newer HTML version i.e. HTML 5 there is no need for a reference to a document type definition (DTD) as HTML 5 is not based on SGML. Syntax: <!DOCTYPE html> Note: The Doctype is not an HTML tag or element and it is not case-sensitive. Example: Below is a sample HTML program with doctype declaration: HTML
Output : This was about doctype and its syntax. Now let’s talk about Transitional and Strict doctype and their difference. Transitional doctype: The transitional doctype validates the written code against the HTML 4.01 spec. It does allow some presentational markup and deprecated elements (such as <font> elements) but not framesets. It validates loose HTML style markup. Syntax: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> Example: In this example, the entire code will be the same as before we will just use transitional doctype syntax. HTML
Output: Strict doctype: The strict doctype validates the written code against the HTML 4.01 spec. However, it doesn’t allow any deprecated elements or presentational markups such as <font> elements, or framesets to be used. It validates loose HTML style markup, for example, minimized attributes and non-quoted attributes (eg required, rather than required=” required”). Syntax: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> Example: In this example, the entire code is the same as before we just change the doctype declaration code. HTML
Output: Difference between Transitional and Strict doctype:
|
Reffered: https://www.geeksforgeeks.org
Web Technologies |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 10 |