Horje
Explain the purpose of DOCTYPE in HTML

The DOCTYPE in HTML acts like a blueprint, telling web browsers how to understand and display a webpage. Here’s why it matters:

  • Defines Document Type: It tells browsers the type and version of HTML or XHTML used in the page.
  • Controls Rendering Mode: It helps and influences how browsers render content, ensuring consistency across different browsers.
  • Ensures Compatibility: Promotes adherence to standards for consistent display and compatibility.
  • Aids Validation: Helps validators check code against standards, catching errors for better quality.
  • Future-Proofs Pages: Shows a commitment to using standardized HTML, making pages compatible with future technologies and updates.

In short, DOCTYPE is like a web language tag that ensures your page speaks the same language as browsers, avoiding confusion and ensuring a smooth viewing experience.

Syntax

<!DOCTYPE html>

Example: Example illustrates the use of Doctype.

HTML

<!DOCTYPE html>
<html>
  
<head>
    <title>Doctype Example</title>
</head>
  
<body>
    <h2>Welcome To GFG</h2>
    <p>Default code has been loaded into the Editor.</p>
</body>
  
</html>

Output:

Screenshot-2024-01-23-151107




Reffered: https://www.geeksforgeeks.org


HTML

Related
Difference between GET and POST Methods in HTML Form Difference between GET and POST Methods in HTML Form
How to use the target attribute in the &lt;a&gt; Tag in HTML ? How to use the target attribute in the &lt;a&gt; Tag in HTML ?
How to include External CSS in an HTML Document ? How to include External CSS in an HTML Document ?
What is the purpose of the colspan attribute in a HTML Table ? What is the purpose of the colspan attribute in a HTML Table ?
How do you create a numbered list in HTML 5 ? How do you create a numbered list in HTML 5 ?

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
16