Explain the purpose of DOCTYPE in HTML
Last Updated :
24 Jan, 2024
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:
Share your thoughts in the comments
Please Login to comment...