HTML Document
Description
Elements and attributes are used to mark up your content in an HTML document.
An HTML document is a text file with .html file extension.
You can load the file into a browser, either directly from the disk or via a web server. For most the html files you can just drag and drop it to the browser window.
Structure
Two elements provide the outer structure of an HTML document:
- DOCTYPE element
- html element
Example
The following code shows the basic structure of a web document.
<!DOCTYPE HTML>
<html>
<!-- elements go here -->
</html>
The DOCTYPE
element tells the browser it is dealing with an HTML document.
This is expressed through the HTML boolean attribute:
<!DOCTYPE HTML>
The start tag of html follows the DOCTYPE element.
Example 2
HTML documents are text files containing html tags. HTML tags in HTML documents mark up Web pages.
Save the following to a text file named index.htm, and drag and drop it to a browser.
<!DOCTYPE HTML>
<html>
<body>
<h1>My Heading</h1>
<p>My paragraph</p>
</body>
</html> <!-- ww w . j a va 2 s . com-->
The HTML document starts with <!DOCTYPE HTML>. <!DOCTYPE HTML> tells the browser this is a html document.
The content between <html>
and </html>
marks the Web page.
<body>
and </body>
makrs the visible page content.
<h1>
and </h1>
is uses to define a heading.
<p>
and </p>
creates a paragraph.