!doctype HTML Head Title /title /head Body h1 /h1 P /P /body /HTML
!doctype HTML Head Title /title /head Body h1 /h1 P /P /body /HTML
!doctype HTML Head Title /title /head Body h1 /h1 P /P /body /HTML
What is HTML?
</body>
</html>
Try it Yourself »
Example Explained
The HTML element is everything from the start tag to the end tag:
Web Browsers
A browser does not display the HTML tags, but uses them to determine
how to display the document:
HTML Page Structure
<html>
<head>
<title>Page title</title>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</html>
Note: The content inside the <body> section (the white area above) will
be displayed in a browser. The content inside the <title> element will
be shown in the browser's title bar or in the page's tab.
HTML History
Since the early days of the World Wide Web, there have been many
versions of HTML:
Year Version
Follow the steps below to create your first web page with Notepad or
TextEdit.
Windows 8 or later:
Windows 7 or earlier:
Then under "Open and Save", check the box that says "Display HTML
files as HTML code instead of formatted text".
<!DOCTYPE html>
<html>
<body>
</body>
</html>
Step 3: Save the HTML Page
Save the file on your computer. Select File > Save as in the Notepad
menu.
Open the saved HTML file in your favorite browser (double click on the
file, or right-click - and choose "Open with").
With our free online editor, you can edit the HTML code and view the
result in your browser.
It is the perfect tool when you want to test code fast. It also has color
coding and the ability to save and share code with others:
Example
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>This is a Heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
HTML Basic Examples
❮ Previous Next ❯
Don't worry if we use tags you have not learned about yet.
HTML Documents
Example
<!DOCTYPE html>
<html>
<body>
</body>
</html>
Try it Yourself »
It must only appear once, at the top of the page (before any HTML
tags).
<!DOCTYPE html>
HTML Headings
Example
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
Try it Yourself »
HTML Paragraphs
Example
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
Try it Yourself »
HTML Links
Example
<a href="https://www.w3schools.com">This is a link</a>
Try it Yourself »
Example
<img src="w3schools.jpg" alt="W3Schools.com" width="104" height="1
42">
Try it Yourself »
Have you ever seen a Web page and wondered "Hey! How did they do
that?"
Right-click in an HTML page and select "View Page Source" (in Chrome)
or "View Source" (in Edge), or similar in other browsers. This will open a
window containing the HTML source code of the page.
HTML Elements
❮ Previous Next ❯
An HTML element is defined by a start tag, some content, and an end
tag.
HTML Elements
The HTML element is everything from the start tag to the end tag:
HTML elements can be nested (this means that elements can contain
other elements).
Example
<!DOCTYPE html>
<html>
<body>
</body>
</html>
Try it Yourself »
Example Explained
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
Some HTML elements will display correctly, even if you forget the end
tag:
Example
<html>
<body>
<p>This is a paragraph
<p>This is a paragraph
</body>
</html>
Try it Yourself »
However, never rely on this! Unexpected results and errors may occur
if you forget the end tag!
Example
<p>This is a <br> paragraph with a line break.</p>
Try it Yourself »
Tag Description
For a complete list of all available HTML tags, visit our HTML Tag
Reference.
HTML Attributes
❮ Previous Next ❯
Example
<a href="https://www.w3schools.com">Visit W3Schools</a>
Try it Yourself »
Example
<img src="img_girl.jpg">
Try it Yourself »
Tip: It is almost always best to use relative URLs. They will not break if
you change domain.
Example
<img src="img_girl.jpg" width="500" height="600">
Try it Yourself »
Example
<img src="img_girl.jpg" alt="Girl with a jacket">
Try it Yourself »
Example
See what happens if we try to display an image that does not exist:
<img src="img_typo.jpg" alt="Girl with a jacket">
Try it Yourself »
Example
<p style="color:red;">This is a red paragraph.</p>
Try it Yourself »
<!DOCTYPE html>
<html lang="en">
<body>
...
</body>
</html>
<!DOCTYPE html>
<html lang="en-US">
<body>
...
</body>
</html>
You can see all the language codes in our HTML Language Code
Reference.
The title Attribute
The value of the title attribute will be displayed as a tooltip when you
mouse over the element:
Example
<p title="I'm a tooltip">This is a paragraph.</p>
Try it Yourself »
The title attribute (and all other attributes) can be written with
uppercase or lowercase like title or TITLE.
The HTML standard does not require quotes around attribute values.
Good:
<a href="https://www.w3schools.com/html/">Visit our HTML
tutorial</a>
Bad:
<a href=https://www.w3schools.com/html/>Visit our HTML
tutorial</a>
Sometimes you have to use quotes. This example will not display the
title attribute correctly, because it contains a space:
Example
<p title=About W3Schools>
Try it Yourself »
Double quotes around attribute values are the most common in HTML,
but single quotes can also be used.
Or vice versa:
Try it Yourself »
Chapter Summary
HTML Headings
❮ Previous Next ❯
Example
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Try it Yourself »
HTML Headings
Example
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
Try it Yourself »
Search engines use the headings to index the structure and content of
your web pages.
Users often skim a page by its headings. It is important to use headings
to show the document structure.
Bigger Headings
Each HTML heading has a default size. However, you can specify the
size for any heading with the style attribute, using the CSS font-
size property:
Example
<h1 style="font-size:60px;">Heading 1</h1>
Try it Yourself »
Tag Description
<html> Defines the root of an HTML document
For a complete list of all available HTML tags, visit our HTML Tag
Reference.
HTML Paragraphs
❮ Previous Next ❯
HTML Paragraphs
Example
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
Try it Yourself »
HTML Display
With HTML, you cannot change the display by adding extra spaces or
extra lines in your HTML code.
The browser will automatically remove any extra spaces and lines when
the page is displayed:
Example
<p>
This paragraph
contains a lot of lines
in the source code,
but the browser
ignores it.
</p>
<p>
This paragraph
contains a lot of spaces
in the source code,
but the browser
ignores it.
</p>
Try it Yourself »
HTML Horizontal Rules
Example
<h1>This is heading 1</h1>
<p>This is some text.</p>
<hr>
<h2>This is heading 2</h2>
<p>This is some other text.</p>
<hr>
Try it Yourself »
Use <br> if you want a line break (a new line) without starting a new
paragraph:
Example
<p>This is<br>a paragraph<br>with line breaks.</p>
Try it Yourself »
Example
<p>
My Bonnie lies over the ocean.
Try it Yourself »
Example
<pre>
My Bonnie lies over the ocean.
HTML Styles
❮ Previous Next ❯
Example
I am Red
I am Blue
I am Big
Try it Yourself »
The HTML Style Attribute
<tagname style="property:value;">
Background Color
Example
Set the background color for a page to powderblue:
<body style="background-color:powderblue;">
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
Try it Yourself »
Example
Set background color for two different elements:
<body>
<h1 style="background-color:powderblue;">This is a heading</h1>
<p style="background-color:tomato;">This is a paragraph.</p>
</body>
Try it Yourself »
Text Color
Example
<h1 style="color:blue;">This is a heading</h1>
<p style="color:red;">This is a paragraph.</p>
Try it Yourself »
Fonts
Example
<h1 style="font-family:verdana;">This is a heading</h1>
<p style="font-family:courier;">This is a paragraph.</p>
Try it Yourself »
Text Size
Example
<h1 style="font-size:300%;">This is a heading</h1>
<p style="font-size:160%;">This is a paragraph.</p>
Try it Yourself »
Text Alignment
Example
<h1 style="text-align:center;">Centered Heading</h1>
<p style="text-align:center;">Centered paragraph.</p>
Chapter Summary
HTML Text Formatting
❮ Previous Next ❯
Example
This text is bold
This text is italic
This is subscript and superscript
Try it Yourself »
Example
<b>This text is bold</b>
Try it Yourself »
Example
<strong>This text is important!</strong>
Try it Yourself »
Example
<i>This text is italic</i>
Try it Yourself »
The HTML <em> element defines emphasized text. The content inside is
typically displayed in italic.
Example
<em>This text is emphasized</em>
Try it Yourself »
Example
<small>This is some smaller text.</small>
Try it Yourself »
Example
<p>Do not forget to buy <mark>milk</mark> today.</p>
Try it Yourself »
HTML <del> Element
Example
<p>My favorite color is <del>blue</del> red.</p>
Try it Yourself »
Example
<p>My favorite color is <del>blue</del> <ins>red</ins>.</p>
Try it Yourself »
Example
<p>This is <sub>subscripted</sub> text.</p>
Try it Yourself »
HTML <sup> Element
Example
<p>This is <sup>superscripted</sup> text.</p>
Try it Yourself »
HTML Exercises
Test Yourself With Exercises
Exercise:
<p>
WWF's mission is to stop the degradation of our planet's
natural environment.
</p>
Submit Answer »
Tag Description
Example
Here is a quote from WWF's website:
For nearly 60 years, WWF has been protecting the future of nature. The
world's leading conservation organization, WWF works in 100 countries
and is supported by more than one million members in the United
States and close to five million globally.
Try it Yourself »
Example
<p>Here is a quote from WWF's website:</p>
<blockquote cite="http://www.worldwildlife.org/who/index.html">
For 50 years, WWF has been protecting the future of nature.
The world's leading conservation organization,
WWF works in 100 countries and is supported by
1.2 million members in the United States and
close to 5 million globally.
</blockquote>
Try it Yourself »
Example
<p>WWF's goal is to: <q>Build a future where people live in harmony
with nature.</q></p>
Try it Yourself »
Tip: Use the global title attribute to show the description for the
abbreviation/acronym when you mouse over the element.
Example
<p>The <abbr title="World Health Organization">WHO</abbr> was
founded in 1948.</p>
Try it Yourself »
Example
<address>
Written by John Doe.<br>
Visit us at:<br>
Example.com<br>
Box 564, Disneyland<br>
USA
</address>
Try it Yourself »
Example
<p><cite>The Scream</cite> by Edvard Munch. Painted in 1893.</p>
Try it Yourself »
Example
<bdo dir="rtl">This text will be written from right to left</bdo>
Try it Yourself »
HTML Exercises
Test Yourself With Exercises
Exercise:
Use an HTML element to add quotation marks around the letters "cool".
<p>
I am so cool .
</p>
Submit Answer »
Tag Description
For a complete list of all available HTML tags, visit our HTML Tag
Reference.
HTML Comments
❮ Previous Next ❯
HTML comments are not displayed in the browser, but they can help
document your HTML source code.
You can add comments to your HTML source by using the following
syntax:
Notice that there is an exclamation point (!) in the start tag, but not in
the end tag.
Note: Comments are not displayed by the browser, but they can help
document your HTML source code.
<p>This is a paragraph.</p>
Try it Yourself »
Comments are also great for debugging HTML, because you can
comment out HTML lines of code, one at a time, to search for errors:
Example
<!-- Do not display this image at the moment
<img border="0" src="pic_trulli.jpg" alt="Trulli">
-->
HTML Colors
❮ Previous Next ❯
HTML colors are specified with predefined color names, or with RGB,
HEX, HSL, RGBA, or HSLA values.
Color Names
Tomato
Orange
DodgerBlue
MediumSeaGreen
Gray
SlateBlue
Violet
LightGray
Try it Yourself »
Background Color
Hello World
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam
nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam
erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation
ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.
Example
<h1 style="background-color:DodgerBlue;">Hello World</h1>
<p style="background-color:Tomato;">Lorem ipsum...</p>
Try it Yourself »
Text Color
Hello World
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam
nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam
erat volutpat.
Example
<h1 style="color:Tomato;">Hello World</h1>
<p style="color:DodgerBlue;">Lorem ipsum...</p>
<p style="color:MediumSeaGreen;">Ut wisi enim...</p>
Try it Yourself »
Border Color
Hello World
Hello World
Hello World
Example
<h1 style="border:2px solid Tomato;">Hello World</h1>
<h1 style="border:2px solid DodgerBlue;">Hello World</h1>
<h1 style="border:2px solid Violet;">Hello World</h1>
Try it Yourself »
Color Values
In HTML, colors can also be specified using RGB values, HEX values, HSL
values, RGBA values, and HSLA values.
The following three <div> elements have their background color set
with RGB, HEX, and HSL values:
#ff6347
hsl(9, 100%, 64%)
The following two <div> elements have their background color set with
RGBA and HSLA values, which adds an Alpha channel to the color (here
we have 50% transparency):
Try it Yourself »
HTML Styles - CSS
❮ Previous Next ❯
CSS saves a lot of work. It can control the layout of multiple web pages
all at once.
CSS = Styles and Colors
M a n i p u l a t e T e x t
C o l o r s , B o x e s
What is CSS?
With CSS, you can control the color, font, the size of text, the spacing
between elements, how elements are positioned and laid out, what
background images or background colors are to be used, different
displays for different devices and screen sizes, and much more!
Using CSS
The most common way to add CSS, is to keep the styles in external CSS
files. However, in this tutorial we will use inline and internal styles,
because this is easier to demonstrate, and easier for you to try it
yourself.
Inline CSS
Example
<h1 style="color:blue;">A Blue Heading</h1>
Try it Yourself »
Internal CSS
The following example sets the text color of ALL the <h1> elements (on
that page) to blue, and the text color of ALL the <p> elements to red. In
addition, the page will be displayed with a "powderblue" background
color:
Example
<!DOCTYPE html>
<html>
<head>
<style>
body {background-color: powderblue;}
h1 {color: blue;}
p {color: red;}
</style>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
Try it Yourself »
External CSS
An external style sheet is used to define the style for many HTML pages.
Example
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
Try it Yourself »
The external style sheet can be written in any text editor. The file must
not contain any HTML code, and must be saved with a .css extension.
"styles.css":
body {
background-color: powderblue;
}
h1 {
color: blue;
}
p {
color: red;
}
Tip: With an external style sheet, you can change the look of an entire
web site, by changing one file!
CSS Colors, Fonts and Sizes
Example
Use of CSS color, font-family and font-size properties:
<!DOCTYPE html>
<html>
<head>
<style>
h1 {
color: blue;
font-family: verdana;
font-size: 300%;
}
p {
color: red;
font-family: courier;
font-size: 160%;
}
</style>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
Try it Yourself »
CSS Border
Example
Use of CSS border property:
p {
border: 2px solid powderblue;
}
Try it Yourself »
CSS Padding
Try it Yourself »
CSS Margin
Example
Use of CSS border and margin properties:
p {
border: 2px solid powderblue;
margin: 50px;
}
Try it Yourself »
External style sheets can be referenced with a full URL or with a path
relative to the current web page.
Example
This example uses a full URL to link to a style sheet:
<link rel="stylesheet" href="https://www.w3schools.com/html/styles.c
ss">
Try it Yourself »
Example
This example links to a style sheet located in the html folder on the
current web site:
<link rel="stylesheet" href="/html/styles.css">
Try it Yourself »
Example
This example links to a style sheet located in the same folder as the
current page:
<link rel="stylesheet" href="styles.css">
Try it Yourself »
You can read more about file paths in the chapter HTML File Paths.
Chapter Summary
Links are found in nearly all web pages. Links allow users to click their
way from page to page.
When you move the mouse over a link, the mouse arrow will turn into a
little hand.
Note: A link does not have to be text. A link can be an image or any
other HTML element!
Clicking on the link text, will send the reader to the specified URL
address.
Example
This example shows how to create a link to W3Schools.com:
<a href="https://www.w3schools.com/">Visit W3Schools.com!</a>
Try it Yourself »
Example
Use target="_blank" to open the linked document in a new browser
window or tab:
<a href="https://www.w3schools.com/" target="_blank">Visit
W3Schools!</a>
Try it Yourself »
Both examples above are using an absolute URL (a full web address) in
the href attribute.
A local link (a link to a page within the same website) is specified with
a relative URL (without the "https://www" part):
Example
<h2>Absolute URLs</h2>
<p><a href="https://www.w3.org/">W3C</a></p>
<p><a href="https://www.google.com/">Google</a></p>
<h2>Relative URLs</h2>
<p><a href="html_images.asp">HTML Images</a></p>
<p><a href="/css/default.asp">CSS Tutorial</a></p>
Try it Yourself »
Example
<a href="default.asp">
<img src="smiley.gif" alt="HTML
tutorial" style="width:42px;height:42px;">
</a>
Try it Yourself »
Example
<a href="mailto:[email protected]">Send email</a>
Button as a Link
To use an HTML button as a link, you have to add some JavaScript code.
Link Titles
Example
<a href="https://www.w3schools.com/html/" title="Go to W3Schools
HTML section">Visit our HTML Tutorial</a>
Example
Link to a page located in the html folder on the current web site:
<a href="/html/default.asp">HTML tutorial</a>
Example
Link to a page located in the same folder as the current page:
<a href="default.asp">HTML tutorial</a>
You can read more about file paths in the chapter HTML File Paths.
Chapter Summary
Tag Description
For a complete list of all available HTML tags, visit our HTML Tag
Reference.
HTML Images
Images can improve the design and the appearance of a web page.
Example
<img src="pic_trulli.jpg" alt="Italian Trulli">
Example
<img src="img_girl.jpg" alt="Girl in a jacket">
Example
<img src="img_chania.jpg" alt="Flowers in Chania">
Images are not technically inserted into a web page; images are linked
to web pages. The <img> tag creates a holding space for the referenced
image.
Syntax
<img src="url" alt="alternatetext">
Example
<img src="img_chania.jpg" alt="Flowers in Chania">
Example
<img src="img_chania.jpg" alt="Flowers in Chania">
Example
<img src="wrongname.gif" alt="Flowers in Chania">
Tip: A screen reader is a software program that reads the HTML code,
and allows the user to "listen" to the content. Screen readers are useful
for people who are visually impaired or learning disabled.
Image Size - Width and Height
Example
<img src="img_girl.jpg" alt="Girl in a
jacket" style="width:500px;height:600px;">
Example
<img src="img_girl.jpg" alt="Girl in a
jacket" width="500" height="600">
Example
<!DOCTYPE html>
<html>
<head>
<style>
img {
width: 100%;
}
</style>
</head>
<body>
<img src="html5.gif" alt="HTML5 Icon" width="128" height="128">
<img src="html5.gif" alt="HTML5
Icon" style="width:128px;height:128px;">
</body>
</html>
If you have your images in a sub-folder, you must include the folder
name in the src attribute:
Example
<img src="/images/html5.gif" alt="HTML5
Icon" style="width:128px;height:128px;">
Images on Another Server/Website
Example
<img src="https://www.w3schools.com/images/w3schools_green.jpg"
alt="W3Schools.com">
Animated Images
Example
<img src="programming.gif" alt="Computer
Man" style="width:48px;height:48px;">
Image as a Link
Example
<a href="default.asp">
<img src="smiley.gif" alt="HTML
tutorial" style="width:42px;height:42px;">
</a>
Image Floating
Use the CSS float property to let the image float to the right or to the
left of a text:
Example
<p><img src="smiley.gif" alt="Smiley
face" style="float:right;width:42px;height:42px;">
The image will float to the right of the text.</p>
<p><img src="smiley.gif" alt="Smiley
face" style="float:left;width:42px;height:42px;">
The image will float to the left of the text.</p>
Tip: To learn more about CSS Float, read our CSS Float Tutorial.
Here are the most common image file types, which are supported in all
browsers (Chrome, Edge, Firefox, Safari, Opera):
JPEG Joint Photographic Expert Group .jpg, .jpeg, .jfif, .pjpeg, .pjp
image
Chapter Summary
Note: Loading large images takes time, and can slow down your web
page. Use images carefully.
HTML Tables
HTML tables allow web developers to arrange data into rows and
columns.
Example
Company Contact Country
Each table row is defined with a <tr> tag. Each table header is defined
with a <th> tag. Each table data/cell is defined with a <td> tag.
Example
A simple HTML table:
<table style="width:100%">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</table>
Example
table, th, td {
border: 1px solid black;
}
Remember to define borders for both the table and the table cells.
To let the borders collapse into one border, add the CSS border-
collapse property:
Example
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
Cell padding specifies the space between the cell content and its
borders.
If you do not specify a padding, the table cells will be displayed without
padding.
Example
th, td {
padding: 15px;
}
Example
th {
text-align: left;
}
Example
table {
border-spacing: 5px;
}
Example
<table style="width:100%">
<tr>
<th>Name</th>
<th colspan="2">Telephone</th>
</tr>
<tr>
<td>Bill Gates</td>
<td>55577854</td>
<td>55577855</td>
</tr>
</table>
Example
<table style="width:100%">
<tr>
<th>Name:</th>
<td>Bill Gates</td>
</tr>
<tr>
<th rowspan="2">Telephone:</th>
<td>55577854</td>
</tr>
<tr>
<td>55577855</td>
</tr>
</table>
Example
<table style="width:100%">
<caption>Monthly savings</caption>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td>February</td>
<td>$50</td>
</tr>
</table>
Note: The <caption> tag must be inserted immediately after
the <table> tag.
Example
<table id="t01">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</table>
Chapter Summary
HTML Lists
HTML lists allow web developers to group a set of related items in lists.
Example
An unordered HTML list:
Item
Item
Item
Item
1. First item
2. Second item
3. Third item
4. Fourth item
An unordered list starts with the <ul> tag. Each list item starts with
the <li> tag.
The list items will be marked with bullets (small black circles) by
default:
Example
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
An ordered list starts with the <ol> tag. Each list item starts with
the <li> tag.
Example
<ol>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
Example
<dl>
<dt>Coffee</dt>
<dd>- black hot drink</dd>
<dt>Milk</dt>
<dd>- white cold drink</dd>
</dl>
Tag Description
For a complete list of all available HTML tags, visit our HTML Tag
Reference.
HTML Unordered Lists
An unordered list starts with the <ul> tag. Each list item starts with
the <li> tag.
The list items will be marked with bullets (small black circles) by
default:
Example
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
Value Description
Example - Disc
<ul style="list-style-type:disc;">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
Example - Circle
<ul style="list-style-type:circle;">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
Example - Square
<ul style="list-style-type:square;">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
Example - None
<ul style="list-style-type:none;">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
Nested HTML Lists
Example
<ul>
<li>Coffee</li>
<li>Tea
<ul>
<li>Black tea</li>
<li>Green tea</li>
</ul>
</li>
<li>Milk</li>
</ul>
Note: A list item (<li>) can contain a new list, and other HTML elements,
like images and links, etc.
Example
<!DOCTYPE html>
<html>
<head>
<style>
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333333;
}
li {
float: left;
}
li a {
display: block;
color: white;
text-align: center;
padding: 16px;
text-decoration: none;
}
li a:hover {
background-color: #111111;
}
</style>
</head>
<body>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#news">News</a></li>
<li><a href="#contact">Contact</a></li>
<li><a href="#about">About</a></li>
</ul>
</body>
</html>
Chapter Summary
Tag Description
<ul> Defines an unordered list
HTML Ordered Lists
An ordered list starts with the <ol> tag. Each list item starts with
the <li> tag.
Example
<ol>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
Type Description
type="I" The list items will be numbered with uppercase roman numbers
type="i" The list items will be numbered with lowercase roman numbers
Numbers:
<ol type="1">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
Uppercase Letters:
<ol type="A">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
Lowercase Letters:
<ol type="a">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
By default, an ordered list will start counting from 1. If you want to start
counting from a specified number, you can use the start attribute:
Example
<ol start="50">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
Example
<ol>
<li>Coffee</li>
<li>Tea
<ol>
<li>Black tea</li>
<li>Green tea</li>
</ol>
</li>
<li>Milk</li>
</ol>
Note: A list item (<li>) can contain a new list, and other HTML elements,
like images and links, etc.
Chapter Summary
Tag Description
Block-level Elements
A block level element has a top and a bottom margin, whereas an inline
element does not.
Example
<div>Hello World</div>
<address>
<article>
<aside>
<blockquote>
<canvas>
<dd>
<div>
<dl>
<dt>
<fieldset>
<figcaption>
<figure>
<footer>
<form>
<h1>-<h6>
<header>
<hr>
<li>
<main>
<nav>
<noscript>
<ol>
<p>
<pre>
<section>
<table>
<tfoot>
<ul>
<video>
Inline Elements
Example
<span>Hello World</span>
<a>
<abbr>
<acronym>
<b>
<bdo>
<big>
<br>
<button>
<cite>
<code>
<dfn>
<em>
<i>
<img>
<input>
<kbd>
<label>
<map>
<object>
<output>
<q>
<samp>
<script>
<select>
<small>
<span>
<strong>
<sub>
<sup>
<textarea>
<time>
<tt>
<var>
Note: An inline element cannot contain a block-level element!
Example
<div style="background-color:black;color:white;padding:20px;">
<h2>London</h2>
<p>London is the capital city of England. It is the most populous city in
the United Kingdom, with a metropolitan area of over 13 million
inhabitants.</p>
</div>
Example
<p>My mother has <span style="color:blue;font-
weight:bold">blue</span> eyes and my father
has <span style="color:darkolivegreen;font-weight:bold">dark
green</span> eyes.</p>
Chapter Summary
HTML Tags
Tag Description
Score: 29 of 40
72% Correct:
Question 1:
Question 2:
Google Your answer
Microsoft
Mozilla
The World Wide Web Consortium Correct answer
Question 3:
<h1> Your answer
<head>
<heading>
<h6>
Question 4:
<br> Your answer
<lb>
<break>
Question 5:
Question 6:
<strong> Your answer
<important>
<b>
<i>
Question 7:
<em> Your answer
<italic>
<i>
Question 8:
Question 9:
/ Your answer
*
<
^
Question 10:
How can you open a link in a new tab/browser window?
Question 11:
<table><tr><td> Your answer
<thead><body><tr>
<table><tr><tt>
<table><head><tfoot>
Question 12:
True Your answer
False
Question 13:
<ol> Your answer
<ul>
<dl>
<list>
Question 14:
<ul> Your answer
<dl>
<ol>
<list>
Question 15:
Question 16:
Question 17:
Question 18:
Question 19:
Question 20:
Question 21:
An <iframe> is used to display a web page within a web page.
True Your answer
There is no such thing as an <iframe>
False
Question 22:
True Your answer
False
Question 23:
False Your answer
True
Question 24:
<title> Your answer
<head>
<meta>
Question 25:
Which HTML attribute specifies an alternate text for an image, if the
image cannot be displayed?
alt Your answer
src
longdesc
title
Question 26:
Question 27:
<footer> Your answer
<section>
<bottom>
Question 28:
In HTML, you can embed SVG elements directly into an HTML page.
True Your answer
False
Question 29:
<video> Your answer
<media>
<movie>
Question 30:
<audio> Your answer
<mp3>
<sound>
Question 31:
Question 32:
In HTML, onblur and onfocus are:
Question 33:
CSS Your answer
XML Correct answer
HTML
Question 34:
Question 35:
placeholder Your answer
required Correct answer
formvalidate
validate
Question 36:
controls Your answer
search
slider
range Correct answer
Question 37:
<measure> Your answer
<meter> Correct answer
<range>
<gauge>
Question 38:
<nav> Your answer
<navigate>
<navigation>
Question 39:
Question 40:
<head> Your answer
<top>
<section>
<header> Correct answer