HTML+CSS Easy t...LOGIN

HTML+CSS Easy to get started with HTML declarations

<!DOCTYPE html>
<html>
<head>
	<title></title>
</head>
<body>

</body>
</html>

All browsers support html declaration

Definition and usage

<!DOCTYPE> The declaration must be the first line of the HTML document, located in < before the ;html> tag. The

<!DOCTYPE> declaration is not an HTML tag; it is an instruction to the web browser as to which version of HTML the page should be written in.

In HTML 4.01, the <!DOCTYPE> declaration references a DTD because HTML 4.01 is based on SGML. A DTD specifies the rules for a markup language so that browsers can render content correctly.

HTML5 is not based on SGML, so there is no need to reference a DTD.

Tip: Always add the <!DOCTYPE> declaration to your HTML document so the browser knows the document type.

Differences between HTML 4.01 and HTML5

There are three types of <!DOCTYPE> declarations in HTML 4.01. There is only one in HTML5:

<!DOCTYPE html>

##Next let’s look at 3 of html4.01 A declaration method:

1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR /html4/strict.dtd">

This DTD contains all HTML elements and attributes, except presentational and deprecated elements (such as font). Framesets are not allowed. Markup must be written in well-formed XML.

2.<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd ">

This DTD contains all HTML elements and attributes, including presentational and deprecated elements (such as font). Framesets are not allowed. Markup must be written in well-formed XML.

3.<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">

This DTD is equivalent to XHTML 1.0 Transitional, but allows frameset content.


At present, most of us use <!DOCTYPE html>

This simplifies the code segment

Next Section

<!DOCTYPE html> <html> <head> <title></title> </head> <body> 欢迎学习html! </body> </html>
submitReset Code
ChapterCourseware