What Is HTML?: Language
What Is HTML?: Language
HTML Tags
HTML markup tags are usually called HTML tags
<html>
<body>
</body>
</html>
Example Explained
The text between <html> and </html> describes the web
page
The text between <body> and </body> is the visible page
content
The text between <h1> and </h1> is displayed as a heading
The text between <p> and </p> is displayed as a paragraph
Editing HTML
In this tutorial we use a plain text editor (like Notepad) to edit
HTML. We believe this is the best way to learn HTML.
If you want to create a test page on your own computer, just copy
the 3 files below to your desktop.
(Right click on each link, and select "save target as" or "save link
as")
mainpage.htm
page1.htm
page2.htm
After you have copied the files, you can double-click on the file
called "mainpage.htm" and see your first web site in action.
Note: If your test web contains HTML markup tags you have not
learned, don't panic. You will learn all about it in the next chapters.
HTML Headings
HTML headings are defined with the <h1> to <h6> tags.
Example
<h1>This is a heading</h1>
<h2>This is a heading</h2>
<h3>This is a heading</h3>
Try it yourself »
HTML Paragraphs
HTML paragraphs are defined with the <p> tag.
Example
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
Try it yourself »
HTML Links
HTML links are defined with the <a> tag.
Example
<a href="http://www.w3schools.com">This is a
link</a>
Try it yourself »
HTML Images
HTML images are defined with the <img> tag.
Example
HTML Elements
An HTML element is everything from the start tag to the end tag:
* The start tag is often called the opening tag. The end tag is often
called the closing tag.
<body>
<p>This is my first paragraph.</p>
</body>
</html>
<body>
<p>This is my first paragraph.</p>
</body>
<html>
<body>
<p>This is my first paragraph.</p>
</body>
</html>
<p>This is a paragraph
<p>This is a paragraph
The example above will work in most browsers, but don't rely on it.
Forgetting the end tag can produce unexpected results or errors.
Note: Future version of HTML will not allow you to skip end tags.
Adding a slash to the start tag, like <br />, is the proper way of
closing empty elements, accepted by HTML, XHTML and XML.
Even if <br> works in all browsers, writing <br /> instead is more
future proof.
HTML Tip: Use Lowercase Tags
HTML tags are not case sensitive: <P> means the same as <p>.
Many web sites use uppercase HTML tags.
HTML Attributes
HTML elements can have attributes
Attributes provide additional information about an element
Attributes are always specified in the start tag
Attributes come in name/value pairs like: name="value"
Attribute Example
HTML links are defined with the <a> tag. The link address is
specified in the href attribute:
Example
<a href="http://www.w3schools.com">This is a
link</a>
Try it yourself »
Below is a list of some attributes that are standard for most HTML
elements:
HTML Headings
Headings are defined with the <h1> to <h6> tags.
Example
<h1>This is a heading</h1>
<h2>This is a heading</h2>
<h3>This is a heading</h3>
Try it yourself »
HTML Lines
The <hr /> tag creates a horizontal line in an HTML page.
Example
<p>This is a paragraph</p>
<hr />
<p>This is a paragraph</p>
<hr />
<p>This is a paragraph</p>
Try it yourself »
HTML Comments
Comments can be inserted into the HTML code to make it more
readable and understandable. Comments are ignored by the
browser and are not displayed.
Example
Try it yourself »
Headings
How to display headings in an HTML document.
Hidden comments
How to insert comments in the HTML source code.
Horizontal lines
How to insert a horizontal line.
You will learn more about HTML tags and attributes in the next
chapters of this tutorial.
Tag Description
<html> Defines an HTML document
<body> Defines the document's body
<h1> to <h6> Defines HTML headings
<hr /> Defines a horizontal line
<!--> Defines a comment
HTML Paragraphs
Paragraphs are defined with the <p> tag.
Example
<p>This is a paragraph</p>
<p>This is another paragraph</p>
Try it yourself »
Example
<p>This is a paragraph
<p>This is another paragraph
Try it yourself »
The example above will work in most browsers, but don't rely on it.
Forgetting the end tag can produce unexpected results or errors.
Note: Future version of HTML will not allow you to skip end tags.
Example
Try it yourself »
The <br /> element is an empty HTML element. It has no end tag.
With HTML, you cannot change the output by adding extra spaces or
extra lines in your HTML code.
The browser will remove extra spaces and extra lines when the page
is displayed. Any number of lines count as one line, and any number
of spaces count as one space.
Try it yourself
HTML paragraphs
How HTML paragraphs are displayed in a browser.
Line breaks
The use of line breaks in an HTML document.
Poem problems
Some problems with HTML formatting.
More Examples
More paragraphs
The default behaviors of paragraphs.
Tag Description
<p> Defines a paragraph
<br /> Inserts a single line break