How to write basic HTML5 page

html 5 basic web page

HTML5 page: This is the most basic question any interview can ask you if you are fresher and apply for UI developer job as fresher.

Interview Question:
How to write basic HTML5 page ?
Write sample HTML5 page ?

Answer:
You just copy below HTML5 page code and paste in notepad or notepad++ or any code editor, save the file with .html extension and open the file any web browser to see the output.

<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<!-- You can update below code to show in the web page -->
<h1>This is a Heading</h1>
<p>This is a paragraph.</p>

</body>
</html>

The most important thing you need to remember is <!DOCTYPE html> tag. You may get the questions like:

Interview Question:
why we use DOCTYPE?
if we don’t use DOCTYPE then what happen?
How browser understand this is web page have the HTML code ?

Answer:
<!DOCTYPE> or document type declaration is an instruction which tells the web browser about the markup language in which the current page is written. The <!DOCTYPE> is not an element or tag, it lets the browser know about the version of or standard of HTML or any other markup language that is being used in the document.

Older HTML Documents

In older documents (HTML 4 or XHTML), the declaration is more complicated because the declaration must refer to a DTD (Document Type Definition).

HTML 4.01:

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

Also the <!DOCTYPE> declaration is NOT case sensitive.

<!DOCTYPE html>
<!DocType html>
<!Doctype html>
<!doctype html>

Leave a Reply

Your email address will not be published. Required fields are marked *