HTML Get Started
An HTML file is simply a text file saved with an .html or .htm extension.
In this tutorial you will learn how easy it is to create an HTML document or a web page. To begin coding HTML you need only two stuff: a simple-text editor and a web browser.
Well, let's get started with creating your first HTML page.
Creating Your First HTML Document
Let's walk through the following steps. At the end of this tutorial, you will have made an HTML file that displays "Hello world" message in your web browser.
Step 1: Creating the HTML file
Open up your computer's plain text editor and create a new file.
Tip: We suggest you to use Notepad (on Windows), TextEdit (on Mac) or some other simple text editor to do this; don't use Word or WordPad! Once you understand the basic principles, you may switch to more advanced tools such as Adobe Dreamweaver.
Step 2: Type some HTML code
Start with an empty window and type the following code:
ExampleTry this code »
<!DOCTYPE html> <html lang="en"> <head> <title>A simple HTML document</title> </head> <body> <p>Hello World!<p> </body> </html>
Step 3: Saving the file
Now save the file on your desktop as "myfirstpage.html ".
Note: It is important that the extension
.html is specified — some text editors, such as Notepad, will automatically save it as
To open the file in a browser. Navigate to your file then double click on it. It will open in your default Web browser. If it does not, open your browser and drag the file to it.
Explanation of code
You might think what that code was all about. Well, let's find out.
- The first line
<!DOCTYPE html>is the document type declaration. It instructs the web browser that this document is an HTML5 document. It is case-insensitive.
<head>element is a container for the tags that provides information about the document, for example,
<title>tag defines the title of the document.
<body>element contains the document's actual content (paragraphs, links, images, tables, and so on) that is rendered in the web browser and displayed to the user.
You will learn about the different HTML elements in detail in the upcoming chapters. For now, just focus on the basic structure of the HTML document.
Note: A DOCTYPE declaration appears at the top of a web page before all other elements; however the doctype declaration itself is not an HTML tag. Every HTML document requires a document type declaration to insure that your pages are displayed correctly.
<body> tags make up the basic skeleton of every web page. Content inside the
</head> are invisible to users with one exception: the text between
</title> tags which appears as the title on a browser tab.
HTML Tags and Elements
HTML is written in the form of HTML elements consisting of markup tags. These markup tags are the fundamental characteristic of HTML. Every markup tag is composed of a keyword, surrounded by angle brackets, such as
<p>, and so on.
HTML tags normally come in pairs like
</html>. The first tag in a pair is often called the opening tag (or start tag), and the second tag is called the closing tag (or end tag).
An opening tag and a closing tag are identical, except a slash (
/) after the opening angle bracket of the closing tag, to tell the browser that the command has been completed.
In between the start and end tags you can place appropriate contents. For example, a paragraph, which is represented by the
p element, would be written as:
ExampleTry this code »
<p>This is a paragraph.</p> <!-- Paragraph with nested element --> <p> This is <b>another</b> paragraph. </p>
You will learn about the various HTML elements in upcoming chapter.