HTML Tags
HTML Tags
HTML 29.
30.
<data>
<datalist>
60.
61.
<kbd>
<label>
91.
92.
<select>
<small>
ELEMENTS 31. <dd> 62. <legend> 93. <source>
1. <!--> 32. <del> 63. <li> 94. <span>
2. <!DOCTYPE> 33. <details> 64. <link> 95. <strike>
3. <a> 34. <dfn> 65. <main> 96. <strong>
4. <abbr> 35. <dialog> 66. <map> 97. <style>
5. <acronym> 36. <dir> 67. <mark> 98. <sub>
6. <address> 37. <div> 68. <meta> 99. <summary>
7. <applet> 38. <dl> 69. <meter> 100. <sup>
8. <area> 39. <dt> 70. <nav> 101. <svg>
9. <article> 40. <em> 71. <noframes> 102. <table>
10. <aside> 41. <embed> 72. <noscript> 103. <tbody>
11. <audio> 42. <fieldset> 73. <object> 104. <td>
12. <b> 43. <figcaption> 74. <ol> 105. <template>
13. <base> 44. <figure> 75. <optgroup> 106. <textarea>
14. <basefont> 45. <font> 76. <option> 107. <tfoot>
15. <bdi> 46. <footer> 77. <output> 108.
16. <bdo> 47. <form> 78. <p> 109. <th>
17. <big> 48. <frame> 79. <param> 110. <thead>
18. <blockquote> 49. <frameset> 80. <picture> 111. <time>
19. <body> 50. <h1> - <h6> 81. <pre> 112. <title>
20. <br> 51. <head> 82. <progress> 113. <tr>
21. <button> 52. <header> 83. <q> 114. <track>
22. <canvas> 53. <hr> 84. <rp> 115. <tt>
23. <caption> 54. <html> 85. <rt> 116. <u>
24. <center> 55. <i> 86. <ruby> 117. <ul>
25. <cite> 56. <iframe> 87. <s> 118. <var>
26. <code> 57. <img> 88. <samp> 119. <video>
27. <col> 58. <input> 89. <script> 120. <wbr>
28. <colgroup> 59. <ins> 90. <section>
The comment tag is used to insert comments in the source code. The declaration is not an HTML tag. It is an
Comments are not displayed in the browsers. "information" to the browser about what document
type to expect. In HTML 5, the declaration is simple: <!
You can use comments to explain your code, which can help you
when you edit the source code at a later date. This is especially
DOCTYPE html>
useful if you have a lot of code.
Look at our table of all HTML elements, and what Create a link to W3Schools.com:
Doctype each element appears in.
<a href="https://www.w3schools.com">Visit W3Schools.com!
Tips and Notes </a>
Tip: The <!DOCTYPE> declaration is NOT case More "Try it Yourself" examples below.
sensitive.
Definition and Usage
The <a> tag defines a hyperlink, which is used to link from one
page to another.
Attributes
4
Attribute Value Attribute Example
download filename download
href URL href
hreflang language_code hreflang How to open a link in a new browser window:
media media_query media
ping list_of_URLs ping
referrerpolicy no-referrer referrerpolicy
no-referrer-when- <a href="https://www.w3schools.com" target="_blank">Visit
downgrade W3Schools.com!</a>
origin
origin-when-cross-
origin Example
same-origin
strict-origin-when-
cross-origin How to link to an email address:
unsafe-url
rel alternate rel
author
bookmark <a href="mailto:someone@example.com">Send email</a>
external
help
license Example
next
nofollow
noreferrer How to link to a phone number:
noopener
prev
search
tag <a href="tel:+4733378901">+47 333 78 901</a>
target _blank target
_parent
_self Example
_top
type media_type type
Example How to link to another section on the same page:
</body>
</html>
Example
The <abbr title="World Health
Organization">WHO</abbr> was founded in 1948.
The text in the <address> element usually renders in italic, and Most browsers no longer support Java Applets and Plug-
browsers will always add a line break before and after ins.
the <address> element. ActiveX controls are no longer supported in any
browsers.
Default CSS Settings The support for Shockwave Flash has also been turned
off in modern browsers.
Most browsers will display the <address> element with the
following default values:\
Plug-ins
Plug-ins are a computer programs that extend the If you want to embed audio, use the <audio> tag:
standard functionality of the browser.
Example
To embed objects, you can use both the <embed> tag Tip: To embed a picture, it is better to use the <img> tag. To
and the <object> tags: embed a document, it is better to use the <iframe> tag.
Example
HTML <area> Tag
<!DOCTYPE html> The map and area elements
Embed a document with the <embed> element: <html>
<body> Click on the computer, the phone,
or the cup of coffee to go to a new
<h1>The map and area elements</h1>
<embed src="snippet.html"> page and read more about the topic:
<p>Click on the computer, the phone, or
the cup of coffee to go to a new page and
Example read more about the topic:</p>
<map name="workmap">
<area shape="rect"
embed src="pic_trulli.jpg"> coords="34,44,270,350" alt="Computer"
href="computer.htm">
<area shape="rect"
Example coords="290,172,333,250" alt="Phone"
href="phone.htm">
<area shape="circle" coords="337,300,44"
alt="Cup of coffee" href="coffee.htm">
Embed a document with the <object> element: </map> Wikipedia says:
</body> A computer is a
device that can
<object data="snippet.html"></object> </html> be instructed to
carry out
arbitrary
sequences of
arithmetic or
Example logical operations
automatically.
More Example:
Attributes
Attribute Value Description
alt text Specifies an alternate text
for the area. Required if
the href attribute is
present
coords coordinates Specifies the coordinates Example
of the area
download filename Specifies that the target
10
Another image map, with clickable areas: <h2>Google Chrome</h2>
<p>Google Chrome is a web Mozilla Firefox
browser developed by Google,
<img src="planets.gif" width="145" height="126" released in 2008. Chrome is the
world's most popular web browser
alt="Planets"
today!</p>
usemap="#planetmap"> </article> Mozilla Firefox is an open-source web browser
developed by Mozilla. Firefox has been the
second most popular web browser since January,
<map name="planetmap"> <article> 2018.
</map> <article>
<h2>Microsoft Edge</h2>
Default CSS Settings <p>Microsoft Edge is a web browser
developed by Microsoft, released in
Most browsers will display the <area> element with the 2015. Microsoft Edge replaced
following default values: Internet Explorer.</p>
</article>
area {
display: none; </body>
} </html>
Example
Three articles with independent, self-contained content:
<article>
HTML <article> Tag <h2>Google Chrome</h2>
<p>Google Chrome is a web browser developed by Google, released
<!DOCTYPE html> The article element in 2008. Chrome is the world's most popular web browser today!</p>
</article>
<html>
<body> Google Chrome
<article>
<h1>The article element</h1> Google Chrome is a web browser developed by <h2>Mozilla Firefox</h2>
Google, released in 2008. Chrome is the world's
most popular web browser today! <p>Mozilla Firefox is an open-source web browser developed by
<article> Mozilla. Firefox has been the second most popular web browser since
11
January, 2018.</p> <style>
</article> .all-browsers {
margin: 0;
padding: 5px;
<article>
background-color: lightgray;
<h2>Microsoft Edge</h2>
}
<p>Microsoft Edge is a web browser developed by Microsoft,
released in 2015. Microsoft Edge replaced Internet Explorer.</p>
.all-browsers > h1, .browser {
</article>
margin: 10px;
padding: 5px;
More "Try it Yourself" examples below. }
An article should make sense on its own and it should be possible .browser > h2, p {
to distribute it independently from the rest of the site. margin: 4px;
font-size: 90%;
}
</style>
</head>
<body>
Potential sources for the <article> element:
<article class="all-browsers">
Forum post <h1>Most Popular Browsers</h1>
Blog post <article class="browser">
News story <h2>Google Chrome</h2>
<p>Google Chrome is a web browser developed by Google,
Note: The <article> element does not render as anything special released in 2008. Chrome is the world's most popular web browser
in a browser. However, you can use CSS to style today!</p>
the <article> element (see example below). </article>
<article class="browser">
<h2>Mozilla Firefox</h2>
<p>Mozilla Firefox is an open-source web browser developed by
More Examples Mozilla. Firefox has been the second most popular web browser since
Example January, 2018.</p>
</article>
<article class="browser">
<h2>Microsoft Edge</h2>
Use CSS to style the <article> element: <p>Microsoft Edge is a web browser developed by Microsoft,
released in 2015. Microsoft Edge replaced Internet Explorer.</p>
</article>
<html> </article>
<head>
12
international pavilions, award-
</body> winning fireworks and seasonal
</html> special events.</p>
</aside>
article {
display: block;
}
<p>My family and I visited The Epcot center this summer. The
HTML <aside> Tag weather was nice, and Epcot was amazing! I had a great summer
together with my family!</p>
<!DOCTYPE html> The aside element
<html> <aside>
My family and I visited The Epcot
<body> center this summer. The weather was <h4>Epcot Center</h4>
nice, and Epcot was amazing! I had a <p>Epcot is a theme park at Walt Disney World Resort featuring
great summer together with my family! exciting attractions, international pavilions, award-winning fireworks
<h1>The aside element</h1>
and seasonal special events.</p>
Epcot Center
</aside>
<p>My family and I visited The
Epcot is a theme park at Walt Disney
Epcot center this summer. The World Resort featuring exciting More "Try it Yourself" examples below.
weather was nice, and Epcot attractions, international pavilions, award-
winning fireworks and seasonal special
was amazing! I had a great events. Definition and Usage
summer together with my
The <aside> tag defines some content aside from the content it is
family!</p> placed in.
<audio controls>
<aside> <source src="horse.ogg"
type="audio/ogg">
<p>The Epcot center is a theme park at Walt Disney World Resort <source src="horse.mp3"
featuring exciting attractions, international pavilions, award-winning type="audio/mpeg">
fireworks and seasonal special events.</p> Your browser does not support
</aside> the audio element.
</audio>
</body>
<p>My family and I visited The Epcot center this summer. The </html>
weather was nice, and Epcot was amazing! I had a great summer
together with my family!</p>
<p>My family and I visited The Epcot center this summer. The
Example
weather was nice, and Epcot was amazing! I had a great summer
14
Play a sound file: Attribute Value Description
autoplay autoplay Specifies that the
audio will start
<audio controls> playing as soon as
<source src="horse.ogg" type="audio/ogg"> it is ready
<source src="horse.mp3" type="audio/mpeg"> controls controls Specifies that audio
Your browser does not support the audio tag. controls should be
</audio> displayed (such as
a play/pause
button etc)
Definition and Usage
loop loop Specifies that the
audio will start over
The <audio> tag is used to embed sound content in a document, again, every time it
such as music or other audio streams. is finished
muted muted Specifies that the
The <audio> tag contains one or more <source> tags with audio output
different audio sources. The browser will choose the first source it should be muted
supports. preload auto Specifies if and
metadata how the author
The text between the <audio> and </audio> tags will only be none thinks the audio
displayed in browsers that do not support the <audio> element. should be loaded
when the page
There are three supported audio formats in HTML: MP3, WAV, and loads
OGG. src URL Specifies the URL
of the audio file
Audio Format and Browser Support
Default CSS Settings
Browser MP3 WAV OGG
Edge / IE YES YES* YES* None.
Chrome YES YES YES
Firefox YES YES YES HTML <b> Tag
Safari YES YES NO
Opera YES YES YES <!DOCTYPE html> The b element
<html>
<body> This is normal text - and this is bold text.
*From Edge 79
<h1>The b element</h1>
Tips and Notes
The <b> tag specifies bold text without any extra importance.
<head>
Definition and Usage
<base href="https://www.w3schools.com/" - Notice that we have only specified a
target="_blank"> relative address for the image. Since we have The <base> tag specifies the base URL and/or target for all
specified a base URL in the head section, the relative URLs in a document.
</head>
browser will look for the image at
"https://www.w3schools.com/images/stickman.g
<body>
if".
The <base> tag must have either an href or a target attribute
<h1>The base element</h1> present, or both.
HTML base tag - Notice that the link opens in a
16
There can only be one single <base> element in a document, and
it must be inside the <head> element.
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
Attributes
Attribut Value Description </body>
e </html>
href URL Specifies the base URL for all
relative URLs in the page
Example
target _blank, Specifies the default target for all
_parent hyperlinks and forms in the page
_self , _top Specify a default font-family for a page (with CSS):
</body>
Example
</html>
<html> Example
<head>
<style>
body {
color: red; Specify a default font-size for a page (with CSS):
}
</style>
</head>
<body>
17
<html> <li>User <bdi>jdoe</bdi>: 80 points</li>
<head> <li>User <bdi><إيان/bdi>: 90 points</li>
<style> </ul>
body { </body>
font-size: 50px; </html>
}
</style> Example
</head>
<body>
Isolate the usernames from the surrounding text-direction settings:
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
<ul>
</body> <li>User <bdi>hrefs</bdi>: 60 points</li>
</html> <li>User <bdi>jdoe</bdi>: 80 points</li>
<li>User <bdi><إيان/bdi>: 90 points</li>
Tip: In our CSS tutorial you can find more information about CSS </ul>
text color and CSS fonts
Definition and Usage
Most browsers will display the <bdo> element with the following
default values:
HTML <blockquote> Tag
bdo {
unicode-bidi: bidi-override;
}
<html>
Example : A section that is quoted from another source:
<head>
<style>
blockquote {
<blockquote cite="http://www.worldwildlife.org/who/index.html"> margin-left: 0;
For 50 years, WWF has been protecting the future of nature. The }
world's leading conservation organization, WWF works in 100 </style>
countries and is supported by 1.2 million members in the United </head>
States and close to 5 million globally. <body>
</blockquote> <p>Here is a quote from WWF's website:</p>
<blockquote cite="http://www.worldwildlife.org/who/index.html">
Definition and Usage For 50 years, WWF has been protecting the future of nature. The
world's leading conservation organization, WWF works in 100
The <blockquote> tag specifies a section that is quoted from countries and is supported by 1.2 million members in the United
another source. States and close to 5 million globally.
</blockquote>
Browsers usually indent <blockquote> elements (look at example
below to see how to remove the indentation). </body>
</html>
Tips and Notes
Default CSS Settings
20
Most browsers will display the <blockquote> element with the Definition and Usage
following default values:
The <body> tag defines the document's body.
More Examples
<html>
HTML <body> Tag <head>
<style>
body {
Example : A simple HTML document: background-image: url(w3s.png);
}
</style>
</head>
<html> <body>
<head>
<title>Title of the document</title>
</head> <h1>Hello world!</h1>
<p><a href="https://www.w3schools.com">Visit W3Schools.com!
</a></p>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p> </body>
</body>
<html>
<head> Example
<style>
body {
color: green; Set the color of active links in a document (with CSS):
}
</style>
</head>
<body> <html>
<head>
<style>
<h1>Hello world!</h1> a:active {
<p>This is some text.</p> color:#00FF00;
<p><a href="https://www.w3schools.com">Visit W3Schools.com! }
</a></p> </style>
</head>
</body> <body>
</html>
<p><a href="https://www.w3schools.com">W3Schools.com</a></p
>
Example <p><a href="https://www.w3schools.com/html/">HTML
Tutorial</a></p>
<html>
<head>
<style>
a:visited {
color:#FF0000;
}
</style>
</head> HTML <br> Tag
<body>
</body>
</html>
<p>To force<br> line breaks<br> in a text,<br> use the
br<br> element.</p>
Most browsers will display the <body> element with the following
Definition and Usage
default values:
The <br> tag inserts a single line break.
The <br> tag is an empty tag which means that it has no end tag.
Example
Use <br> in a poem: Inside a <button> element you can put text (and tags
like <i>, <b>, <strong>, <br>, <img>, etc.). That is not possible
with a button created with the <input> element!
<p>Be not afraid of greatness.<br> Tip: Always specify the type attribute for a <button> element, to
Some are born great,<br> tell browsers what type of button it is.
some achieve greatness,<br>
and others have greatness thrust upon them.</p>
Tip: You can easily style buttons with CSS! Look at the examples
below or visit our CSS Buttons tutorial.
<p><em>-William Shakespeare</em></p>
Attributes
Default CSS Settings
Attribute Value Attribute
None. autofocus autofocus autofocus
disabled disabled disabled
form form_id form
HTML <button> Tag formaction URL formaction
formenctype application/x-www- formenctype
<!DOCTYPE html> The button Element form-urlencoded
<html> multipart/form-data
<body> Click Me! text/plain
formmethod get Specifies how to send
post the form-data (which
<h1>The button Element</h1> HTTP method to use).
Only for
<button type="button" type="submit"
onclick="alert('Hello formnovalidate formnovalidate Specifies that the
form-data should not
world!')">Click Me!</button> be validated on
submission. Only for
</body> type="submit"
</html> formtarget _blank Specifies where to
_self display the response
_parent after submitting the
_top form. Only for
24
framename type="submit"
name name Specifies a name for
the button Definition and Usage
type button Specifies the type of
reset button The <canvas> tag is used to draw graphics, on the fly, via scripting
submit (usually JavaScript).
value text value
The <canvas> tag is transparent, and is only a container for
graphics, you must use a script to actually draw the graphics.
HTML <canvas> Tag Any text inside the <canvas> element will be displayed in
browsers with JavaScript disabled and in browsers that do not
<!DOCTYPE html> HTML5 Canvas support <canvas>.
<html>
<body> Tips and Notes
<h1>HTML5 Canvas</h1>
Tip: Learn more about the <canvas> element in our HTML Canvas
<canvas id="myCanvas" width="300" Tutorial.
height="150" style="border:1px solid
grey"></canvas>
Tip: For a complete reference of all the properties and methods,
</body>
please visit our HTML Canvas Reference.
</html>
Attributes
Attribut Valu Description
e e
Example height pixels Specifies the height of the
canvas. Default value is 150
width pixels Specifies the width of the canvas
Draw a red rectangle on the fly, and show it inside the <canvas> Default value is 300
element:
More Examples
<canvas id="myCanvas">
Your browser does not support the canvas tag. Example : Another <canvas> example:
</canvas>
<canvas id="myCanvas">
<script> Your browser does not support the canvas tag.
let canvas = document.getElementById("myCanvas"); </canvas>
let ctx = canvas.getContext("2d");
ctx.fillStyle = "#FF0000";
ctx.fillRect(0, 0, 80, 80); <script>
</script> let c = document.getElementById("myCanvas");
let ctx = c.getContext("2d");
25
ctx.fillStyle = "red"; <td>January</td>
ctx.fillRect(20, 20, 75, 50); <td>$100</td>
//Turn transparency on </tr>
ctx.globalAlpha = 0.2; <tr>
ctx.fillStyle = "blue"; <td>February</td>
ctx.fillRect(50, 50, 75, 50); <td>$50</td>
ctx.fillStyle = "green"; </tr>
</table>
ctx.fillRect(80, 80, 75, 50);
</body>
</script>
</html>
Default CSS Settings
canvas { <table>
height: 150px; <caption>Monthly savings</caption>
width: 300px; <tr>
} <th>Month</th>
<th>Savings</th>
HTML <caption> Tag </tr>
<tr>
<!DOCTYPE html> The caption <td>January</td>
<html> <td>$100</td>
<head>
element
</tr>
<style> </table>
table, th, td { Monthly
savings
border: 1px solid black;
Saving More "Try it Yourself" examples below.
} Month
s
</style>
January $100
</head> Definition and Usage
February $50
<body>
The <caption> tag defines a table caption.
<h1>The caption element</h1>
The <caption> tag must be inserted immediately after
<table> the <table> tag.
<caption>Monthly savings</caption>
<tr>
<th>Month</th> Tip: By default, a table caption will be center-aligned above a
<th>Savings</th> table. However, the CSS properties text-align and caption-side can
</tr> be used to align and place the caption.
<tr>
26
<!DOCTYPE html> The cite element
<html>
<body>
HTML <center> Tag <h1>The cite element</h1>
Not Supported in HTML5. <img src="img_the_scream.jpg"
width="220" height="277" alt="The
The <center> tag was used in HTML4 to center-align text. Scream">
<p><cite>The Scream</cite> by
Edward Munch. Painted in 1893.</p>
What to Use Instead?
</body> The Scream by Edward Munch. Painted in
</html> 1893.
Example
Most browsers will display the <cite> element with the following
default values:
HTML <cite> Tag
Example
27
cite { The <code> tag is used to define a piece of computer code. The
font-style: italic; content inside is displayed in the browser's default monospace
} font.
Tag Description
HTML <code> Tag <samp> Defines sample output from a
computer program
<!DOCTYPE html> <kbd> Defines keyboard input
<html> The code element <var> Defines a variable
<body>
<html>
<head>
Example <style>
code {
font-family: Consolas,"courier new";
color: crimson;
Define some text as computer code in a document: background-color: #f1f1f1;
padding: 2px;
font-size: 105%;
<p>The HTML <code>button</code> tag defines a clickable }
button.</p> </style>
</head>
<body>
<p>The CSS <code>background-color</code> property defines
the background color of an element.</p>
<p>The HTML <code>button</code> tag defines a clickable
More "Try it Yourself" examples below. button.</p>
<p>The CSS <code>background-color</code> property defines
the background color of an element.</p>
Definition and Usage
</body>
</html>
28
<td>$53</td>
</tr>
Default CSS Settings </table>
Most browsers will display the <code> element with the following Definition and Usage
default values:
The <col> tag specifies column properties for each column within
a <colgroup> element.
Example
The <col> tag is useful for applying styles to entire columns,
instead of repeating the styles for each cell, for each row.
code {
font-family: monospace;
}
Attributes
<table>
<colgroup> col {
<col span="2" style="background-color:red"> display: table-column;
<col style="background-color:yellow"> }
</colgroup>
<tr>
<th>ISBN</th>
27. HTML <colgroup> Tag
<th>Title</th>
<th>Price</th>
</tr>
<tr>
<td>3476896</td>
<td>My first HTML</td>
29
<!DOCTYPE html> The colgroup element <table>
<html> <colgroup>
<head> <col span="2" style="background-color:red">
<style> ISBN Title Price <col style="background-color:yellow">
table, th, td { </colgroup>
border: 1px solid black; 3476896 My first HTML $53 <tr>
} <th>ISBN</th>
</style>
<th>Title</th>
</head> 5869207 My first CSS $49
<th>Price</th>
<body>
</tr>
<h1>The colgroup element</h1> <tr>
<td>3476896</td>
<table> <td>My first HTML</td>
<colgroup> <td>$53</td>
<col span="2" style="background- </tr>
color:red"> </table>
<col style="background-
color:yellow"> Definition and Usage
</colgroup>
<tr> The <colgroup> tag specifies a group of one or more columns in a
<th>ISBN</th> table for formatting.
<th>Title</th>
<th>Price</th>
The <colgroup> tag is useful for applying styles to entire columns,
</tr>
<tr>
instead of repeating the styles for each cell, for each row.
<td>3476896</td>
<td>My first HTML</td> Note: The <colgroup> tag must be a child of a <table> element,
<td>$53</td> after any <caption> elements and before any <thead>, <tbody>,
</tr> <tfoot>, and <tr> elements.
<tr>
<td>5869207</td> Tip: To define different properties to a column within
<td>My first CSS</td> a <colgroup>, use the <col> tag within the <colgroup> tag.
<td>$49</td>
</tr>
</table> HTML <data> Tag
</body>
</html> <!DOCTYPE html>
<html>
<body>
The data
<h1>The data element</h1> element
Example <p>The following example displays
product names but also associates each The following example displays
name with a product number:</p> product names but also
<ul>
associates each name with a
Set the background color of the three columns with the <colgroup>
<li><data value="21053">Cherry
and <col> tags:
30
Tomato</data></li>
<li><data value="21054">Beef
HTML <datalist> Tag
Tomato</data></li> product number:
<li><data value="21055">Snack
<!DOCTYPE html>
Tomato</data></li>
</ul> Cherry Tomato <html>
<body>
Beef Tomato
</body> Snack Tomato <h1>The datalist element</h1>
</html>
<form action="/action_page.php"
method="get">
<label for="browser">Choose your
browser from the list:</label>
<input list="browsers"
Example name="browser" id="browser">
<datalist id="browsers">
<option value="Edge">
<option value="Firefox">
<option value="Chrome">
The following example displays product names but also associates <option value="Opera">
each name with a product number: <option value="Safari">
</datalist>
<input type="submit">
</form>
<ul> <p><strong>Note:</strong> The
<li><data value="21053">Cherry Tomato</data></li> datalist tag is not supported in Safari
<li><data value="21054">Beef Tomato</data></li> 12.0 (or earlier).</p>
<li><data value="21055">Snack Tomato</data></li> </body>
</ul> </html>
datalist {
display: none;
}
Example
HTML <dd> Tag
A description list, with terms and descriptions:
<dl>
<dt>Coffee</dt>
<dd>Black hot drink</dd>
<dt>Milk</dt>
<dd>White cold drink</dd>
</dl>
32
Definition and Usage Example
A text with a deleted part, and a new, inserted part:
The <dd> tag is used to describe a term/name in a description list.
<p>My favorite color
The <dd> tag is used in conjunction with <dl> (defines a is <del>blue</del> <ins>red</ins>!</p>
description list) and <dt> (defines terms/names).
More "Try it Yourself" examples below.
Inside a <dd> tag you can put paragraphs, line breaks, images,
links, lists, etc.
.
Definition and Usage
Default CSS Settings
The <del> tag defines text that has been deleted from a
Most browsers will display the <dd> element with the following document. Browsers will usually strike a line through deleted text.
default values:
Tips and Notes
Attributes
Attribute Value Description
Example cite URL Specifies a URL to a
document that
dd { explains the reason
display: block; why the text was
margin-left: 40px; deleted/changed
datetime YYYY-MM-DDThh:mm:ssTZD Specifies the date
and time of when
the text was
HTML <del> Tag deleted/changed
<details> </body>
<summary>Epcot Center</summary> </html>
<p>Epcot is a theme park at Walt Disney World Resort
featuring exciting attractions, international pavilions,
award-winning fireworks and seasonal special events.</p> Example
</details>
Mark up a term with <dfn>:
More "Try it Yourself" examples below.
<p><dfn>HTML</dfn> is the standard markup language for
Definition and Usage creating web pages.</p>
The <details> tag specifies additional details that the user can More "Try it Yourself" examples below.
open and close on demand.
Definition and Usage
The <details> tag is often used to create an interactive widget
that the user can open and close. By default, the widget is closed. The <dfn> tag stands for the "definition element", and it specifies
When open, it expands, and displays the content within. a term that is going to be defined within the content.
Any sort of content can be put inside the <details> tag. The nearest parent of the <dfn> tag must also contain the
definition/explanation for the term.
Tip: The <summary> tag is used in conjunction with <details> to
specify a visible heading for the details. The term inside the <dfn> tag can be any of the following:
Attributes
<p><dfn>HTML</dfn> is the standard markup language for <p><dfn id="html-def">HTML</dfn> is the standard markup
creating web pages.</p> language for creating web pages.</p>
<p>This is some text...</p>
<p>This is some text...</p>
<p>Learn <a href="#html-def">HTML</a> now.</p>
</body>
</html>
Example
Attributes
Attribute Value Description Reduce line-height in a list (with CSS):
open open Specifies that the dialog element is
active and that the user can interact
with it <ul style="line-height:80%">
<li>html</li>
HTML <dir> Tag <li>xhtml</li>
<li>css</li>
Not Supported in HTML5. </ul>
The <dir> tag was used in HTML 4 to list directory titles. Tip: In our CSS tutorial you can find more details about styling
lists.
What to Use Instead?
Example
<ul>
<li>html</li>
<li>xhtml</li>
<li>css</li>
</ul>
36
A <div> section in a document that is styled with CSS:
<html>
<head>
<style>
HTML <div> Tag .myDiv {
border: 5px outset red;
<!DOCTYPE html> background-color: lightblue;
<html> text-align: center;
<head> }
<style>
The div element
</style>
.myDiv {
border: 5px outset red; This is a heading in a div
</head>
background-color: lightblue; element <body>
text-align: center;
}
This is some text in a div element.
</style> <div class="myDiv">
</head> <h2>This is a heading in a div element</h2>
<body> This is some text outside the div
element. <p>This is some text in a div element.</p>
<h1>The div element</h1> </div>
<div class="myDiv">
<h2>This is a heading in a div </body>
element</h2> </html>
<p>This is some text in a div
element.</p>
</div> More "Try it Yourself" examples below.
Most browsers will display the <div> element with the following
default values:
Example
37
Example Definition and Usage
HTML <dl> Tag Most browsers will display the <dl> element with the following
default values:
<!DOCTYPE html> The dl, dd, and dt elements
<html>
<body>
These three elements are used Example
<h1>The dl, dd, and dt
elements</h1> to create a description list:
<p>These three elements are used dl {
to create a description list:</p> Coffee display: block;
<dl>
Black hot drink margin-top: 1em;
<dt>Coffee</dt> Milk margin-bottom: 1em;
<dd>Black hot drink</dd>
<dt>Milk</dt>
White cold drink margin-left: 0;
margin-right: 0;
<dd>White cold drink</dd>
</dl> }
</body>
</html> HTML <dt> Tag
Example
Example
A description list, with terms and descriptions:
Default CSS Settings A screen reader will pronounce the words in <em> with an
emphasis, using verbal stress.
Most browsers will display the <dt> element with the following
default values: Default CSS Settings
Most browsers will display the <em> element with the following
Example default values:
dt {
display: block; Example
}
em {
HTML <em> Tag font-style: italic;
}
<!DOCTYPE html>
<html> The em element
<body> HTML <embed> Tag
You have to hurry up! Example
<h1>The em element</h1>
</body>
</html>
<embed type="image/jpg" src="pic_trulli.jpg" width="300" h
eight="200">
Example
Most browsers will display the <embed> element with the following
To display a picture, it is better to use the <img> tag. default values:
embed:focus {
outline: none;
To display HTML, it is better to use the <iframe> tag.
}
Example
40
Group related elements in a form: belongs to
name text Specifies a name
for the fieldset
<form action="/action_page.php"> More Examples
<fieldset>
<legend>Personalia:</legend>
<label for="fname">First name:</label>
Example
<input type="text" id="fname" name="fname"><br><br>
<label for="lname">Last name:</label>
<input type="text" id="lname" name="lname"><br><br>
<label for="email">Email:</label> Use CSS to style <fieldset> and <legend>:
<input type="email" id="email" name="email"><br><br>
<label for="birthday">Birthday:</label>
<input type="date" id="birthday" name="birthday"><br><br> <html>
<input type="submit" value="Submit"> <head>
</fieldset> <style>
</form> fieldset {
background-color: #eeeeee;
More "Try it Yourself" examples below. }
input {
margin: 5px;
}
</style>
Tips and Notes
</head>
<body>
Tip: The <legend> tag is used to define a caption for
the <fieldset> element.
<form action="/action_page.php">
Attributes <fieldset>
<legend>Personalia:</legend>
<label for="fname">First name:</label>
Attribute Value Description <input type="text" id="fname" name="fname"><br><br>
disabled disabled Specifies that a <label for="lname">Last name:</label>
group of related <input type="text" id="lname" name="lname"><br><br>
form elements <label for="email">Email:</label>
should be disabled <input type="email" id="email" name="email"><br><br>
form form_id Specifies which <label for="birthday">Birthday:</label>
form the fieldset <input type="date" id="birthday" name="birthday"><br><br>
41
<input type="submit" value="Submit">
</fieldset>
</form>
</body>
</html>
Definition and Usage
Most browsers will display the <figcaption> element with the More Examples
following default values:
figcaption { Example
display: block;
}
Use CSS to style <figure> and <figcaption>:
HTML <figure> Tag
<html>
Example
<head>
<style>
figure {
Use a <figure> element to mark up a photo in a document, and a border: 1px #cccccc solid;
<figcaption> element to define a caption for the photo: padding: 4px;
margin: auto;
}
<figure>
<img src="pic_trulli.jpg" alt="Trulli" style="width:100% figcaption {
"> background-color: black;
<figcaption>Fig.1 - Trulli, Puglia, Italy.</figcaption> color: white;
</figure> font-style: italic;
padding: 2px;
text-align: center;
More "Try it Yourself" examples below.
}
</style>
</head>
<body>
<figure>
Definition and Usage <img src="pic_trulli.jpg" alt="Trulli" style="width:100%
">
The <figure> tag specifies self-contained content, like <figcaption>Fig.1 - Trulli, Puglia, Italy</figcaption>
illustrations, diagrams, photos, code listings, etc. </figure>
43
<p style="color:red">This is a paragraph.</p>
<p style="color:blue">This is another paragraph.</p>
</body>
</html>
In our CSS tutorial you can find more information about CSS
HTML <font> Tag Text and CSS Fonts.
<footer>
Set the color of text (with CSS): <p>Author: Hege Refsnes</p>
<p><a href="mailto:hege@example.com">hege@example.com</a
></p>
</footer>
44
More "Try it Yourself" examples below.
<footer>
Definition and Usage <p>Author: Hege Refsnes<br>
<a href="mailto:hege@example.com">hege@example.com</a></p>
The <footer> tag defines a footer for a document or section. </footer>
Example
\An HTML form with two input fields and one submit button:
<form action="/action_page.php" method="get"> Use the <iframe> tag to embed another document within the current
<input type="radio" id="html" name="fav_language" value= HTML document:
"HTML">
<label for="html">HTML</label><br>
<input type="radio" id="css" name="fav_language" value=" <iframe src="https://www.w3schools.com"></iframe>
CSS" checked="checked">
<label for="css">CSS</label><br>
<input type="radio" id="javascript" name="fav_language"
value="JavaScript"> <HTML <frameset> Tag
<label for="javascript">JavaScript</label><br><br>
<input type="submit" value="Submit"> Not Supported in HTML5.
</form>
The <frameset> tag was used in HTML 4 to define a frameset.
Most browsers will display the <form> element with the following
default values: Example
Example Use the <iframe> tag to embed another document within the current
HTML document:
form {
display: block;
<iframe src="https://www.w3schools.com"></iframe>
47
ame src="https://www.w3schools.com"></iframe> Set the alignment of headings (with CSS):
Most browsers will display the <h2> element with the following
Example default values:
Example
Set the background color and text color of headings (with CSS):
h2 {
<h1 style="background-color:DodgerBlue;">Hello World</h1> display: block;
<h2 style="color:Tomato;">Hello World</h2> font-size: 1.5em;
margin-top: 0.83em;
margin-bottom: 0.83em;
Example margin-left: 0;
margin-right: 0;
48
font-weight: bold; Most browsers will display the <h5> element with the following
} default values:
Most browsers will display the <h3> element with the following
default values: Example
h5 {
display: block;
font-size: .83em;
margin-top: 1.67em;
Example margin-bottom: 1.67em;
margin-left: 0;
margin-right: 0;
h3 { font-weight: bold;
display: block; }
font-size: 1.17em;
margin-top: 1em; Most browsers will display the <h6> element with the following
margin-bottom: 1em; default values:
margin-left: 0;
margin-right: 0;
font-weight: bold; Example
}
Most browsers will display the <h4> element with the following h6 {
default values: display: block;
font-size: .67em;
margin-top: 2.33em;
Example margin-bottom: 2.33em;
margin-left: 0;
margin-right: 0;
h4 { font-weight: bold;
display: block; }
font-size: 1em;
margin-top: 1.33em;
margin-bottom: 1.33em;
margin-left: 0;
margin-right: 0;
font-weight: bold; HTML <head> Tagg
}
Example
49
A simple HTML document, with a <title> tag inside the head section: The <base> tag (specifies a default URL and target for all links on a
page) goes inside <head>:
<!DOCTYPE html>
<html lang="en"> <html>
<head> <head>
<title>Title of the document</title> <base href="https://www.w3schools.com/" target="_blank">
</head> </head>
<body> <body>
Example
<h1>A heading</h1>
<p>A paragraph.</p>
50
<article>
<header>
</body>
<h1>A heading here</h1>
</html>
<p>Posted by John Doe</p>
<p>Some additional information here</p>
</header>
Example <p>Lorem Ipsum dolor set amet....</p>
</article>
The <link> tag (links to an external style sheet) goes inside <head>:
head {
display: none; Example : A page header:
}
A header for an <article>: Most browsers will display the <header> element with the
following default values:
51
header { More "Try it Yourself" examples below.
display: block;
} Definition and Usage
The <hr> tag defines a thematic break in an HTML page (e.g. a shift of topic).
The <hr> element is most often displayed as a horizontal rule that is used to
separate content (or define a change) in an HTML page.
HTML <hr> Tag
Example:
Example
Use the <hr> tag to define thematic changes in the content:
<p>CSS is a language that describes how HTML elements are to <hr style="height:30px">
be displayed on screen, paper, or in other media. CSS saves a
lot of work, because it can control the layout of multiple
web pages all at once.</p>
<hr>
Try it Yourself »
52
Default CSS Settings The <html> tag is the container for all other HTML elements
(except for the <!DOCTYPE> tag).
Most browsers will display the <hr> element with the following default values:
Note: You should always include the lang attribute inside
Example the <html> tag, to declare the language of the Web page. This is
meant to assist search engines and browsers.
hr {
display: block; Attributes
margin-top: 0.5em;
margin-bottom: 0.5em; Attribute Value Description Attribute
margin-left: auto; xmlns http:// Specifies the XML xmlns
margin-right: auto; www.w3.org/1999/ namespace attribute (If
border-style: inset; xhtml you need your content to
border-width: 1px; conform to XHTML)
}
Default CSS Settings
HTML <html> Tag Most browsers will display the <html> element with the following
default values:
Example html {
display: block;
}
A simple HTML document:
html:focus {
outline: none;
<!DOCTYPE html>
<html lang="en"> HTML <i> Tag
<head>
<title>Title of the document</title>
</head>
<body>
Example
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
Mark up text that is set off from the normal prose in a document:
</body>
</html>
<p><i>Lorem ipsum</i> is the most popular filler text in
Definition and Usage history.</p>
<iframe src="/default.asp" width="100%" height="300" style="b The <img> tag is used to embed an image in an HTML page.
order:1px solid black;">
</iframe>
55
Images are not technically inserted into a web page; images are origin an image
linked to web pages. The <img> tag creates a holding space for origin-when-cross-
the referenced image. origin
unsafe-url
sizes sizes Specifies image sizes
The <img> tag has two required attributes: for different page
layouts
src - Specifies the path to the image src URL Specifies the path to
alt - Specifies an alternate text for the image, if the image the image
for some reason cannot be displayed srcset URL-list Specifies a list of
image files to use in
different situations
Note: Also, always specify the width and height of an image. If
usemap #mapname Specifies an image as
width and height are not specified, the page might flicker while a client-side image
the image loads. map
width pixels Specifies the width of
Tip: To link an image to another document, simply nest an image
the <img> tag inside an <a> tag (see example below).
Example
Attributes
Add top and bottom margins to image (with CSS): <map name="workmap">
<area shape="rect" coords="34,44,270,350" alt="Computer"
href="computer.htm">
<img src="smiley.gif" alt="Smiley <area shape="rect" coords="290,172,333,250" alt="Phone"
face" width="42" height="42" style="vertical- href="phone.htm">
align:middle;margin:50px 0px"> <area shape="circle" coords="337,300,44" alt="Cup of
coffee" href="coffee.htm">
</map>
Example
How to insert images from another folder or from another web site: Default CSS Settings
Most browsers will display the <img> element with the following
default values:
<img src="/images/stickman.gif" alt="Stickman" width="24" hei
ght="39">
<img src="https://www.w3schools.com/images/lamp.jpg" alt="Lam
p" width="32" height="32">
Example
57
Example <input type="datetime-local">
<input type="email">
<input type="file">
img { <input type="hidden">
display: inline-block; <input type="image">
} <input type="month">
<input type="number">
<input type="password">
<input type="radio">
HTML <input> Tag <input type="range">
<input type="reset">
<input type="search">
<input type="submit">
Example
<input type="tel">
<input type="text"> (default value)
<input type="time">
An HTML form with three input fields; two text fields and one submit <input type="url">
button: <input type="week">
The <input> tag specifies an input field where the user can enter
data.
Example
Define some text as keyboard input in a document:
<p>My favorite color Tip: This tag is not deprecated. However, it is possible to achieve
is <del>blue</del> <ins>red</ins>!</p> richer effect by using CSS (see example below).
Tag Description
61
<code> Defines a piece of computer Example
code
<samp> Defines sample output from a
computer program kbd {
<var> Defines a variable font-family: monospace;
<pre> Defines preformatted text }
Example
HTML <label> Tag
Example
<html>
<head>
<style> Three radio buttons with labels:
kbd {
border-radius: 2px;
padding: 2px;
border: 1px solid black; <form action="/action_page.php">
} <input type="radio" id="html" name="fav_language" value="HT
</style> ML">
</head> <label for="html">HTML</label><br>
<body> <input type="radio" id="css" name="fav_language" value="CSS
">
<label for="css">CSS</label><br>
<p>Press <kbd>Ctrl</kbd> + <kbd>C</kbd> to copy text <input type="radio" id="javascript" name="fav_language" val
(Windows).</p> ue="JavaScript">
<p>Press <kbd>Cmd</kbd> + <kbd>C</kbd> to copy text (Mac <label for="javascript">JavaScript</label><br><br>
OS).</p> <input type="submit" value="Submit">
</form>
</body>
</html> Definition and Usage
<input type="checkbox">
<input type="color">
Default CSS Settings <input type="date">
<input type="datetime-local">
Most browsers will display the <kbd> element with the following <input type="email">
default values: <input type="file">
<input type="month">
62
<input type="number">
<input type="password">
Default CSS Settings
<input type="radio">
<input type="range">
Most browsers will display the <label> element with the following default
<input type="search">
values:
<input type="tel">
<input type="text">
<input type="time">
Example
<input type="url">
<input type="week">
<meter>
label {
<progress>
cursor: default;
<select>
}
<textarea>
Tip: The for attribute of <label> must be equal to the id attribute of the related <form action="/action_page.php">
element to bind them together. A label can also be bound to an element by placing <fieldset>
the element inside the <label> element. <legend>Personalia:</legend>
<label for="fname">First name:</label>
<input type="text" id="fname" name="fname"><br><br>
<label for="lname">Last name:</label>
Attributes <input type="text" id="lname" name="lname"><br><br>
<label for="email">Email:</label>
Attribut Value Description <input type="email" id="email" name="email"><br><br>
e <label for="birthday">Birthday:</label>
<input type="date" id="birthday" name="birthday"><br><
for element_ Specifies the id of the form
br>
id element the label should be bound
<input type="submit" value="Submit">
to
</fieldset>
form form_id Specifies which form the label </form>
belongs to
Definition and Usage
63
The <legend> tag defines a caption for the <fieldset> element. Attributes
<ol>
Use of the value attribute in an ordered list:
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol> <ol>
<li value="100">Coffee</li>
<li>Tea</li>
<ul>
<li>Milk</li>
<li>Coffee</li>
<li>Water</li>
<li>Tea</li>
<li>Juice</li>
<li>Milk</li>
<li>Beer</li>
</ul>
</ol>
In <ul> and <menu>, the list items will usually be displayed with
bullet points. <ol>
<li>Coffee</li>
In <ol>, the list items will usually be displayed with numbers or <li style="list-style-type:lower-alpha">Tea</li>
letters. <li>Milk</li>
</ol>
Tip: Use CSS to style lists.
<ul>
<li>Coffee</li>
64
<li style="list-style-type:square">Tea</li> <li>Milk</li>
<li>Milk</li> </ul>
</ul>
Default CSS Settings
Example Most browsers will display the <li> element with the following
default values:
li {
Create a list inside a list (a nested list):
display: list-item;
}
<ul>
<li>Coffee</li> HTML <link> Tag
<li>Tea
<ul>
<li>Black tea</li>
<li>Green tea</li>
</ul>
</li> Example
<li>Milk</li>
</ul>
Link to an external style sheet:
Example
<head>
<link rel="stylesheet" href="styles.css">
Create a more complex nested list: </head>
.browser {
<article>
background: white;
<h2>Microsoft Edge</h2>
}
<p>Microsoft Edge is a web browser developed by
Microsoft, released in 2015. Microsoft Edge replaced Internet
.browser > h2, p {
Explorer.</p>
margin: 4px;
</article>
font-size: 90%;
</main>
}
</style>
Definition and Usage
</head>
<body>
The <main> tag specifies the main content of a document.
The content inside the <main> element should be unique to the <main>
document. It should not contain any content that is repeated <h1>Most Popular Browsers</h1>
across documents such as sidebars, navigation links, copyright <p>Chrome, Firefox, and Edge are the most used browsers
information, site logos, and search forms. today.</p>
<article class="browser">
Note: There must not be more than one <main> element in a <h2>Google Chrome</h2>
document. The <main> element must NOT be a descendant of an <p>Google Chrome is a web browser developed by Google,
<article>, <aside>, <footer>, <header>, or <nav> element. released in 2008. Chrome is the world's most popular web
browser today!</p>
More Examples </article>
<article class="browser">
<h2>Mozilla Firefox</h2>
<p>Mozilla Firefox is an open-source web browser
Example
developed by Mozilla. Firefox has been the second most
popular web browser since January, 2018.</p>
</article>
Use CSS to style the <main> element: <article class="browser">
<h2>Microsoft Edge</h2>
<p>Microsoft Edge is a web browser developed by
Microsoft, released in 2015. Microsoft Edge replaced
<html>
Internet Explorer.</p>
<head>
</article>
<style>
</main>
main {
margin: 0;
padding: 5px; </body>
background-color: lightgray; </html>
}
The <map> tag is used to define an image map. An image map is an image with
clickable areas.
HTML <mark> Tag
The required name attribute of the <map> element is associated with the <img>'s
usemap attribute and creates a relationship between the image and the map.
Example
The <map> element contains a number of <area> elements, that defines the
clickable areas in the image map.
Most browsers will display the <mark> element with the following default values:
68
Example Metadata will not be displayed on the page, but is machine
parsable.
More Examples
<meta> tags always go inside the <head> element, and are Define a description of your web page:
typically used to specify character set, page description,
keywords, author of the document, and viewport settings.
69
Define the author of a page: Tip: If you are browsing this page with a phone or a tablet, you can
The viewport is the user's visible area of a web page. It varies with
the device - it will be smaller on a mobile phone than on a
computer screen.
You should include the following <meta> element in all your web
pages:
This gives the browser instructions on how to control the page's With the viewport meta tag
dimensions and scaling.
Note: The <meter> tag should not be used to indicate progress Example
(as in a progress bar). For progress bars, use the <progress> tag.
Tip: Always add the <label> tag for best accessibility practices! A set of navigation links:
71
<nav> <iframe src="https://www.w3schools.com"></iframe>
<a href="/html/">HTML</a> |
<a href="/css/">CSS</a> | HTML <noscript> Tag
<a href="/js/">JavaScript</a> |
<a href="/python/">Python</a>
</nav>
Example
Use the <iframe> tag to embed another document within the current
HTML document:
An embedded image:
72
<object data="pic_trulli.jpg" width="300" height="200"></ The <object> tag was originally designed to embed browser Plug-
object> ins.
Example
Warning !
An embedded video:
Most browsers no longer support Java Applets and Plug-ins.
Attributes
To embed a picture, it is better to use the <img> tag.
Attribute Value Description
data URL Specifies the URL
of the resource to
To embed HTML, it is better to use the <iframe> tag. be used by the
object
form form_id Specifies which
To embed video or audio, it is better to use the <video> and <audio> tags. form the object
belongs to
height pixels Specifies the
height of the object
Plug-ins name name Specifies a name
for the object
73
type media_type Specifies the </ol>
media type of data
specified in the
<ol start="50">
data attribute
<li>Coffee</li>
typemustmatch true/false Specifies whether <li>Tea</li>
the type attribute <li>Milk</li>
and the actual </ol>
content of the
resource must
Definition and Usage
match to be
displayed
The <ol> tag defines an ordered list. An ordered list can be numerical or
usemap #mapname Specifies the name
alphabetical.
of a client-side
image map to be
used with the The <li> tag is used to define each list item.
object
width pixels Specifies the width Tip: Use CSS to style lists.
of the object
Tip: For unordered list, use the <ul> tag.
Default CSS Settings
Most browsers will display the <object> element with the following default
values: Attributes
Two different ordered lists (the first list starts at 1, and the second starts at 50):
Example
<ol>
<li>Coffee</li>
Set different list types (with CSS):
<li>Tea</li>
<li>Milk</li>
74
<ol style="list-style-type:upper-roman"> Reduce and expand line-height in lists (with CSS):
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
<ol style="line-height:80%">
</ol>
<li>Coffee</li>
<li>Tea</li>
<ol style="list-style-type:lower-alpha"> <li>Milk</li>
<li>Coffee</li> </ol>
<li>Tea</li>
<li>Milk</li>
<ol style="line-height:180%">
</ol>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
Example </ol>
<style>
ol.a {list-style-type: armenian;}
ol.b {list-style-type: cjk-ideographic;}
ol.c {list-style-type: decimal;}
ol.d {list-style-type: decimal-leading-zero;}
ol.e {list-style-type: georgian;} Example
ol.f {list-style-type: hebrew;}
ol.g {list-style-type: hiragana;}
ol.h {list-style-type: hiragana-iroha;} Nest an unordered list inside an ordered list:
ol.i {list-style-type: katakana;}
ol.j {list-style-type: katakana-iroha;}
ol.k {list-style-type: lower-alpha;}
<ol>
ol.l {list-style-type: lower-greek;}
<li>Coffee</li>
ol.m {list-style-type: lower-latin;}
<li>Tea
ol.n {list-style-type: lower-roman;}
<ul>
ol.o {list-style-type: upper-alpha;}
<li>Black tea</li>
ol.p {list-style-type: upper-latin;}
<li>Green tea</li>
ol.q {list-style-type: upper-roman;}
</ul>
ol.r {list-style-type: none;}
</li>
ol.s {list-style-type: inherit;}
<li>Milk</li>
</style>
</ol>
Example If you have a long list of options, groups of related options are easier to handle for a
user.
ol {
display: block;
list-style-type: decimal;
margin-top: 1em;
margin-bottom: 1em;
margin-left: 0;
margin-right: 0; Attributes
padding-left: 40px;
}
Attribute Value Description
disabled disabled Specifies that an
option-group
should be disabled
HTML <optgroup> Tag label text Specifies a label
for an option-group
Default CSS Settings
None.
Example
Attributes
Example
Attribute Value Description
disabled disabled Specifies that an
option should be Use of <option> in <optgroup> elements:
disabled
label text Specifies a shorter
label for an option <label for="cars">Choose a car:</label>
selected selected Specifies that an <select id="cars">
option should be <optgroup label="Swedish Cars">
pre-selected when <option value="volvo">Volvo</option>
the page loads <option value="saab">Saab</option>
value text Specifies the value </optgroup>
to be sent to a <optgroup label="German Cars">
server <option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</optgroup>
</select>
None.
Example output {
display: inline;
}
Perform a calculation and show the result in an <output> element:
HTML <p> Tag
<form oninput="x.value=parseInt(a.value)+parseInt(b.value)">
<input type="range" id="a" value="50">
+<input type="number" id="b" value="25">
Example
=<output name="x" for="a b"></output>
</form>
Attributes
Attribute Value Description Attribute
for element_id Specifies the for
relationship
between the
result of the Definition and Usage
calculation,
and the The <p> tag defines a paragraph.
elements
used in the Browsers automatically add a single blank line before and after
calculation each <p> element.
form form_id Specifies form
which form Tip: Use CSS to style paragraphs.
the output
element
belongs to
Example
name name Specifies a name
name for the
output
element Align text in a paragraph (with CSS):
<html>
<head>
<style>
p {
color: navy;
text-indent: 30px;
text-transform: uppercase; Example
}
</style>
Example
p {
display: block;
More on paragraphs: margin-top: 1em;
margin-bottom: 1em;
margin-left: 0;
79
margin-right: 0; param {
} display: none;
}
<picture>
<source media="(min-width:650px)" srcset="img_pink_flowers.
Set the "autoplay" parameter to "true", so the sound will start playing as jpg">
soon as the page loads: <source media="(min-width:465px)" srcset="img_white_flower.
jpg">
<img src="img_orange_flowers.jpg" alt="Flowers" style="widt
<object data="horse.wav"> h:auto;">
<param name="autoplay" value="true"> </picture>
</object>
Definition and Usage
Definition and Usage
The <picture> tag gives web developers more flexibility in
The <param> tag is used to define parameters for specifying image resources.
an <object> element.
The most common use of the <picture> element will be for art
Attributes direction in responsive designs. Instead of having one image that
is scaled up or down based on the viewport width, multiple images
Attribute Value Description can be designed to more nicely fill the browser viewport.
name name Specifies the name
of a parameter The <picture> element contains two tags: one or
value value Specifies the value more <source> tags and one <img> tag.
of the parameter
The browser will look for the first <source> element where the
Default CSS Settings media query matches the current viewport width, and then it will
display the proper image (specified in the srcset attribute). The
Most browsers will display the <param> element with the following <img> element is required as the last child of
default values:
80
the <picture> element, as a fallback option if none of the source computer code
tags matches. <samp> Defines sample <samp>
output from a
Tip: The <picture> element works "similar" to <video> and computer program
<audio>. You set up different sources, and the first source that <kbd> Defines keyboard <kbd>
fits the preferences is the one being used. input
<var> Defines a variable <var>
The <picture> tag also supports the Event Attributes in HTML.
Example
Example
pre {
Definition and Usage display: block;
The <pre> tag defines preformatted text.Text in font-family: monospace;
white-space: pre;
a <pre> element is displayed in a fixed-width font, and the text
margin: 1em 0;
preserves both spaces and line breaks. The text will be displayed
}
exactly as written in the HTML source code.
The <progress> tag represents the completion progress of a task. Definition and Usage
Tip: Always add the <label> tag for best accessibility practices! The <q> tag defines a short quotation.
Tips and Notes Browsers normally insert quotation marks around the quotation.
Tip: Use the <progress> tag in conjunction with JavaScript to Tip: Use <blockquote> for long quotations.
display the progress of a task.
Attributes
Note: The <progress> tag is not suitable for representing a gauge
(e.g. disk space usage or relevance of a query result). To Attribute Value Description
represent a gauge, use the <meter> tag instead. cite URL Specifies the
source URL of the
quote
Attributes
<html>
<head>
Default CSS Settings
<style>
q {
None.
color: gray;
font-style: italic;
t Yourself » HTML <q> Tag }
</style>
</head>
<body>
Example
82
A ruby annotation:
<p>WWF's goal is to:
<q>Build a future where people live in harmony with
nature.</q> <ruby>
We hope they succeed.</p> 漢 <rp>(</rp><rt>ˋ</rt><rp>)</rp>
</ruby>
</body>
Definition and Usage
</html>
The <rp> tag can be used to provide parentheses around a ruby
Default CSS Settings
text, to be shown by browsers that do not support ruby
annotations.
Most browsers will display the <q> element with the following
default values:
Use <rp> together with <ruby> and <rt>: The <ruby> element
consists of one or more characters that needs an
explanation/pronunciation, and an <rt> element that gives that
Example information, and an optional <rp> element that defines what to
show for browsers that not support ruby annotations.
q:before {
content: open-quote;
}
q:after {
content: close-quote;
}
A ruby annotation:
Example
83
<ruby> A ruby annotation is a small extra text, attached to the main text
漢 <rt> ˋ </rt> to indicate the pronunciation or meaning of the corresponding
</ruby> characters. This kind of annotation is often used in Japanese
publications.
Definition and Usage
Use <ruby> together with <rt> and <rp>: The <ruby> element
The <rt> tag defines an explanation or pronunciation of consists of one or more characters that needs an
characters (for East Asian typography) in a ruby annotation. explanation/pronunciation, and an <rt> element that gives that
information, and an optional <rp> element that defines what to
Use <rt> together with <ruby> and <rp>: The <ruby> element show for browsers that do not support ruby annotations.
consists of one or more characters that needs an
explanation/pronunciation, and an <rt> element that gives that
information, and an optional <rp> element that defines what to
show for browsers that not support ruby annotations
A ruby annotation: The <s> tag should not be used to define deleted text in a
document, use the <del> tag for that.
Example
Example
HTML <script> Tag
Define some text as sample output from a computer program in a
document: Example
Example
Definition and Usage The name attribute is needed to reference the form data after the
form is submitted (if you omit the name attribute, no data from the
The <section> tag defines a section in a document. drop-down list will be submitted).
Default CSS Settings The id attribute is needed to associate the drop-down list with a
label.
Most browsers will display the <section> element with the following default
values: The <option> tags inside the <select> element define the
available options in the drop-down list.
Tip: Always add the <label> tag for best accessibility practices!
Example
Attributes
section {
display: block; Attribute Value Description
} autofocus autofocus Specifies that the
drop-down list
HTML <select> Tag should
automatically get
focus when the
page loads
Example disabled disabled Specifies that a
drop-down list
should be disabled
Create a drop-down list with four options: form form_id Defines which form
the drop-down list
belongs to
multiple multiple Specifies that
<label for="cars">Choose a car:</label>
multiple options
can be selected at
<select name="cars" id="cars"> once
<option value="volvo">Volvo</option> name name Defines a name for
<option value="saab">Saab</option> the drop-down list
87
required required Specifies that the <p>This is some normal text.</p>
user is required to <p><small>This is some smaller text.</small></p>
select a value
before submitting
the form
size number Defines the Definition and Usage
number of visible
options in a drop- The <small> tag defines smaller text (like copyright and other
down list side-comments).
Example </body>
</html>
<audio controls>
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
Attributes
<video width="320" height="240" controls>
<source src="movie.mp4" type="video/mp4">
Attribute Value Description <source src="movie.ogg" type="video/ogg">
media media_query Accepts any valid Your browser does not support the video tag.
media query that </video>
would normally be
defined in a CSS
sizes Specifies image
89
Example The <span> tag is easily styled by CSS or manipulated with
JavaScript using the class or id attribute.
Use <source> within <picture> to define different images based on the The <span> tag is much like the <div> element, but <div> is a
viewport width: block-level element and <span> is an inline element.
<picture> None.
<source media="(min-width:650px)" srcset="img_pink_flowers.
jpg">
<source media="(min-width:465px)" srcset="img_white_flower.
jpg">
<img src="img_orange_flowers.jpg" alt="Flowers" style="widt
h:auto;">
</picture>
The <span> tag is an inline container used to mark up a part of a Use the <s> tag to mark up text that is no longer correct:
text, or a part of a document.
90
<p><s>My car is blue.</s></p> <html>
<head>
<style>
HTML <strong> Tag h1 {color:red;}
Example p {color:blue;}
</style>
</head>
<body>
Define important text in a document:
<h1>A heading</h1>
<p>A paragraph.</p>
<strong>This text is important!</strong>
Tip: Use the <b> tag to specify bold text without any extra importance! The <style> tag is used to define style information (CSS) for a
document.
Default CSS Settings
Inside the <style> element you specify how HTML elements
Most browsers will display the <strong> element with the following default should render in a browser.
values:
Tips and Notes
Example Note: When a browser reads a style sheet, it will format the HTML
document according to the information in the style sheet. If some
properties have been defined for the same selector (element) in
different style sheets, the value from the last read style sheet will
strong {
be used (see example below)!
font-weight: bold;
}
Tip: To link to an external style sheet, use the <link> tag.
Tip: To learn more about style sheets, please read our CSS
Tutorial.
HTML <style> Tag
Example
type text/css
optimized for
Specifies the media
HTML <sub> Tag
type of the <style>
tag
Example
Example
Subscript text:
Multiple styles for the same elements:
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
Default CSS Settings
</body> Most browsers will display the <sub> element with the following
</html> default values:
Example
Default CSS Settings
Most browsers will display the <style> element with the following
default values: sub {
vertical-align: sub;
92
font-size: smaller; <html>
} <style>
details > summary {
padding: 4px;
width: 200px;
HTML <summary> Tag background-color: #eeeeee;
border: none;
box-shadow: 1px 1px 2px #bbbbbb;
cursor: pointer;
Example
}
details > p {
Using the <summary> element: background-color: #eeeeee;
padding: 4px;
margin: 0;
<details> box-shadow: 1px 1px 2px #bbbbbb;
<summary>Epcot Center</summary> }
<p>Epcot is a theme park at Walt Disney World Resort </style>
featuring exciting attractions, international pavilions, <body>
award-winning fireworks and seasonal special events.</p>
</details> <details>
<summary>Epcot Center</summary>
<p>Epcot is a theme park at Walt Disney World Resort
featuring exciting attractions, international pavilions,
award-winning fireworks and seasonal special events.</p>
</details>
Note: The <summary> element should be the first child Most browsers will display the <summary> element with the
element of the <details> element. following default values:
summary {
display: block;
Example
}
Superscript text:
93
<p>This text contains <sup>superscript</sup> text.</p> width="4" fill="yellow" />
</svg>
Definition and Usage
The <sup> tag defines superscript text. Superscript text appears half a
character above the normal line, and is sometimes rendered in a smaller
font. Superscript text can be used for footnotes, like WWW[1].
Definition and Usage
SVG has several methods for drawing paths, boxes, circles, text,
and graphic images.
Tip: Use the <sub> tag to define subscript text. To learn more about SVG, please read our SVG Tutorial.
Most browsers will display the <sup> element with the following
default values:
Draw a rectangle:
Example
Try it Yourself »
Example
Example
<svg width="400" height="180">
<rect x="50" y="20" rx="20" ry="20" width="150" height="150
Draw a circle: " style="fill:red;stroke:black;stroke-width:5;opacity:0.5" />
</svg>
<svg width="300" height="200"> A simple HTML table, containing two columns and two rows:
<polygon points="100,10 40,198 190,78 10,78 160,198"
style="fill:lime;stroke:purple;stroke-width:5;fill-
rule:evenodd;" />
<table>
</svg>
<tr>
<th>Month</th>
<th>Savings</th>
Example </tr>
<tr>
<td>January</td>
Draw an SVG logo: <td>$100</td>
</tr>
</table>
<svg height="130" width="500"> Definition and Usage
<defs>
<linearGradient id="grad1" x1="0%" y1="0%" x2="100%" y2="0%">
The <table> tag defines an HTML table.
<stop offset="0%" style="stop-color:rgb(255,255,0);stop-
opacity:1" />
An HTML table consists of one <table> element and one or
<stop offset="100%" style="stop-color:rgb(255,0,0);stop-
more <tr>, <th>, and <td> elements.
opacity:1" />
</linearGradient>
</defs> The <tr> element defines a table row, the <th> element defines a
table header, and the <td> element defines a table cell.
<ellipse cx="100" cy="70" rx="85" ry="55" fill="url(#grad1)" An HTML table may also
/> include <caption>, <colgroup>, <thead>, <tfoot>,
and <tbody> elements.
<text fill="#ffffff" font-size="45" font-family="Verdana" x="
50" y="86">SVG</text>
</svg> Example
<html>
<head>
<style>
table, th, td {
HTML <table> Tag border: 1px solid black;
95
border-collapse: collapse; <tr>
} <td>February</td>
</style> <td>$80</td>
</head> </tr>
<body> </table>
<table>
<tr> Example
<th>Month</th>
<th>Savings</th>
</tr> How to center-align a table (with CSS):
<tr>
<td>January</td>
<td>$100</td>
</tr> <html>
<tr> <head>
<td>February</td> <style>
<td>$80</td> table, th, td {
</tr> border: 1px solid black;
</table> }
table.center {
margin-left: auto;
</body> margin-right: auto;
</html> }
</style>
</head>
<body>
<table class="center">
Example <tr>
<th>Month</th>
<th>Savings</th>
How to right-align a table (with CSS): </tr>
<tr>
<td>January</td>
<td>$100</td>
<table style="float:right"> </tr>
<tr> <tr>
<th>Month</th> <td>February</td>
<th>Savings</th> <td>$80</td>
</tr> </tr>
<tr> </table>
<td>January</td>
<td>$100</td>
</tr>
Example
96
How to add background-color to a table (with CSS): <th>Savings</th>
</tr>
<tr>
<td>January</td>
<table style="background-color:#00FF00">
<td>$100</td>
<tr>
</tr>
<th>Month</th>
<tr>
<th>Savings</th>
<td>February</td>
</tr>
<td>$80</td>
<tr>
</tr>
<td>January</td>
</table>
<td>$100</td>
</tr>
<tr> </body>
<td>February</td> </html>
<td>$80</td>
</tr>
Example
</table>
<table style="width:400px">
How to add padding to a table (with CSS):
<tr>
<th>Month</th>
<th>Savings</th>
<html> </tr>
<head> <tr>
<style> <td>January</td>
table, th, td { <td>$100</td>
border: 1px solid black; </tr>
} <tr>
<td>February</td>
th, td { <td>$80</td>
padding: 10px; </tr>
} </table>
</style>
</head>
<body> Example
<table>
<tr> How to create table headers:
<th>Month</th>
97
<table> <table>
<tr> <tr>
<th>Name</th> <th>Name</th>
<th>Email</th> <th>Email</th>
<th>Phone</th> <th colspan="2">Phone</th>
</tr> </tr>
<tr> <tr>
<td>John Doe</td> <td>John Doe</td>
<td>john.doe@example.com</td> <td>john.doe@example.com</td>
<td>123-45-678</td> <td>123-45-678</td>
</tr> <td>212-00-546</td>
</table> </tr>
</table>
Most browsers will display the <table> element with the following
default values:
How to create a table with a caption:
Example
<table>
<caption>Monthly savings</caption>
<tr> table {
<th>Month</th> display: table;
<th>Savings</th> border-collapse: separate;
</tr> border-spacing: 2px;
<tr> border-color: gray;
<td>January</td> }
<td>$100</td>
</tr>
<tr>
<td>February</td>
<td>$80</td>
</tr>
</table> HTML <tbody> Tag
Example Example
How to define table cells that span more than one row or one column: An HTML table with a <thead>, <tbody>, and a <tfoot> element:
98
<table> Note: The <tbody> element must have one or more <tr> tags
<thead> inside.
<tr>
<th>Month</th> The <tbody> tag must be used in the following context: As a child
<th>Savings</th> of a <table> element, after any <caption>, <colgroup>,
</tr> and <thead> elements.
</thead>
<tbody> Tip: The <thead>, <tbody>, and <tfoot> elements will not affect
<tr> the layout of the table by default. However, you can use CSS to
<td>January</td> style these elements (see example below)!
<td>$100</td>
</tr>
<tr> Example
<td>February</td>
<td>$80</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>Sum</td>
<td>$180</td>
</tr>
</tfoot>
</table> Style <thead>, <tbody>, and <tfoot> with CSS:
<html>
<head>
<style>
Definition and Usage thead {color: green;}
tbody {color: blue;}
The <tbody> tag is used to group the body content in an HTML tfoot {color: red;}
table.
table, th, td {
The <tbody> element is used in conjunction with border: 1px solid black;
the <thead> and <tfoot> elements to specify each part of a table }
(body, header, footer). </style>
</head>
Browsers can use these elements to enable scrolling of the table <body>
body independently of the header and footer. Also, when printing
a large table that spans multiple pages, these elements can
<table>
enable the table header and footer to be printed at the top and
<thead>
bottom of each page.
<tr>
<th>Month</th>
99
<th>Savings</th> </tbody>
</tr> </table>
</thead>
<tbody>
<tr>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td>February</td>
<td>$80</td>
</tr> Example
</tbody>
<tfoot>
<tr> How to vertical align content inside <tbody> (with CSS):
<td>Sum</td>
<td>$180</td>
</tr>
<table style="width:50%;">
</tfoot>
<tr>
</table>
<th>Month</th>
<th>Savings</th>
</tr>
Example <tbody style="vertical-align:bottom">
<tr style="height:100px">
<td>January</td>
How to align content inside <tbody> (with CSS): <td>$100</td>
</tr>
<tr style="height:100px">
<td>February</td>
<table style="width:100%"> <td>$80</td>
<thead> </tr>
<tr> </tbody>
<th>Month</th> </table>
<th>Savings</th>
</tr> Default CSS Settings
</thead>
<tbody style="text-align:right">
Most browsers will display the <tbody> element with the following
<tr>
default values:
<td>January</td>
<td>$100</td>
</tr> tbody {
<tr> display: table-row-group;
<td>February</td> vertical-align: middle;
<td>$80</td> border-color: inherit;
</tr> }
100
colspan number Specifies the
number of columns
a cell should span
headers header_id Specifies one or
more header cells
HTML <td> Tag a cell is related to
rowspan number Sets the number of
rows a cell should
span
Example More Examples
A simple HTML table, with two rows and four table cells: Example
Attributes
<table>
Attribute Value Description <tr>
101
<th>Month</th> explain anything</td>
<th>Savings</th> </tr>
</tr> </table>
<tr>
<td style="background-color:#FF0000">January</td>
<td style="background-color:#00FF00">$100</td> Example
</tr>
</table>
How to vertical align content inside <td> (with CSS):
Example
<table style="width:50%;">
<tr>
How to set the height of a table cell (with CSS):
<th>Month</th>
<th>Savings</th>
</tr>
<table> <tr style="height:100px">
<tr> <td style="vertical-align:bottom">January</td>
<th>Month</th> <td style="vertical-align:bottom">$100</td>
<th>Savings</th> </tr>
</tr> </table>
<tr>
<td style="height:100px">January</td>
<td style="height:100px">$100</td>
</tr>
</table> Example
<table style="width:100%">
<tr>
How to specify no word-wrapping in table cell (with CSS):
<th>Month</th>
<th>Savings</th>
</tr>
<table> <tr>
<tr> <td style="width:70%">January</td>
<th>Poem</th> <td style="width:30%">$100</td>
</tr> </tr>
<tr> </table>
<td style="white-space:nowrap">Never increase, beyond
what is necessary, the number of entities required to
102
Example Example
How to create table headers: How to define table cells that span more than one row or one column:
<table> <table>
<tr> <tr>
<th>Name</th> <th>Name</th>
<th>Email</th> <th>Email</th>
<th>Phone</th> <th colspan="2">Phone</th>
</tr> </tr>
<tr> <tr>
<td>John Doe</td> <td>John Doe</td>
<td>john.doe@example.com</td> <td>john.doe@example.com</td>
<td>123-45-678</td> <td>123-45-678</td>
</tr> <td>212-00-546</td>
</table> </tr>
</table>
Most browsers will display the <td> element with the following
default values:
How to create a table with a caption:
td {
display: table-cell;
<table> vertical-align: inherit;
<caption>Monthly savings</caption> }
<tr>
<th>Month</th>
<th>Savings</th> HTML <template> Tag
</tr>
<tr>
<td>January</td> Example
<td>$100</td>
</tr>
<tr>
<td>February</td> Use <template> to hold some content that will be hidden when the
<td>$80</td> page loads. Use JavaScript to display it:
</tr>
</table>
<button onclick="showContent()">Show hidden content</button>
103
<template> Fill the web page with one new div element for each item in an array.
<h2>Flower</h2> The HTML code of each div element is inside the template element:
<img src="img_white_flower.jpg" width="214" height="204">
</template>
<template>
<script> <div class="myClass">I like: </div>
function showContent() { </template>
let temp = document.getElementsByTagName("template")[0];
let clon = temp.content.cloneNode(true);
<script>
document.body.appendChild(clon);
let myArr =
}
["Audi", "BMW", "Ford", "Honda", "Jaguar", "Nissan"];
</script>
function showContent() {
let temp, item, a, i;
Try it Yourself » temp = document.getElementsByTagName("template")[0];
item = temp.content.querySelector("div");
for (i = 0; i < myArr.length; i++) {
More "Try it Yourself" examples below. a = document.importNode(item, true);
a.textContent += myArr[i];
document.body.appendChild(a);
}
}
Definition and Usage </script>
Example
104
HTML <textarea> Tag Attribute
autofocus
Value
autofocus
Description
Specifies that a
text area should
automatically get
focus when the
Example page loads
cols number Specifies the
visible width of a
text area
A multi-line text input control (text area): dirname textareaname.dir Specifies that the
text direction of
the textarea will be
<label for="w3review">Review of W3Schools:</label> submitted
disabled disabled Specifies that a
text area should be
<textarea id="w3review" name="w3review" rows="4" cols="50" disabled
> form form_id Specifies which
At w3schools.com you will learn how to make a website. form the text area
They offer free tutorials in all web development belongs to
technologies. maxlength number Specifies the
</textarea> maximum number
of characters
Definition and Usage allowed in the text
area
The <textarea> tag defines a multi-line text input control. name text Specifies a name
for a text area
The <textarea> element is often used in a form, to collect user placeholder text Specifies a short
inputs like comments or reviews. hint that describes
the expected value
A text area can hold an unlimited number of characters, and the of a text area
text renders in a fixed-width font (usually Courier). readonly readonly Specifies that a
text area should be
The size of a text area is specified by the cols and rows attributes read-only
(or with CSS). required required Specifies that a
text area is
The name attribute is needed to reference the form data after the required/must be
form is submitted (if you omit the name attribute, no data from the filled out
text area will be submitted). rows number Specifies the
visible number of
The id attribute is needed to associate the text area with a label. lines in a text area
wrap hard Specifies how the
Tip: Always add the <label> tag for best accessibility practices! soft text in a text area
is to be wrapped
Attributes when submitted in
a form
105
Example <table>
<thead>
<tr>
<th>Month</th>
Disable default resize option:
<th>Savings</th>
</tr>
</thead>
<html> <tbody>
<head> <tr>
<style> <td>January</td>
textarea { <td>$100</td>
resize: none; </tr>
} <tr>
</style> <td>February</td>
</head> <td>$80</td>
<body> </tr>
</tbody>
<label for="w3review">Review of W3Schools:</label> <tfoot>
<tr>
<td>Sum</td>
<textarea id="w3review" name="w3review" rows="4" cols="50" <td>$180</td>
> </tr>
At w3schools.com you will learn how to make a website. </tfoot>
They offer free tutorials in all web development </table>
technologies.
</textarea> Definition and Usage
</body> The <tfoot> tag is used to group footer content in an HTML table.
</html>
The <tfoot> element is used in conjunction with
Default CSS Settings the <thead> and <tbody> elements to specify each part of a table (footer, header,
body).
None.
Browsers can use these elements to enable scrolling of the table body independently
of the header and footer. Also, when printing a large table that spans multiple
pages, these elements can enable the table header and footer to be printed at the top
and bottom of each page.
HTML <tfoot> Tag
Note: The <tfoot> element must have one or more <tr> tags inside.
Example The <tfoot> tag must be used in the following context: As a child of
a <table> element, after any <caption>, <colgroup>, <thead>,
and <tbody> elements.
An HTML table with a <thead>, <tbody>, and a <tfoot> element:
106
Tip: The <thead>, <tbody>, and <tfoot> elements will not affect the layout of <td>Sum</td>
the table by default. However, you can use CSS to style these elements (see <td>$180</td>
example below)! </tr>
</tfoot>
</table>
Example
Example
<html>
<head>
<style>
thead {color: green;} How to align content inside <tfoot> (with CSS):
tbody {color: blue;}
tfoot {color: red;}
<table style="width:100%">
table, th, td { <tr>
border: 1px solid black; <th>Month</th>
} <th>Savings</th>
</style> </tr>
</head> <tr>
<body> <td>January</td>
<td>$100</td>
</tr>
<table>
<tr>
<thead>
<td>February</td>
<tr>
<td>$80</td>
<th>Month</th>
</tr>
<th>Savings</th>
<tfoot style="text-align:center">
</tr>
<tr>
</thead>
<td>Sum</td>
<tbody>
<td>$180</td>
<tr>
</tr>
<td>January</td>
</tfoot>
<td>$100</td>
</table>
</tr>
<tr>
<td>February</td>
<td>$80</td>
</tr>
</tbody>
<tfoot>
<tr>
107
Example Example
How to vertical align content inside <tfoot> (with CSS): A simple HTML table with three rows, two header cells and four data
cells:
<table style="width:100%">
<tr> <table>
<th>Month</th> <tr>
<th>Savings</th> <th>Month</th>
</tr> <th>Savings</th>
<tr> </tr>
<td>January</td> <tr>
<td>$100</td> <td>January</td>
</tr> <td>$100</td>
<tr> </tr>
<td>February</td> <tr>
<td>$80</td> <td>February</td>
</tr> <td>$80</td>
<tfoot style="vertical-align:bottom"> </tr>
<tr style="height:100px"> </table>
<td>Sum</td>
<td>$180</td> Definition and Usage
</tr>
</tfoot> The <th> tag defines a header cell in an HTML table.
</table>
An HTML table has two kinds of cells:
Default CSS Settings
Header cells - contains header information (created with
Most browsers will display the <tfoot> element with the following default the <th> element)
values: Data cells - contains data (created with the <td> element)
tfoot { The text in <th> elements are bold and centered by default.
display: table-footer-group;
vertical-align: middle;
The text in <td> elements are regular and left-aligned by default.
border-color: inherit;
}
Attributes
Attribute Value Description
abbr text Specifies an
HTML <th> Tag abbreviated
version of the
❮ PreviousComplete HTML ReferenceNext ❯
content in a header
cell
108
colspan number Specifies the Example
number of columns
a header cell
should span How to add background-color to table header cell (with CSS):
headers header_id Specifies one or
more header cells
a cell is related to
rowspan number Specifies the <table>
number of rows a <tr>
header cell should <th style="background-color:#FF0000">Month</th>
span <th style="background-color:#00FF00">Savings</th>
scope col Specifies whether a </tr>
colgroup header cell is a <tr>
row header for a <td>January</td>
rowgroup column, row, or <td>$100</td>
group of columns </tr>
or rows </table>
Example
Example How to set the height of a table header cell (with CSS):
Example <table>
<tr>
<th>Name</th>
How to vertical align content inside <th> (with CSS): <th>Email</th>
<th>Phone</th>
</tr>
<tr>
<table style="width:50%;"> <td>John Doe</td>
<tr style="height:100px"> <td>john.doe@example.com</td>
<th style="vertical-align:bottom">Month</th> <td>123-45-678</td>
<th style="vertical-align:bottom">Savings</th> </tr>
</tr> </table>
<tr>
<td>January</td>
<td>$100</td> Example
</tr>
</table>
<table>
How to set the width of a table header cell (with CSS): <caption>Monthly savings</caption>
<tr>
<th>Month</th>
<th>Savings</th>
<table style="width:100%"> </tr>
<tr> <tr>
<th style="width:70%">Month</th> <td>January</td>
<th style="width:30%">Savings</th> <td>$100</td>
</tr> </tr>
<tr> <tr>
<td>January</td> <td>February</td>
110
<td>$80</td> An HTML table with a <thead>, <tbody>, and a <tfoot> element:
</tr>
</table>
<table>
<thead>
Example <tr>
<th>Month</th>
<th>Savings</th>
How to define table cells that span more than one row or one column: </tr>
</thead>
<tbody>
<tr>
<table> <td>January</td>
<tr> <td>$100</td>
<th>Name</th> </tr>
<th>Email</th> <tr>
<th colspan="2">Phone</th> <td>February</td>
</tr> <td>$80</td>
<tr> </tr>
<td>John Doe</td> </tbody>
<td>john.doe@example.com</td> <tfoot>
<td>123-45-678</td> <tr>
<td>212-00-546</td> <td>Sum</td>
</tr> <td>$180</td>
</table> </tr>
</tfoot>
Default CSS Settings </table
Most browsers will display the <th> element with the following
default values:
Definition and Usage
th {
display: table-cell; The <thead> tag is used to group header content in an HTML
vertical-align: inherit; table.
font-weight: bold;
text-align: center; The <thead> element is used in conjunction with
} the <tbody> and <tfoot> elements to specify each part of a table
(header, body, footer).
<html>
<head>
<style> How to align content inside <thead> (with CSS):
thead {color: green;}
tbody {color: blue;}
tfoot {color: red;} <table style="width:100%">
<thead style="text-align:left">
table, th, td { <tr>
border: 1px solid black; <th>Month</th>
} <th>Savings</th>
</style> </tr>
</head> </thead>
<body> <tbody>
<tr>
<td>January</td>
<table>
<td>$100</td>
<thead>
</tr>
<tr>
<tr>
<th>Month</th>
<td>February</td>
<th>Savings</th>
<td>$80</td>
</tr>
</tr>
</thead>
</tbody>
<tbody>
</table>
<tr>
<td>January</td>
<td>$100</td>
112
Example
thead { Attributes
display: table-header-group;
vertical-align: middle; Attribute Value Description
border-color: inherit; datetime datetime Represent a
} machine-readable
format of the
<time> element
None.
</body> Most browsers will display the <title> element with the following
</html> default values:
Example
Example <table>
<tr>
<th>Name</th>
<th>Email</th>
How to add background-color to a table row (with CSS): <th>Phone</th>
</tr>
<tr>
<table> <td>John Doe</td>
<tr style="background-color:#FF0000"> <td>john.doe@example.com</td>
115
<td>123-45-678</td> <td>123-45-678</td>
</tr> <td>212-00-546</td>
</table> </tr>
</table>
Most browsers will display the <tr> element with the following
default values:
How to create a table with a caption:
tr {
display: table-row;
<table> vertical-align: inherit;
<caption>Monthly savings</caption> border-color: inherit;
<tr> }
<th>Month</th>
<th>Savings</th>
</tr>
<tr> HTML <track> Tag
<td>January</td>
<td>$100</td>
</tr>
<tr> Example
<td>February</td>
<td>$80</td>
</tr> A video with subtitle tracks for two languages:
</table>
Example
HTML <tt> Tag
Not Supported in HTML5. Mark up a misspelled word with the <u> tag:
Tip: Avoid using the <u> element where it could be confused for a
hyperlink!
Example
Example Example
118
Set the different list style types (with CSS):
ul style="list-style-type:circle"> Example
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li> Create a list inside a list (a nested list):
</ul>
Example
Example
<ul>
<ul style="line-height:180%"> <li>Coffee</li>
<li>Coffee</li> <li>Tea
<li>Tea</li> <ul>
<li>Milk</li> <li>Black tea</li>
</ul> <li>Green tea
<ul>
<li>China</li>
<ul style="line-height:80%"> <li>Africa</li>
<li>Coffee</li> </ul>
<li>Tea</li> </li>
<li>Milk</li> </ul>
</ul> </li>
<li>Milk</li>
</ul>
119
Default CSS Settings Also look at:
Most browsers will display the <ul> element with the following default values: Tag Description
<code> Defines a piece of computer
code
Example <samp> Defines sample output from a
computer program
<kbd> Defines keyboard input
ul { <pre> Defines preformatted text
display: block;
Default CSS Settings
list-style-type: disc;
margin-top: 1em;
margin-bottom: 1 em; Most browsers will display the <var> element with the following
margin-left: 0; default values:
margin-right: 0;
padding-left: 40px;
} Example
var {
font-style: italic;
HTML <var> Tag }
Example
Tip: For audio files, look at the <audio> tag. HTML <wbr> Tag
Optional Attributes
Example
Attribute Value Description
autoplay autoplay Specifies that the
video will start
playing as soon as A text with word break opportunities:
it is ready
controls controls Specifies that video
controls should be <p>To learn AJAX, you must be familiar with the
displayed (such as XML<wbr>Http<wbr>Request Object.</p>
a play/pause
button etc). Definition and Usage
height pixels Sets the height of
the video player The <wbr> (Word Break Opportunity) tag specifies where in a text
loop loop Specifies that the it would be ok to add a line-break.
video will start over
again, every time it
Tip: When a word is too long, the browser might break it at the
is finished
wrong place. You can use the <wbr> element to add word break
muted muted Specifies that the opportunities.
audio output of the
video should be
muted
poster URL Specifies an image
121
HTML Introduction
What is HTML?
What is an HTML element?
Web browsers
HTML page structure
HTML History
HTML BASIC
HTML Document
HTML Declaration
HTML Headings
HTML Paragraphs
HTML Links
HTML Images
How to view HTML sources?
HTML ELEMENT
HTML Elements
Nested HTML Elements
Empty HTML Elements
HTML Attributes
The href attribute
The src attribute
The width and height attributes
HTML Headings
HTML Headings
Heading is Important
Bigger headings
HTML Paragraphs
HTML Paragraphs
HTML display
HTML Horizontal rules
HTML Line breaks
The Poem Problem
Solution - the HTML <pre> Element
HTML style Attribute
Background and Color
HTML Styles
Text Color
Fonts
Text Size
122
Text Alignment HTML Links
HTMLFormatting HTML Links-Hyper Links
HTML Formatting Elements HTML Links-Syntax
HTML <b> and <strong> Elements HTML Links- The Target Attribute
HTML <i> and <em> Elements Absolute URLs Vs Relative URLs
HtML <small> Element HTML Links- Use an image as a link
HTML <mark> Element Links to an Email Adress
HTML <del> Element Button as a Link
HTML <ins> Element Link Titles
HTML <sub> Element More on Absolute URLs and Relative URLs
HTML Quotations HTML LInks Tags
HTML <blockquote> for Quotations HTML Links- Different Colors
HTML <q> for short Quotations HTML- Link Colors
HTML <abbr> for Abrreviations HTML Links- Create Bookmarks
HTML <address> for Contact Information
HTML <cite> for work Title
HTML <bdo> for bi-directional Override
HTML Comments HTML Images
HTML Comment Tag HTML Images
Add Comments HTML images Syntax
Hide Contents The src Attribute
Hide in the Comments The alt attribute
HTML Colors Image -Size, Width, and Height
Color Names Width and Height , or Style?
Background Color Images in another folder
Test color Images on another server/website
Border Color Animated Images
Color Values Images as a link
HTML RGB and RGBA color Image floating
RGB clor Values Common Image Formats
HTML HEX Colors Chapter Summary
HTML Color Values
HTML HSL HSLA Colors HTML image Maps
HSL Color Values Image maps
Saturation How does it work?
HTML CSS The image
What is CSS? Create Image map
Using CSS The areas
Inline CSS Shape=”rect”
Internal CSS Shape=”circle”
External CSS Shape=”poly”
CSS Colors, Fonts, and Sizes Image map and Javascript
CSS Border Chapter Summary
CSS Padding HTML image tags
CSS Margin HTML Background Images
Link to External CSS
123
Background Image on a HTML element IdHTML IframesHTML JavaScriptHTML File PathsHTML HeadHTML
LayoutHTML ResponsiveHTML ComputercodeHTML
Background Images on a page
SemanticsHTML Style GuideHTML EntitiesHTML SymbolsHTML
Background Repeat EmojisHTML CharsetHTML URL Encode
Background Color
Background Stretch
HTML Favicon
How to add a favicon In HTML?
Favicon File Support
Chapter Summary
HTML Link tag
HTML Tables
HTML Tables
Define an HTML table
Table Cells
Table Row
Table headers
HTML tags
HTML Table Borders