What Is HTML?: My First Heading My First Paragraph
What Is HTML?: My First Heading My First Paragraph
HTML Tags
HTML markup tags are usually called HTML tags
• HTML tags are keywords surrounded by angle brackets like <html>
• HTML tags normally come in pairs like <b> and </b>
• The first tag in a pair is the start tag, the second tag is the end tag
• Start and end tags are also called opening tags and closing tags
The purpose of a web browser (like Internet Explorer or Firefox) is to read HTML documents and display them
as web pages. The browser does not display the HTML tags, but uses the tags to interpret the content of the
page:
<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: professional web developers often prefer HTML editors like FrontPage
or Dreamweaver, instead of writing plain text.
HTM or HTML Extension?
When you save an HTML file, you can use either the .htm or the .html extension. We use .htm in our examples. It
is a habit from the past, when the software only allowed three letters in file extensions.
With new software it is perfectly safe to use .html.
HTML Attributes
Attributes provide additional information about HTML elements.
HTML Attributes
• HTML elements can have attributes
• Attributes provide additional information about the 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 provided as an attribute:
Example
HTML Headings
Headings are defined with the <h1> to <h6> tags.
<h1> defines the largest heading. <h6> defines the smallest heading.
Headings Are Important
Use HTML headings for headings only. Don't use headings to make text BIG or bold.
Search engines use your headings to index the structure and content of your web pages.
Since users may skim your pages by its headings, it is important to use headings to show the document
structure.
H1 headings should be used as main headings, followed by H2 headings, then less important H3 headings,
and so on.
HTML Comments
<!-- This is a comment -->
HTML Paragraphs
Paragraphs are defined with the <p> tag
Example
<p>This is a paragraph</p>
<p>This is another paragraph</p>
HTML Styles
The style attribute is a new HTML attribute. It introduces CSS to HTML.
Text Alignment
<h1 style="text-align:center">
HTML Images
The Alt Attribute
The alt attribute is used to define an "alternate text" for an image. The value of the alt attribute is an
author-defined text:
The "alt" attribute tells the reader what he or she is missing on a page if the browser can't load images. The
browser will then display the alternate text instead of the image. It is a good practice to include the "alt"
attribute for each image on a page, to improve the display and usefulness of your document for people who
have text-only browsers.
HTML Tables
<table border="1">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>
Headings in a Table
Headings in a table are defined with the <th> tag.
<table border="1">
<tr>
<th>Heading</th>
<th>Another Heading</th>
</tr>
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>
HTML Lists
Unordered Lists
An unordered list is a list of items. The list items are marked with bullets (typically small black circles).
An unordered list starts with the <ul> tag. Each list item starts with the <li> tag.
<ul>
<li>Coffee</li>
<li>Milk</li>
</ul>
Ordered Lists
An ordered list is also a list of items. The list items are marked with numbers.
An ordered list starts with the <ol> tag. Each list item starts with the <li> tag.
<ol>
<li>Coffee</li>
<li>Milk</li>
</ol>
Input
The most used form tag is the <input> tag. The type of input is specified with the type attribute. The most
commonly used input types are explained below.
Text Fields
Text fields are used when you want the user to type letters, numbers, etc. in a form.
<form>
First name:
<input type="text" name="firstname" />
<br />
Last name:
<input type="text" name="lastname" />
</form>
First name:
Last name:
Bottom of Form
Note that the form itself is not visible. Also note that in most browsers, the width of the text field is 20
characters by default.
Radio Buttons
Radio Buttons are used when you want the user to select one of a limited number of choices.
<form>
<input type="radio" name="sex" value="male" /> Male
<br />
<input type="radio" name="sex" value="female" /> Female
</form>
Female
Bottom of Form
Note that only one option can be chosen.
Checkboxes
Checkboxes are used when you want the user to select one or more options of a limited number of choices.
<form>
I have a bike:
<input type="checkbox" name="vehicle" value="Bike" />
<br />
I have a car:
<input type="checkbox" name="vehicle" value="Car" />
<br />
I have an airplane:
<input type="checkbox" name="vehicle" value="Airplane" />
</form>
I have a bike:
I have a car:
I have an airplane:
Bottom of Form
Username:
Bottom of Form
If you type some characters in the text field above, and click the "Submit" button, the browser will send
your input to a page called "html_form_submit.asp". The page will show you the received input.