HTML Tutorial – Introduction

HTML Document

All HTML documents must start with a document type declaration: <!DOCTYPE html>. The HTML document itself begins with <html> and ends with </html>. The visible part of the HTML document is between <body> and </body>.

Hello World HTML Example


<!DOCTYPE html>
<html>
	<body>
		<h1>Hello World!</h1>
	</body>
</html>

The <!DOCTYPE> Declaration

<!DOCTYPE> is a document type declaration, it tells browsers which version of HTML you are using. It is very important to include this in the HTML document even if you don’t fully understand the need for it. It must only appear once, at the top of the page (before any HTML tags).

HTML5 <!DOCTYPE> Declaration


<!DOCTYPE html>

HTML 4.01 <!DOCTYPE> Declaration


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

XHTML 1.0 <!DOCTYPE> Declaration


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

HTML Tag

HTML tags are the structure of an HTML document, it tells browsers what version of HTML you are using. It is ok if you don’t understand it, but just be sure to include it in every HTML document.

HTML tags are keywords (tag names) surrounded by angle brackets

HTML tags usually come in a pairs, where the closing tag is written like the opening tag but with a slash before the tag name

From the above HTML example, <p> is a HTML tag for paragraph, and its closing tag is </p>. Keep in mind that HTML tags are not being rendered by the browsers, only the content wrapped between the tags are being rendered. Click on the Try It Yourself button above to see for yourself.

<html> Tag

<html> opening tag tells the browsers that everything between it and the closing tag </html> is an HTML document.

<body> Tag

<body> opening tag tells the browsers that everything between it and the closing tag </body> is the content of the HTML document, and browsers will render it in the browser window.