Every XHTML document starts out with this basic structure (right after the doctype):

<html xmlns=”https://www.w3.org/1999/xhtml”>

<head runat=”server”>

<title>Untitled Page</title>

</head>

<body>

</body>

</html>

When you create a new web form in Visual Studio 2010, this is the structure you start with in which the basic parts are:

– XHTML documents start with the <html> tag and end with the </html> tag. This <html> element contains the complete content of the web page.

– Inside the <html> element, the web page is divided into two portions:

– The first portion is the <head> element, which stores some information about the web page. You can use it to store the title of your web page, which will appear in the title bar in your web browser. When you generate a web page in Visual Studio, the <head> section has a runat=”server” attribute. This gives you the ability to manipulate it in your code.

– The second portion is the <body> element, which contains the actual page content that appears in the web browser window.

 

In an ASP.NET web page, there’s at least one more element. Inside the <body> element is a <form> element which is required because it defines a portion of the page that can send information back to the web server. This becomes important when you start adding text boxes, lists, and other controls. As long as they’re in a form, information like the current text in the text box and the current selection in the list will be sent to the web server using a process known as a postback. Most of the time, when you’re working with a page, you should focus on the markup inside the <form> element, because it contains most of the page content.

When you create a new web page in Visual Studio 2010, there’s one more detail—the <div> element inside the <form> element:

 

<html xmlns=”https://www.w3.org/1999/xhtml”>

<head runat=”server”>

<title>My first XTHML page</title>

</head>

<body>

<form ID=”form1″ runat=”server”>

<div>

</div>

</form>

</body>

</html>

 

The <div> element is optional. It is a container or an invisible box that has not built-in appearance or formatting. The element is very useful, because you can:

– Use the tag to group parts of your page with the same font, background color or border.

– Apply style settings to the <div> tag and they’ll cascade down into every tag it contains.

– Create a real box on your page by giving the <div> a border.

– Place text directly inside it, without needing a container element (such as a paragraph). On the other hand, adding text directly inside the <form> element violates the rules of XHTML.

 

Notes: You can find more information about different doctypes from the following articles:

How to set up XHTML 1.0 transitional doctype in ASP.NET 4.0,

How to set up XHTML 1.0 strict doctype in ASP.NET 4.0,

How to set up out-of-date HTML standard doctype in ASP.NET 4.0,

How to set up XHTML 1.1 doctype in ASP.NET 4.0