Reputation: 1265
Why is <!DOCTYPE html ... >
used in html file?
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
Upvotes: 0
Views: 641
Reputation: 1
is important for building an HTML documents it is not just HTML but it is an instruction to the web browser about what version of HTML the page is written in.
Upvotes: 0
Reputation: 163
It tells the browser that the following code is to be treated as a particular version of html code.
The browser knows then to look for an open HTML tag <html>
and treats everything like html until it reaches the close HTML tag </html>
<!DOCTYPE html>
is all that's needed now.
Upvotes: 2
Reputation:
Show to the browser than the file is a HTML5. Is followed by the lenguage etiquete according to HTML5 good practiques.
<!doctype html>
<html lang="es">
In this case the second line indicates to the browsers than the file is in example, spanish in this case <html lang="es">
Upvotes: 0
Reputation: 1
The <!DOCTYPE html>
declaration is used to inform a website visitor's browser that the document being rendered is an HTML document. While not actually an HTML element itself, every HTML document should being with a DOCTYPE declaration to be compliant with HTML standards.
For HTML5 documents (which nearly all new web documents should be), the DOCTYPE declaration should be:
<!DOCTYPE html>
Upvotes: 0
Reputation: 11
The declaration is not an HTML tag; it is an instruction to the web browser about what version of HTML the page is written in.
In HTML 4.01, the declaration refers to a DTD, because HTML 4.01 was based on SGML. The DTD specifies the rules for the markup language, so that the browsers render the content correctly.
HTML5 is not based on SGML, and therefore does not require a reference to a DTD.
Tip: Always add the declaration to your HTML documents, so that the browser knows what type of document to expect.
Upvotes: 0
Reputation: 544
A doctype defines which version of HTML/XHTML your document uses. You would want to use a doctype so that when you run your code through validators, the validators know which version of HTML/XHTML to check against
Upvotes: 0
Reputation: 2760
The term DOCTYPE
tells the browser which type of HTML is used on a webpage. Here is link of official page which explains your query why and what is
<!DOCTYPE html>
Upvotes: 0
Reputation: 155
The DOCTYPE Declaration (DTD or Document Type Declaration) does a couple of things:
When performing HTML validation testing on a web page it tells the HTML (HyperText Markup Language) validator which version of (X)HTML standard the web page coding is supposed to comply with. When you validate your web page the HTML validator checks the coding against the applicable standard then reports which portions of the coding do not pass HTML validation (are not compliant). It tells the browser how to render the page in standards compliant mode.
For more information refer to this "<!DOCTYPE html>" What does it mean?
Upvotes: 2