Horje

Tips (Total 123)


# Tips-1) What is HTML <!--...--> Tag

HTML Tag Defines a comment

Example of HTML <!--...--> Tag

An HTML comment:
index.html
Example: HTML
 <!--This is a comment. Comments are not displayed in the browser-->

<p>This is a paragraph.</p> 

Output should be:

Example of HTML <!--...--> Tag

Definition and Usage HTML <!--...--> Tag

The comment tag is used to insert comments in the source code. Comments are not displayed in the browsers. 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 useful if you have a lot of code.

Browser Support HTML <!--...--> Tag

Output should be:

Browser Support HTML <!--...--> Tag

Tips and Notes HTML <!--...--> Tag

You can use the comment tag to "hide" scripts from browsers without support for scripts (so they don't show them as plain text):

Note: The two forward slashes at the end of comment line (//) is the JavaScript comment symbol. This prevents JavaScript from executing the --> tag.
<script type="text/javascript">
<!--
function displayMsg() {
  alert("Hello World!")
}
//-->
</script>  

# Tips-2) What is HTML <!DOCTYPE> Declaration

All HTML documents must start with a <!DOCTYPE> declaration.

The declaration is not an HTML tag. It is an "information" to the browser about what document type to expect.

In HTML 5, the declaration is simple:
<!DOCTYPE html>

Browser Support <!DOCTYPE> Declaration

Output should be:

Browser Support <!DOCTYPE> Declaration

Older HTML Documents

HTML 4.01:
index.html
Example: HTML
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

XHTML 1.1:
index.html
Example: HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

# Tips-3) What is HTML Elements and Doctypes

Look at our table of all HTML elements, and what Doctype each element appears in.

Tips and Notes HTML Elements and Doctypes

Tip: The <!DOCTYPE> declaration is NOT case sensitive.
<!DOCTYPE html>
<!DocType html>
<!Doctype html>
<!doctype html>


# Tips-4) What is HTML <a> Tag

The <a> tag defines a hyperlink, which is used to link from one page to another.

The most important attribute of the <a> element is the href attribute, which indicates the link's destination.

By default, links will appear as follows in all browsers:

Example of HTML <a> Tag

Create a link to Horje.com:
 <a href="https://horje.com">Visit Horje.com!</a> 

Output should be:

Example of HTML <a> Tag

Tips and Notes for HTML <a> Tag

Tip: If the <a> tag has no href attribute, it is only a placeholder for a hyperlink. Tip: A linked page is normally displayed in the current browser window, unless you specify another target.

Browser Support for HTML <a> Tag

Output should be:

Browser Support for HTML <a> Tag

<a> Tag Attributes

Attribute Value Description
download filename Specifies that the target will be downloaded when a user clicks on the hyperlink
href URL Specifies the URL of the page the link goes to
hreflang language_code Specifies the language of the linked document
media media_query Specifies what media/device the linked document is optimized for
ping list_of_URLs Specifies a space-separated list of URLs to which, when the link is followed, post requests with the body ping will be sent by the browser (in the background). Typically used for tracking.
referrerpolicy no-referrer
no-referrer-when-downgrade
origin
origin-when-cross-origin
same-origin
strict-origin-when-cross-origin
unsafe-url
Specifies which referrer information to send with the link
rel alternate
author
bookmark
external
help
license
next
nofollow
noreferrer
noopener
prev
search
tag
Specifies the relationship between the current document and the linked document
target _blank
_parent
_self
_top
Specifies where to open the linked document
type media_type Specifies the media type of the linked document

<a> Global Attributes

The <a> tag also supports the Global Attributes in HTML.

<a> Event Attributes

The <a> tag also supports the Event Attributes in HTML.

How to use an image as a link

An image as a link:
index.html
Example: HTML
 <a href="https://www.w3schools.com">
<img border="0" alt="W3Schools" src="logo_w3s.gif" width="100" height="100">
</a> 

Output should be:

How to use an image as a link

How to open a link in a new browser window

<a href="https://horje.com" target="_blank">Visit Horje.com!</a> 

Output should be:

How to open a link in a new browser window

How to link to an email address

To create a link that opens in the user's email program (to let them send a new email), use mailto: inside the href attribute:
index.html
Example: HTML
<a href="mailto:[email protected]">Send email</a>

Output should be:

How to link to an email address

How to link to another section on the same page

index.html
Example: HTML
 <a href="#section2">Go to Section 2</a>
<h2 id="section2">Section 2</h2>

How to link to a JavaScript

index.html
Example: HTML
<a href="javascript:alert('Hello World!');">Execute JavaScript</a> 

Output should be:

How to link to a JavaScript

How to add HTML <a> download Attribute

Download file when clicking on the link (instead of navigating to the file):

Definition and Usage

The download attribute specifies that the target (the file specified in the href attribute) will be downloaded when a user clicks on the hyperlink.

The optional value of the download attribute will be the new name of the file after it is downloaded. There are no restrictions on allowed values, and the browser will automatically detect the correct file extension and add it to the file (.img, .pdf, .txt, .html, etc.).

If the value is omitted, the original filename is used.

Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<a download="filename">

Attribute Values

Value Description
filename Optional. Specifies the new filename for the downloaded file
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The a download attribute</h1>

<p>Click on the image to download it:<p>
<a href="https://horje.com/avatar.png" download>
  <img src="https://horje.com/avatar.png" alt="Horje" width="104" height="142">
</a>

<p><b>Note:</b> The download attribute is not supported in IE or Edge (prior version 18), or in Safari (prior version 10.1).</p>

</body>
</html>

Output should be:

How to add HTML <a> download Attribute

How to add HTML <a> href Attribute

The href attribute specifies the link's destination:

Definition and Usage

The href attribute specifies the URL of the page the link goes to.

If the href attribute is not present, the <a> tag will not be a hyperlink.

Tip: You can use href="#top" or href="#" to link to the top of the current page!

Browser Support

Syntax

<a href="URL">

Attribute Values

Value Description
URL The URL of the link.

Possible values:

  • An absolute URL - points to another web site (like href="http://www.example.com/default.htm")
  • A relative URL - points to a file within a web site (like href="default.htm")
  • Link to an element with a specified id within the page (like href="#section2")
  • Other protocols (like https://, ftp://, mailto:, file:, etc..)
  • A script (like href="javascript:alert('Hello');")
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The a href attribute</h1>

<p>An absolute URL: <a href="https://horje.com/">Horje</a></p>
<p>A relative URL: <a href="tag_a.asp">The a tag</a></p>

</body>
</html>

Output should be:

How to add HTML <a> href Attribute

How to add HTML <a> hreflang Attribute

The hreflang attribute specifies the language of the document in the link:

Definition and Usage

The hreflang attribute specifies the language of the linked document.

This attribute is only used if the href attribute is set.

Note: This attribute is purely advisory.

Browser Support

Syntax

<a hreflang="language_code">

Attribute Values

Value Description
language_code A two-letter language code that specifies the language of the linked document.
To view all available language codes, go to our Language code reference.

 

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The a hreflang attribute</h1>

<p><a hreflang="en" href="https://horje.com">Horje.com</a></p>

</body>
</html>

Output should be:

How to add HTML <a> hreflang Attribute

How to add HTML <a> media Attribute

A link with a media attribute.

Definition and Usage

The media attribute specifies what media or device the linked document is optimized for.

This attribute is used to specify that the target URL is designed for special devices (like iPhone), speech or print media.

This attribute can accept several values.

Only used if the href attribute is present.

Note: This attribute is purely advisory.

Browser Support

Syntax

<a media="value">

Possible Operators

Value Description
and Specifies an AND operator
not Specifies a NOT operator
, Specifies an OR operator

Devices

Value Description
all Default. Suitable for all devices
aural Speech synthesizers
braille Braille feedback devices
handheld Handheld devices (small screen, limited bandwidth)
projection Projectors
print Print preview mode/printed pages
screen Computer screens
tty Teletypes and similar media using a fixed-pitch character grid
tv Television type devices (low resolution, limited scroll ability)

Values

Value Description
width Specifies the width of the targeted display area.
"min-" and "max-" prefixes can be used.
Example: media="screen and (min-width:500px)"
height Specifies the height of the  targeted display area.
"min-" and "max-" prefixes can be used.
Example: media="screen and (max-height:700px)"
device-width Specifies the width of the target display/paper.
"min-" and "max-" prefixes can be used.
Example: media="screen and (device-width:500px)"
device-height Specifies the height of the target display/paper.
"min-" and "max-" prefixes can be used.
Example: media="screen and (device-height:500px)"
orientation Specifies the orientation of the target display/paper.
Possible values: "portrait" or "landscape"
Example: media="all and (orientation: landscape)"
aspect-ratio Specifies the width/height ratio of the targeted display area.
"min-" and "max-" prefixes can be used.
Example: media="screen and (aspect-ratio:16/9)"
device-aspect-ratio Specifies the device-width/device-height ratio of the target display/paper.
"min-" and "max-" prefixes can be used.
Example: media="screen and (aspect-ratio:16/9)"
color Specifies the bits per color of target display.
"min-" and "max-" prefixes can be used.
Example: media="screen and (color:3)"
color-index Specifies the number of colors the target display can handle.
"min-" and "max-" prefixes can be used.
Example: media="screen and (min-color-index:256)"
monochrome Specifies the bits per pixel in a monochrome frame buffer.
"min-" and "max-" prefixes can be used.
Example: media="screen and (monochrome:2)"
resolution Specifies the pixel density (dpi or dpcm) of the target display/paper.
"min-" and "max-" prefixes can be used.
Example: media="print and (resolution:300dpi)"
scan Specifies scanning method of a tv display.
Possible values are "progressive" and "interlace".
Example: media="tv and (scan:interlace)"
grid Specifies if the output device is grid or bitmap.
Possible values are "1" for grid, and "0" otherwise.
Example: media="handheld and (grid:1)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The a media attribute</h1>

<p>
<a href="https://horje.com/" media="print and (resolution:300dpi)">Open media attribute page for print</a>
</p>

</body>
</html>

Output should be:

How to add HTML <a> media Attribute

How to add HTML <a> media height Attribute

Specifies the height of the  targeted display area.
"min-" and "max-" prefixes can be used.
Example: media="screen and (max-height:700px)"

index.html
Example: HTML
<a href="att_a_media.asp?output=print"
media="screen and (max-height:700px)">
Open media attribute page for print.</a> 

Output should be:

How to add HTML <a> media height Attribute

How to add HTML <a> media device-width Attribute

Specifies the width of the target display/paper.
"min-" and "max-" prefixes can be used.
Example: media="screen and (device-width:500px)"

index.html
Example: HTML
<a href="att_a_media.asp?output=print"
media="screen and (device-width:500px)">
Open media attribute page for print.</a> 

Output should be:

How to add HTML <a> media device-width Attribute

How to add HTML <a> media width Attribute

Specifies the width of the targeted display area.
"min-" and "max-" prefixes can be used.
Example: media="screen and (min-width:500px)"

<a href="att_a_media.asp?output=print"
media="print and (resolution:300dpi)">
Open media attribute page for print.</a>

Output should be:

How to add HTML <a> media width Attribute

How to add HTML <a> media device-height Attribute

Specifies the height of the target display/paper.
"min-" and "max-" prefixes can be used.
Example: media="screen and (device-height:500px)"

index.html
Example: HTML
<a href="att_a_media.asp?output=print"
media="screen and (device-height:500px)">
Open media attribute page for print.</a>

Output should be:

How to add HTML <a> media device-height Attribute

How to add HTML <a> media orientation Attribute

Specifies the orientation of the target display/paper.
Possible values: "portrait" or "landscape"
Example: media="all and (orientation: landscape)"

index.html
Example: HTML
<a href="att_a_media.asp?output=print"
media="all and (orientation: landscape)">
Open media attribute page for print.</a>

Output should be:

How to add HTML <a> media orientation Attribute

How to add HTML <a> media aspect-ratio Attribute

Specifies the width/height ratio of the targeted display area.
"min-" and "max-" prefixes can be used.
Example: media="screen and (aspect-ratio:16/9)"

index.html
Example: HTML
<a href="att_a_media.asp?output=print"
media="screen and (aspect-ratio:16/9)">
Open media attribute page for print.</a>

Output should be:

How to add HTML <a> media aspect-ratio Attribute

How to add HTML <a> media device-aspect-ratio Attribute

Specifies the device-width/device-height ratio of the target display/paper.
"min-" and "max-" prefixes can be used.
Example: media="screen and (aspect-ratio:16/9)"

index.html
Example: HTML
<a href="att_a_media.asp?output=print"
media="screen and (aspect-ratio:16/9)">
Open media attribute page for print.</a>

Output should be:

How to add HTML <a> media device-aspect-ratio Attribute

How to add HTML <a> media color Attribute

Specifies the bits per color of target display.
"min-" and "max-" prefixes can be used.
Example: media="screen and (color:3)"

index.html
Example: HTML
<a href="att_a_media.asp?output=print"
media="screen and (color:3)">
Open media attribute page for print.</a>

Output should be:

How to add HTML <a> media color Attribute

How to add HTML <a> media color-index Attribute

Specifies the number of colors the target display can handle.
"min-" and "max-" prefixes can be used.
Example: media="screen and (min-color-index:256)"

index.html
Example: HTML
<a href="https://horje.com/view/1367/how-to-add-html-a-media-aspect-ratio-attribute"
media="screen and (min-color-index:256)">
Open media attribute page for print.</a>

Output should be:

How to add HTML <a> media color-index Attribute

How to add HTML <a> media monochrome Attribute

Specifies the bits per pixel in a monochrome frame buffer.
"min-" and "max-" prefixes can be used.
Example: media="screen and (monochrome:2)"

index.html
Example: HTML
<a href="https://horje.com/view/1367/how-to-add-html-a-media-aspect-ratio-attribute"
media="screen and (monochrome:2)">
Open media attribute page for print.</a>

Output should be:

How to add HTML <a> media monochrome Attribute

How to add HTML <a> media resolution Attribute

Specifies the pixel density (dpi or dpcm) of the target display/paper.
"min-" and "max-" prefixes can be used.
Example: media="print and (resolution:300dpi)"

index.html
Example: HTML
<a href="att_a_media.asp?output=print"
media="print and (resolution:300dpi)">
Open media attribute page for print.</a>

Output should be:

How to add HTML <a> media resolution Attribute

How to add HTML <a> media monochrome Attribute

Specifies scanning method of a tv display.
Possible values are "progressive" and "interlace".
Example: media="tv and (scan:interlace)"

index.html
Example: HTML
<a href="att_a_media.asp?output=print"
media="tv and (scan:interlace)">
Open media attribute page for print.</a>

Output should be:

How to add HTML <a> media monochrome Attribute

How to add HTML <a> media grid Attribute

Specifies if the output device is grid or bitmap.
Possible values are "1" for grid, and "0" otherwise.
Example: media="handheld and (grid:1)"

index.html
Example: HTML
<a href="att_a_media.asp?output=print"
media="handheld and (grid:1)">
Open media attribute page for print.</a>

Output should be:

How to add HTML <a> media grid Attribute

How to add HTML <a> ping Attribute

Notify https://horje.com, when a user clicks on the link.

Definition and Usage

The ping attribute specifies a list of URLs to be notified if the user follows the hyperlink.

When the user clicks on the hyperlink, the ping attribute will send a short HTTP POST request to the specified URL.

This attribute is useful for monitoring/tracking.

Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<a ping="URL">

Attribute Values

Value Description
URL Specifies the URL to be notified if the user follows the hyperlink. Must be a space separated list of one or more valid URLs
index.html
Example: HTML
 <a href="https://horje.com/" ping="https://horje.com/"> 

How to add HTML <a> referrerpolicy Attribute

Set the referrerpolicy for a link.

Definition and Usage

The referrerpolicy attribute specifies which referrer information to send when the user clicks on the hyperlin


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<a referrerpolicy="no-referrer|no-referrer-when-downgrade|origin|origin-when-cross-origin|same-origin|strict-origin-when-cross-origin|unsafe-url">

Attribute Values

Value Description
no-referrer No referrer information is sent
no-referrer-when-downgrade Default. Sends the origin, path, and query string if the protocol security level stays the same or is higher (HTTP to HTTP, HTTPS to HTTPS, HTTP to HTTPS is ok). Sends nothing to less secure level (HTTPS to HTTP is not ok)
origin Sends the origin (scheme, host, and port) of the document
origin-when-cross-origin Sends the origin of the document for cross-origin request. Sends the origin, path, and query string for same-origin request
same-origin Sends a referrer for same-origin request. Sends no referrer for cross-origin request
strict-origin-when-cross-origin Sends the origin if the protocol security level stays the same or is higher (HTTP to HTTP, HTTPS to HTTPS, and HTTP to HTTPS is ok). Sends nothing to less secure level (HTTPS to HTTP)
unsafe-url Sends the origin, path, and query string (regardless of security). Use this value carefully!
index.html
Example: HTML
<a href="https://horje.com/" referrerpolicy="origin">WWE</a>

Output should be:

How to add HTML <a> referrerpolicy Attribute

How to add HTML <a> referrerpolicy no-referrer Attribute

no-referrer No referrer information is sent
index.html
Example: HTML
<a href="https://horje.com/" referrerpolicy="no-referrer">Open A Link</a>

Output should be:

How to add HTML <a> referrerpolicy no-referrer Attribute

How to add HTML <a> Tag referrerpolicy no-referrer-when-downgrade Attribute

Default. Sends the origin, path, and query string if the protocol security level stays the same or is higher (HTTP to HTTP, HTTPS to HTTPS, HTTP to HTTPS is ok). Sends nothing to less secure level (HTTPS to HTTP is not ok)

index.html
Example: HTML
<a href="https://horje.com/" referrerpolicy="no-referrer-when-downgrade">Open a Link</a>

Output should be:

How to add HTML <a> Tag referrerpolicy no-referrer-when-downgrade Attribute

How to add HTML <a> Tag referrerpolicy origin Attribute

Sends the origin (scheme, host, and port) of the document

index.html
Example: HTML
<a href="https://horje.com/" referrerpolicy="origin">Open a Link</a>

Output should be:

How to add HTML <a> Tag referrerpolicy origin Attribute

How to add HTML <a> Tag referrerpolicy origin-when-cross-origin Attribute

Sends the origin of the document for cross-origin request. Sends the origin, path, and query string for same-origin request.

index.html
Example: HTML
<a href="https://horje.com/" referrerpolicy="origin-when-cross-origin">Open a Link</a>

Output should be:

How to add HTML <a> Tag referrerpolicy origin-when-cross-origin Attribute

How to add HTML <a> Tag referrerpolicy same-origin Attribute

Sends a referrer for same-origin request. Sends no referrer for cross-origin request.

index.html
Example: HTML
<a href="https://horje.com/" referrerpolicy="same-origin">Open a Link</a>

Output should be:

How to add HTML <a> Tag referrerpolicy same-origin Attribute

How to add HTML <a> Tag referrerpolicy strict-origin-when-cross-origin Attribute

Sends the origin if the protocol security level stays the same or is higher (HTTP to HTTP, HTTPS to HTTPS, and HTTP to HTTPS is ok). Sends nothing to less secure level (HTTPS to HTTP).

index.html
Example: HTML
<a href="https://horje.com/" referrerpolicy="strict-origin-when-cross-origin">Open a Link</a>

Output should be:

How to add HTML <a> Tag referrerpolicy strict-origin-when-cross-origin Attribute

How to add HTML <a> Tag referrerpolicy unsafe-url Attribute

Sends the origin, path, and query string (regardless of security). Use this value carefully!

index.html
Example: HTML
<a href="https://horje.com/" referrerpolicy="unsafe-url">Open a Link</a>

Output should be:

How to add HTML <a> Tag referrerpolicy unsafe-url Attribute

How to add HTML <a> rel Attribute

A link with a rel attribute.

Definition and Usage

The rel attribute specifies the relationship between the current document and the linked document.

Only used if the href attribute is present.

Tip: Search engines can use this attribute to get more information about a link!

Syntax

<a rel="value">

Attribute Values

Value Description
alternate Provides a link to an alternate representation of the document (i.e. print page, translated or mirror)
author Provides a link to the author of the document
bookmark Permanent URL used for bookmarking
external Indicates that the referenced document is not part of the same site as the current document
help Provides a link to a help document
license Provides a link to licensing information for the document
next Provides a link to the next document in the series
nofollow Links to an unendorsed document, like a paid link.
("nofollow" is used by Google, to specify that the Google search spider should not follow that link)
noopener Requires that any browsing context created by following the hyperlink must not have an opener browsing context
noreferrer Makes the referrer unknown. No referer header will be included when the user clicks the hyperlink
prev The previous document in a selection
search Links to a search tool for the document
tag A tag (keyword) for the current document
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The a rel attribute</h1>

<p><a rel="nofollow" href="https://horje.com/">Horje.com</a></p>

</body>
</html>

Output should be:

How to add HTML <a> rel Attribute

How to use HTML <a>Tag rel alternate Attribute

Provides a link to an alternate representation of the document (i.e. print page, translated or mirror).

index.html
Example: HTML
<a rel="alternate" href="https://horje.com">Horje.com</a>

Output should be:

How to use HTML <a>Tag rel alternate Attribute

How to use HTML <a>Tag rel author Attribute

Provides a link to the author of the document.

index.html
Example: HTML
<a rel="author" href="https://horje.com">Horje.com</a>

Output should be:

How to use HTML <a>Tag rel author Attribute

How to use HTML <a>Tag rel bookmark Attribute

Permanent URL used for bookmarking.

index.html
Example: HTML
<a rel="bookmark" href="https://horje.com">Horje.com</a>

Output should be:

How to use HTML <a>Tag rel bookmark Attribute

How to use HTML <a>Tag rel external Attribute

Indicates that the referenced document is not part of the same site as the current document.

index.html
Example: HTML
<a rel="external" href="https://horje.com">Horje.com</a>

Output should be:

How to use HTML <a>Tag rel external Attribute

How to use HTML <a>Tag rel help Attribute

Provides a link to a help document.

index.html
Example: HTML
<a rel="help" href="https://horje.com">Horje.com</a>

Output should be:

How to use HTML <a>Tag rel help Attribute

How to use HTML <a>Tag rel license Attribute

Provides a link to licensing information for the document.

index.html
Example: HTML
<a rel="license" href="https://horje.com/">Horje.com</a>

Output should be:

How to use HTML <a>Tag rel license Attribute

How to use HTML <a>Tag rel next Attribute

Provides a link to the next document in the series.

index.html
Example: HTML
<a rel="next" href="https://horje.com/">Horje.com</a>

Output should be:

How to use HTML <a>Tag rel next Attribute

How to use HTML <a>Tag rel nofollow Attribute

Links to an unendorsed document, like a paid link.
("nofollow" is used by Google, to specify that the Google search spider should not follow that link)

index.html
Example: HTML
<a rel="nofollow" href="https://horje.com/">Horje.com</a>

Output should be:

How to use HTML <a>Tag rel nofollow Attribute

How to use HTML <a>Tag rel noopener Attribute

Requires that any browsing context created by following the hyperlink must not have an opener browsing context.

index.html
Example: HTML
<a rel="noopener" href="https://horje.com/">Horje.com</a>

Output should be:

How to use HTML <a>Tag rel noopener Attribute

How to use HTML <a>Tag rel noreferrer Attribute

Makes the referrer unknown. No referer header will be included when the user clicks the hyperlink.

index.html
Example: HTML
<a rel="noreferrer" href="https://horje.com/">Horje.com</a>

Output should be:

How to use HTML <a>Tag rel noreferrer Attribute

How to use HTML <a>Tag rel prev Attribute

The previous document in a selection.

index.html
Example: HTML
<a rel="prev" href="https://horje.com/">Horje.com</a>

Output should be:

How to use HTML <a>Tag rel prev Attribute

How to use HTML <a>Tag rel search Attribute

Links to a search tool for the document.

index.html
Example: HTML
<a rel="search" href="https://horje.com/">Horje.com</a>

Output should be:

How to use HTML <a>Tag rel search Attribute

How to use HTML <a>Tag rel tag Attribute

A tag (keyword) for the current document.

index.html
Example: HTML
<a rel="tag" href="https://horje.com/">Horje.com</a>

Output should be:

How to use HTML <a>Tag rel tag Attribute

How to create HTML <a> target Attribute

The target attribute specifies where to open the linked document.

Definition and Usage

The target attribute specifies where to open the linked document.

Browser Support

Syntax

<a target="_blank|_self|_parent|_top|framename">

Attribute Values

Value Description
_blank Opens the linked document in a new window or tab
_self Opens the linked document in the same frame as it was clicked (this is default)
_parent Opens the linked document in the parent frame
_top Opens the linked document in the full body of the window
framename Opens the linked document in the named iframe
index.html
<!DOCTYPE html>
<html>
<body>

<h1>The a target attribute</h1>

<p>Open link in a new window or tab: <a href="https://horje.com" target="_blank">Visit Horje!</a></p>

</body>
</html>

Output should be:

How to create HTML <a> target Attribute

How to add HTML <a> target _blank Attribute

Opens the linked document in a new window or tab.

index.html
Example: HTML
<a href="https://horje.com" target="_blank">Visit Horje!</a>

Output should be:

How to add HTML <a> target _blank Attribute

How to add HTML <a> target _self Attribute

Opens the linked document in the same frame as it was clicked (this is default).

index.html
Example: HTML
<a href="https://horje.com" target="_self">Visit Horje!</a>

Output should be:

How to add HTML <a> target _self Attribute

How to add HTML <a> target _parent Attribute

Opens the linked document in the parent frame.

index.html
Example: HTML
<a href="https://horje.com" target="_parent">Visit Horje!</a>

Output should be:

How to add HTML <a> target _parent Attribute

How to add HTML <a> target _top Attribute

Opens the linked document in the full body of the window.

index.html
Example: HTML
<a href="https://horje.com" target="_top">Visit Horje!</a>

Output should be:

How to add HTML <a> target _top Attribute

How to add HTML <a> target framename Attribute

Opens the linked document in the named iframe.

index.html
Example: HTML
<a href="https://horje.com" target="framename">Visit Horje!</a>

Output should be:

How to add HTML <a> target framename Attribute

How to create HTML <a> type Attribute

The type attribute specifies the media type of the linked document:.

Definition and Usage

The type attribute specifies the Internet media type (formerly known as MIME type) of the linked document.

This attribute is only used if the href attribute is set.

Note: This attribute is purely advisory.

Browser Support

Syntax

<a type="media_type">

Attribute Values

Value Description
media_type The Internet media type of the linked document.
Look at IANA Media Types for a complete list of standard media types.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The a type attribute</h1>

<p>
<a href="https://horje.com" type="text/html">Horje.com</a>
</p>

</body>
</html>

Output should be:

How to create HTML <a> type Attribute

# Tips-5) What is HTML <abbr> Tag

The <abbr> tag defines an abbreviation or an acronym, like "HTML", "CSS", "Mr.", "Dr.", "ASAP", "ATM".

Tip: Use the global title attribute to show the description for the abbreviation/acronym when you mouse over the element.

An abbreviation is marked up as follows

index.html
Example: HTML
<p>The <abbr title="World Health Organization">WHO</abbr> was founded in 1948.</p>

Output should be:

An abbreviation is marked up as follows

What types of Browsers will Support <abbr> Tag

Output should be:

What types of Browsers will Support <abbr> Tag

<abbr> can also be used with <dfn> to define an abbreviation

Follow the Example
index.html
Example: HTML
<p><dfn><abbr title="Cascading Style Sheets">CSS</abbr>
</dfn> is a language that describes the style of an HTML document.</p>

Output should be:

<abbr> can also be used with <dfn> to define an abbreviation

Default CSS Settings for <abbr> Tag

Most browsers will display the <abbr> element with the following default values:

index.html
Example: HTML
<style>
abbr { 
  display: inline;
} 
</style>
<p><abbr title="Hyper Text Markup Language">HTML</abbr> describes the structure of Web pages using markup.</p>

Output should be:

Default CSS Settings for <abbr> Tag

# Tips-6) What is HTML <acronym> Tag

The tag was used in HTML 4 to define an acronym.

Not Supported in HTML5.

 

What to Use Instead of HTML <acronym> Tag?

<!DOCTYPE html>
<html>
<body>

<h1>The abbr element</h1>

<p>The <abbr title="World Health Organization">WHO</abbr> was founded in 1948.</p>

</body>
</html>

Output should be:

What to Use Instead of HTML <acronym> Tag?

# Tips-7) What is HTML <address> Tag

The <address> tag defines the contact information for the author/owner of a document or an article.

The contact information can be an email address, URL, physical address, phone number, social media handle, etc.

The text in the <address> element usually renders in italic, and browsers will always add a line break before and after the <address> element.


HTML Contact information for HTML <address> Tag

Follow the Example
Example: HTML
<address>
Written by <a href="mailto:[email protected]">Jon Doe</a>.<br> 
Visit us at:<br>
Example.com<br>
Box 564, Disneyland<br>
USA
</address>

Output should be:

HTML Contact information for HTML <address> Tag

Browser Support for HTML <address> Tag

Output should be:

Browser Support for HTML <address> Tag

Default CSS Settings for <address> Tag

Change the default CSS settings to see the effect. An address element is displayed like this:
index.html
Example: HTML
<style>
address { 
  display: block;
  font-style: italic;
} 
</style>
<p>An address element is displayed like this:</p>
<address>
Written by <a href="mailto:[email protected]">Jon Doe</a>.<br> 
Visit us at:<br>
Example.com<br>
Box 564, Disneyland<br>
USA
</address>

Output should be:

Default CSS Settings for <address> Tag

# Tips-8) What is HTML <applet> Tag

Not Supported in HTML5.

The tag was used in HTML 4 to define an embedded applet (Plug-in).

Plug-ins for HTML <applet> Tag

Plug-ins are a computer programs that extend the standard functionality of the browser.

Plug-ins have been used for many different purposes:

Most browsers no longer support Java Applets and Plug-ins.

ActiveX controls are no longer supported in any browsers.

The support for Shockwave Flash has also been turned off in modern browsers.

What to Use Instead of HTML <applet> Tag?

You can use following tags instead of HTMLTag.
<video> <audio> <embed> <object>

Use <video> Tag Instead of HTML <applet> Tag

If you want to embed a video, use the <video> tag:

index.html
Example: HTML
 <video width="320" height="240" controls>
  <source src="https://www.w3schools.com/tags/movie.mp4" type="video/mp4">
  <source src="https://www.w3schools.com/tags/movie.mp4" type="video/ogg">
  Your browser does not support the video tag.
</video> 

Output should be:

Use <video> Tag Instead of HTML <applet> Tag

How to Use <audio> Tag Instead of HTML <applet> Tag

If you want to embed audio, use the <audio> tag:

index.html
Example: HTML
<audio controls>
  <source src="https://www.w3schools.com/tags/horse.ogg" type="audio/ogg">
  <source src="https://www.w3schools.com/tags/horse.ogg" type="audio/mpeg">
  Your browser does not support the audio element.
</audio>

Output should be:

How to Use <audio> Tag Instead of HTML <applet> Tag

How to Use <embed> Tag Instead of HTML <applet> Tag

To embed objects, you can use both the <embed> tag and the <object> tags:

Embed a document with the <embed> element:

 

index.html
Example: HTML
 <embed src="https://horje.com/avatar.png"> 

How to Use <object> Tag Instead of HTML <applet> Tag

To object you can use <object> tags:

index.html
Example: HTML
<object data="https://horje.com/avatar.png" width="300" height="200"></object>

Output should be:

How to Use <object> Tag Instead of HTML <applet> Tag

# Tips-9) What is HTML <area> Tag

An image map, with clickable areas:

The <area> tag defines an area inside an image map (an image map is an image with clickable areas).

<area> elements are always nested inside a <map> tag.

Note: The usemap attribute in <img> is associated with the <map> element's name attribute, and creates a relationship between the image and the map.

How to create HTML <area> Tag

An image map, with clickable areas:

index.html
Example: HTML
<img src="https://horje.com/avatar.png" alt="Workplace" usemap="#workmap" width="400" height="379">

<map name="workmap">
  <area shape="rect" coords="34,44,270,350" alt="Computer" href="computer.htm">
  <area shape="rect" coords="290,172,333,250" alt="Phone" href="phone.htm">
  <area shape="circle" coords="337,300,44" alt="Cup of coffee" href="coffee.htm">
</map>

Browser Support for HTML <area> Tag

Output should be:

Browser Support for HTML <area> Tag

Attributes for HTML <area> Tag

Attribute Value Description
alt text Specifies an alternate text for the area. Required if the href attribute is present
coords coordinates Specifies the coordinates of the area
download filename Specifies that the target will be downloaded when a user clicks on the hyperlink
href URL Specifies the hyperlink target for the area
hreflang language_code Specifies the language of the target URL
media media query Specifies what media/device the target URL is optimized for
referrerpolicy no-referrer
no-referrer-when-downgrade
origin
origin-when-cross-origin
same-origin
strict-origin-when-cross-origin
unsafe-url
Specifies which referrer information to send with the link
rel alternate
author
bookmark
help
license
next
nofollow
noreferrer
prefetch
prev
search
tag
Specifies the relationship between the current document and the target URL
shape default
rect
circle
poly
Specifies the shape of the area
target _blank
_parent
_self
_top
framename
Specifies where to open the target URL
type media_type Specifies the media type of the target URL

Another image map, with clickable areas for HTML <area> Tag

index.html
Example: HTML
<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com/learn/629/what-is-html-applet-tag">
  <area shape="circle" coords="90,58,3" alt="Mercury" href="https://horje.com/learn/628/what-is-html-address-tag">
  <area shape="circle" coords="124,58,8" alt="Venus" href="https://horje.com/learn/627/what-is-html-acronym-tag">
</map>

Output should be:

Another image map, with clickable areas for HTML <area> Tag

How to set Default CSS Settings for HTML <area> Tag

Most browsers will display the <area> element with the following default values: Click on the sun or on one of the planets to watch it closer:
index.html
Example: HTML
<style>
area {
  display: none;
}
</style>

Output should be:

How to set Default CSS Settings for HTML <area> Tag

How to add HTML <area> alt Attribute

Use the alt attribute to specify an alternate text for each area in the image map.

Definition and Usage

The alt attribute specifies an alternate text for an area, if the image cannot be displayed.

The alt attribute provides alternative information for an image if a user for some reason cannot view it (because of slow connection, an error in the src attribute, or if the user uses a screen reader).

The alt attribute is required if the href attribute is present.

Browser Support

Syntax

<area alt="text">

Attribute Values

Value Description
text Specifies the alternate text for the area, if the image cannot be displayed
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area alt attribute</h1>

<p>Click on the sun or on one of the planets to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com/learn/630/what-is-html-area-tag">
  <area shape="circle" coords="90,58,3" alt="Mercury" href="https://horje.com/learn/630/what-is-html-area-tag">
  <area shape="circle" coords="124,58,8" alt="Venus" href="https://horje.com/learn/630/what-is-html-area-tag">
</map>

</body>
</html>

Output should be:

How to add HTML <area> alt Attribute

How to add HTML <area> coords Attribute

Use the coords attribute to specify the coordinates of each area in the image map.

Definition and Usage

The coords attribute specifies the coordinates of an area in an image map.

The coords attribute is used together with the shape attribute to specify the size, shape, and placement of an area.

Tip: The coordinates of the top-left corner of an area are 0,0.

Browser Support

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area coords attribute</h1>

<p>Click on the sun or on one of the planets to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map id="planetmap" name="planetmap">
<area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com">
<area shape="circle" coords="90,58,3" alt="Mercury" href="https://horje.com/avatar.png">
<area shape="circle" coords="124,58,8" alt="Venus" href="https://horje.com">
</map>

</body>
</html>

Output should be:

How to add HTML <area> coords Attribute

How to add HTML <area> coords x1,y1,x2,y2 Attribute

Specifies the coordinates of the top-left and bottom-right corner of the rectangle (shape="rect").

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area coords attribute</h1>

<p>Click on the sun or on one of the planets to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map id="planetmap" name="planetmap">
<area shape="rect" coords="x1,y1,x2,y2" alt="Sun" href="https://horje.com">
</map>

</body>
</html>

Output should be:

How to add HTML <area> coords x1,y1,x2,y2 Attribute

How to add HTML <area> coords x,y,radius Attribute

Specifies the coordinates of the circle center and the radius (shape="circle").

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area coords attribute</h1>

<p>Click on the sun or on one of the planets to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map id="planetmap" name="planetmap">
<area shape="rect" coords="x,y,radius" alt="Sun" href="https://horje.com">
</map>

</body>
</html>

Output should be:

How to add HTML <area> coords x,y,radius Attribute

How to add HTML <area> download Attribute

Use the download attribute to specify that the target will be downloaded when a user clicks on the hyperlink:

Definition and Usage

The download attribute specifies that the target (the file specified in the href attribute) will be downloaded when a user clicks on the hyperlink.

The optional value of the download attribute will be the new name of the file after it is downloaded. There are no restrictions on allowed values, and the browser will automatically detect the correct file extension and add it to the file (.img, .pdf, .txt, .html, etc.).

If the value is omitted, the original filename is used.

Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

* Chrome 65+ and Firefox only support same-origin download links.

Syntax

<area download="filename">

Attribute Values

Value Description
filename Optional. Specifies the new filename for the downloaded file

 

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area download attribute</h1>

<p>Click on the sun or on one of the planets to download its content.</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com/avatar.png" download>
  <area shape="circle" coords="90,58,3" alt="Mercury" href="https://horje.com/avatar.png" download>
  <area shape="circle" coords="124,58,8" alt="Venus" href="https://horje.com/avatar.png" download>
</map>

<p><b>Note:</b> The download attribute is not supported in IE, Safari or Opera version 12 (and earlier).</p>

</body>
</html>

Output should be:

How to add HTML <area> download Attribute

How to Specify a value for the download attribute HTML <area> download Attribute

Specify a value for the download attribute, which will be the new filename of the downloaded file (sun.htm instead of information_about_the_sun.htm and so on):

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area download attribute</h1>

<p>Click on the sun or on one of the planets to download its content.</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com" download="sun">
  <area shape="circle" coords="90,58,3" alt="Mercury" href="https://horje.com/avatar.png" download="mercury">
  <area shape="circle" coords="124,58,8" alt="Venus" href="https://horje.com/avatar.png" download="venus">
</map>

<p>Notice that the filename of the downloaded file will be saved as "sun.htm" instead of "information_about_the_sun.htm" for the sun area, "mercury.gif" instead of "merglobe.gif" for the mercury area and "venus.txt" instead of "information_about_the_planet_venus.txt" for the venus area.</p>
<p><b>Note:</b> The download attribute is not supported in IE, Safari or Opera version 12 (and earlier).</p>

</body>
</html>

Output should be:

How to Specify a value for the download attribute HTML <area> download Attribute

How to add HTML <area> href Attribute

Use the href attribute to specify the link target for each area in the image map:

Definition and Usage

The href attribute specifies the hyperlink target for the area.

If the href attribute is not present, the <area> tag is not a hyperlink.

Browser Support

Syntax

<area href="URL">

Attribute Values

Value Description
URL Specifies the hyperlink target for the area.

Possible values:

  • An absolute URL - points to another web site (like href="http://www.example.com/sun.htm")
  • A relative URL - points to a file within a web site (like href="sun.htm")
  • Link to an element with a specified id within the page (like href="#top")
  • Other protocols (like https://, ftp://, mailto:, file:, etc..)
  • A script (like href="javascript:alert('Hello');")
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area href attribute</h1>

<p>Click on the sun or on one of the planets to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map id="planetmap" name="planetmap">
<area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com/avatar.png">
<area shape="circle" coords="90,58,3" alt="Mercury" href="https://horje.com/avatar.png">
<area shape="circle" coords="124,58,8" alt="Venus" href="https://horje.com/avatar.png">
</map>

</body>
</html>

Output should be:

How to add HTML <area> href Attribute

How to add HTML <area> hreflang Attribute

Use the hreflang attribute to specify the language of the target URL for each area in the image map:

Definition and Usage

The hreflang attribute specifies the language of the target URL in the area.

This attribute is only used if the href attribute is set.

Note: This attribute is purely advisory.

Browser Support

Syntax

<area hreflang="language_code">

Attribute Values

Value Description
language_code A two-letter language code that specifies the language of the linked document.
To view all available language codes, go to our Language code reference.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area hreflang attribute</h1>

<p>Click on the sun to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com" hreflang="en">
</map>

</body>
</html>

Output should be:

How to add HTML <area> hreflang Attribute

How to add HTML <area> media Attribute

Use the media attribute to specify what media/device the target URL is optimized for:

Definition and Usage

The media attribute specifies what media/device the target URL is optimized for.

This attribute is used to specify that the URL is designed for special devices (like iPhone), speech or print media.

This attribute can accept several values.

Only used if the href attribute is present.

Note: This attribute is purely advisory.

Browser Support

Syntax

<area media="value">

 

Possible Operators

Value Description
and Specifies an AND operator
not Specifies a NOT operator
, Specifies an OR operator

Devices

Value Description
all Default. Suitable for all devices
aural Speech synthesizers
braille Braille feedback devices
handheld Handheld devices (small screen, limited bandwidth)
projection Projectors
print Print preview mode/printed pages
screen Computer screens
tty Teletypes and similar media using a fixed-pitch character grid
tv Television type devices (low resolution, limited scroll ability)

Values

Value Description
width Specifies the width of the targeted display area.
"min-" and "max-" prefixes can be used.
Example: media="screen and (min-width:500px)"
height Specifies the height of the  targeted display area. "min-" and "max-" prefixes can be used.
Example: media="screen and (max-height:700px)"
device-width Specifies the width of the target display/paper.
"min-" and "max-" prefixes can be used.
Example: media="screen and (device-width:500px)"
device-height Specifies the height of the target display/paper.
"min-" and "max-" prefixes can be used.
Example: media="screen and (device-height:500px)"
orientation Specifies the orientation of the target display/paper.
Possible values: "portrait" or "landscape"
Example: media="all and (orientation: landscape)"
aspect-ratio Specifies the width/height ratio of the targeted display area.
"min-" and "max-" prefixes can be used.
Example: media="screen and (aspect-ratio:16/9)"
device-aspect-ratio Specifies the device-width/device-height ratio of the target display/paper.
"min-" and "max-" prefixes can be used.
Example: media="screen and (aspect-ratio:16/9)"
color Specifies the bits per color of target display.
"min-" and "max-" prefixes can be used.
Example: media="screen and (color:3)"
color-index Specifies the number of colors the target display can handle.
"min-" and "max-" prefixes can be used.
Example: media="screen and (min-color-index:256)"
monochrome Specifies the bits per pixel in a monochrome frame buffer.
"min-" and "max-" prefixes can be used.
Example: media="screen and (monochrome:2)"
resolution Specifies the pixel density (dpi or dpcm) of the target display/paper.
"min-" and "max-" prefixes can be used.
Example: media="print and (resolution:300dpi)"
scan Specifies scanning method of a tv display.
Possible values are "progressive" and "interlace".
Example: media="tv and (scan:interlace)"
grid Specifies if the output device is grid or bitmap.
Possible values are "1" for grid, and "0" otherwise.
Example: media="handheld and (grid:1)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area media attribute</h1>

<p>Click on the sun to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com" media="screen and (min-color-index:256)">
</map>

</body>
</html>

Output should be:

How to add HTML <area> media Attribute

How to add HTML <area> media width Attribute

width Specifies the width of the targeted display area.
"min-" and "max-" prefixes can be used.
Example: media="screen and (min-width:500px)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area media width attribute</h1>

<p>Click on the sun to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com/avatar.png" media="screen and (min-width:500px)">
</map>

</body>
</html>

Output should be:

How to add HTML <area> media width Attribute

How to add HTML <area> media height Attribute

height Specifies the height of the  targeted display area. "min-" and "max-" prefixes can be used.
Example: media="screen and (max-height:700px)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area media height attribute</h1>

<p>Click on the sun to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com" media="screen and (max-height:700px)">
</map>

</body>
</html>

Output should be:

How to add HTML <area> media height Attribute

How to add HTML <area> media device-width Attribute

device-width Specifies the width of the target display/paper.
"min-" and "max-" prefixes can be used.
Example: media="screen and (device-width:500px)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area media device-width attribute</h1>

<p>Click on the sun to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com" media="screen and (device-width:500px)">
</map>

</body>
</html>

Output should be:

How to add HTML <area> media device-width Attribute

How to add HTML <area> media device-height Attribute

device-height Specifies the height of the target display/paper.
"min-" and "max-" prefixes can be used.
Example: media="screen and (device-height:500px)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area media device-height attribute</h1>

<p>Click on the sun to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com" media="screen and (device-height:500px)">
</map>

</body>
</html>

Output should be:

How to add HTML <area> media device-height Attribute

How to add HTML <area> media orientation Attribute

orientation Specifies the orientation of the target display/paper.
Possible values: "portrait" or "landscape"
Example: media="all and (orientation: landscape)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area media orientation attribute</h1>

<p>Click on the sun to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com" media="all and (orientation: landscape)">
</map>

</body>
</html>

Output should be:

How to add HTML <area> media orientation Attribute

How to add HTML <area> media aspect-ratio Attribute

aspect-ratio Specifies the width/height ratio of the targeted display area.
"min-" and "max-" prefixes can be used.
Example: media="screen and (aspect-ratio:16/9)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area media aspect-ratio attribute</h1>

<p>Click on the sun to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com" media="screen and (aspect-ratio:16/9)">
</map>

</body>
</html>

Output should be:

How to add HTML <area> media aspect-ratio Attribute

How to add HTML <area> media device-aspect-ratio Attribute

device-aspect-ratio Specifies the device-width/device-height ratio of the target display/paper.
"min-" and "max-" prefixes can be used.
Example: media="screen and (aspect-ratio:16/9)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area media device-aspect-ratio attribute</h1>

<p>Click on the sun to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com" media="screen and (aspect-ratio:16/9)">
</map>

</body>
</html>

Output should be:

How to add HTML <area> media device-aspect-ratio Attribute

How to add HTML <area> media color Attribute

color Specifies the bits per color of target display.
"min-" and "max-" prefixes can be used.
Example: media="screen and (color:3)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area media color attribute</h1>

<p>Click on the sun to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com" media="screen and (color:3)">
</map>

</body>
</html>

Output should be:

How to add HTML <area> media color Attribute

How to add HTML <area> media color-index Attribute

color-index Specifies the number of colors the target display can handle.
"min-" and "max-" prefixes can be used.
Example: media="screen and (min-color-index:256)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area media color-index attribute</h1>

<p>Click on the sun to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com" media="screen and (min-color-index:256)">
</map>

</body>
</html>

Output should be:

How to add HTML <area> media color-index Attribute

How to add HTML <area> media monochrome Attribute

monochrome Specifies the bits per pixel in a monochrome frame buffer.
"min-" and "max-" prefixes can be used.
Example: media="screen and (monochrome:2)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area media monochrome attribute</h1>

<p>Click on the sun to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com" media="screen and (monochrome:2)">
</map>

</body>
</html>

Output should be:

How to add HTML <area> media monochrome Attribute

How to add HTML <area> media resolution Attribute

resolution Specifies the pixel density (dpi or dpcm) of the target display/paper.
"min-" and "max-" prefixes can be used.
Example: media="print and (resolution:300dpi)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area media resolution attribute</h1>

<p>Click on the sun to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com" media="print and (resolution:300dpi)">
</map>

</body>
</html>

Output should be:

How to add HTML <area> media resolution Attribute

How to add HTML <area> media scan Attribute

scan Specifies scanning method of a tv display.
Possible values are "progressive" and "interlace".
Example: media="tv and (scan:interlace)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area media scan attribute</h1>

<p>Click on the sun to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com" media="tv and (scan:interlace)">
</map>

</body>
</html>

Output should be:

How to add HTML <area> media scan Attribute

How to add HTML <area> media grid Attribute

grid Specifies if the output device is grid or bitmap.
Possible values are "1" for grid, and "0" otherwise.
Example: media="handheld and (grid:1)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area media grid attribute</h1>

<p>Click on the sun to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com" media="handheld and (grid:1)">
</map>

</body>
</html>

Output should be:

How to add HTML <area> media grid Attribute

How to add HTML <area> referrerpolicy Attribute

Set the referrerpolicy attribute for the area hyperlinks.

Definition and Usage

The referrerpolicy attribute specifies which referrer information to send when the user clicks on the hyperlink.

Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<area referrerpolicy="no-referrer|no-referrer-when-downgrade|origin|origin-when-cross-origin|same-origin|strict-origin-when-cross-origin|unsafe-url">

Attribute Values

Value Description
no-referrer No referrer information is sent
no-referrer-when-downgrade Default. Sends the origin, path, and query string if the protocol security level stays the same or is higher (HTTP to HTTP, HTTPS to HTTPS, HTTP to HTTPS is ok). Sends nothing to less secure level (HTTPS to HTTP is not ok)
origin Sends the origin (scheme, host, and port) of the document
origin-when-cross-origin Sends the origin of the document for cross-origin request. Sends the origin, path, and query string for same-origin request
same-origin Sends a referrer for same-origin request. Sends no referrer for cross-origin request
strict-origin-when-cross-origin Sends the origin if the protocol security level stays the same or is higher (HTTP to HTTP, HTTPS to HTTPS, and HTTP to HTTPS is ok). Sends nothing to less secure level (HTTPS to HTTP)
unsafe-url Sends the origin, path, and query string (regardless of security). Use this value carefully!
index.html
Example: HTML
<img src="https://horje.com/uploads/demo/2024-02-19-15-51-41-area11.png"
        alt="" width="300" height="119"
        class="aligncenter size-medium wp-image-910965"
        usemap="#shapemap" />
 
    <map name="shapemap">
        <!-- area tag contained image. -->
        <area shape="poly"
            coords="59,31,28,83,91,83"
            href="https://horje.com/uploads/demo/2024-02-19-15-52-16-area2.png"
            alt="Triangle" referrerpolicy="same-origin">
         

    </map>

Output should be:

How to add HTML <area> referrerpolicy Attribute

How to add HTML <area> referrerpolicy no-referrer Attribute

no-referrer No referrer information is sent
index.html
Example: HTML
<img src="https://horje.com/uploads/demo/2024-02-19-15-51-41-area11.png"
alt="" width="300" height="119"
class="aligncenter size-medium wp-image-910965"
usemap="#shapemap" />
<map name="shapemap">
<!-- area tag contained image. -->
<area shape="poly"
coords="59,31,28,83,91,83"
href="https://horje.com/uploads/demo/2024-02-19-15-52-16-area2.png"
alt="Triangle" referrerpolicy="no-referrer">
</map>

Output should be:

How to add HTML <area> referrerpolicy no-referrer Attribute

How to add HTML <area> referrerpolicy no-referrer-when-downgrade Attribute

no-referrer-when-downgrade Default. Sends the origin, path, and query string if the protocol security level stays the same or is higher (HTTP to HTTP, HTTPS to HTTPS, HTTP to HTTPS is ok). Sends nothing to less secure level (HTTPS to HTTP is not ok)
index.html
Example: HTML
<img src="https://horje.com/uploads/demo/2024-02-19-15-51-41-area11.png"
alt="" width="300" height="119"
class="aligncenter size-medium wp-image-910965"
usemap="#shapemap" />
<map name="shapemap">
<!-- area tag contained image. -->
<area shape="poly"
coords="59,31,28,83,91,83"
href="https://horje.com/uploads/demo/2024-02-19-15-52-16-area2.png"
alt="Triangle" referrerpolicy="no-referrer-when-downgrade">
</map>

Output should be:

How to add HTML <area> referrerpolicy no-referrer-when-downgrade Attribute

How to add HTML <area> referrerpolicy origin Attribute

origin Sends the origin (scheme, host, and port) of the document
index.html
Example: HTML
<img src="https://horje.com/uploads/demo/2024-02-19-15-51-41-area11.png"
alt="" width="300" height="119"
class="aligncenter size-medium wp-image-910965"
usemap="#shapemap" />
<map name="shapemap">
<!-- area tag contained image. -->
<area shape="poly"
coords="59,31,28,83,91,83"
href="https://horje.com/uploads/demo/2024-02-19-15-52-16-area2.png"
alt="Triangle" referrerpolicy="origin">
</map>

Output should be:

How to add HTML <area> referrerpolicy origin Attribute

How to add HTML <area> referrerpolicy origin-when-cross-origin Attribute

origin-when-cross-origin Sends the origin of the document for cross-origin request. Sends the origin, path, and query string for same-origin request
index.html
Example: HTML
<img src="https://horje.com/uploads/demo/2024-02-19-15-51-41-area11.png"
alt="" width="300" height="119"
class="aligncenter size-medium wp-image-910965"
usemap="#shapemap" />
<map name="shapemap">
<!-- area tag contained image. -->
<area shape="poly"
coords="59,31,28,83,91,83"
href="https://horje.com/uploads/demo/2024-02-19-15-52-16-area2.png"
alt="Triangle" referrerpolicy="origin-when-cross-origin">
</map>

Output should be:

How to add HTML <area> referrerpolicy origin-when-cross-origin Attribute

How to add HTML <area> referrerpolicy same-origin Attribute

same-origin Sends a referrer for same-origin request. Sends no referrer for cross-origin request
index.html
Example: HTML
<img src="https://horje.com/uploads/demo/2024-02-19-15-51-41-area11.png"
alt="" width="300" height="119"
class="aligncenter size-medium wp-image-910965"
usemap="#shapemap" />
<map name="shapemap">
<!-- area tag contained image. -->
<area shape="poly"
coords="59,31,28,83,91,83"
href="https://horje.com/uploads/demo/2024-02-19-15-52-16-area2.png"
alt="Triangle" referrerpolicy="same-origin">
</map>

Output should be:

How to add HTML <area> referrerpolicy same-origin Attribute

How to add HTML <area> referrerpolicy strict-origin-when-cross-origin Attribute

strict-origin-when-cross-origin Sends the origin if the protocol security level stays the same or is higher (HTTP to HTTP, HTTPS to HTTPS, and HTTP to HTTPS is ok). Sends nothing to less secure level (HTTPS to HTTP)
index.html
Example: HTML
<img src="https://horje.com/uploads/demo/2024-02-19-15-51-41-area11.png"
alt="" width="300" height="119"
class="aligncenter size-medium wp-image-910965"
usemap="#shapemap" />
<map name="shapemap">
<!-- area tag contained image. -->
<area shape="poly"
coords="59,31,28,83,91,83"
href="https://horje.com/uploads/demo/2024-02-19-15-52-16-area2.png"
alt="Triangle" referrerpolicy="strict-origin-when-cross-origin">
</map>

Output should be:

How to add HTML <area> referrerpolicy strict-origin-when-cross-origin Attribute

How to add HTML <area> referrerpolicy unsafe-url Attribute

unsafe-url Sends the origin, path, and query string (regardless of security). Use this value carefully!
index.html
Example: HTML
<img src="https://horje.com/uploads/demo/2024-02-19-15-51-41-area11.png"
alt="" width="300" height="119"
class="aligncenter size-medium wp-image-910965"
usemap="#shapemap" />
<map name="shapemap">
<!-- area tag contained image. -->
<area shape="poly"
coords="59,31,28,83,91,83"
href="https://horje.com/uploads/demo/2024-02-19-15-52-16-area2.png"
alt="Triangle" referrerpolicy="unsafe-url">
</map>

Output should be:

How to add HTML <area> referrerpolicy unsafe-url Attribute

How to add HTML <area> rel Attribute

Use the rel attribute to specify the relationship between the current document and the linked document:

Definition and Usage

The rel attribute specifies the relationship between the current document and the linked document.

Only used if the href attribute is present.

Browser Support

Syntax

<area rel="value">

Attribute Values

Value Description
alternate Links to an alternate version of the document (i.e. print page, translated or mirror)
author Links to the author of the document
bookmark Permanent URL used for bookmarking
help Links to a help document
license Links to copyright information for the document
next The next document in a selection
nofollow Links to an unendorsed document, like a paid link.
("nofollow" is used by Google, to specify that the Google search spider should not follow that link)
noreferrer Specifies that the browser should not send a HTTP referer header if the user follows the hyperlink
prefetch Specifies that the target document should be cached
prev The previous document in a selection
search Links to a search tool for the document
tag A tag (keyword) for the current document
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area rel attribute</h1>

<p>Click on the sun to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com" rel="alternate">
</map>

</body>
</html>

Output should be:

How to add HTML <area> rel Attribute

How to add HTML <area> rel alternate Attribute

alternate Links to an alternate version of the document (i.e. print page, translated or mirror)
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area rel attribute</h1>

<p>Click on the sun to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com" rel="alternate">
</map>

</body>
</html>

Output should be:

How to add HTML <area> rel alternate Attribute

How to add HTML <area> rel author Attribute

author Links to the author of the document
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area rel attribute</h1>

<p>Click on the sun to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com" rel="author">
</map>

</body>
</html>

Output should be:

How to add HTML <area> rel author Attribute

How to add HTML <area> rel bookmark Attribute

bookmark Permanent URL used for bookmarking
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area rel attribute</h1>

<p>Click on the sun to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com" rel="bookmark">
</map>

</body>
</html>

Output should be:

How to add HTML <area> rel bookmark Attribute

How to add HTML <area> rel help Attribute

help Links to a help document
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area rel attribute</h1>

<p>Click on the sun to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com" rel="help">
</map>

</body>
</html>

Output should be:

How to add HTML <area> rel help Attribute

How to add HTML <area> rel license Attribute

license Links to copyright information for the document
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area rel attribute</h1>

<p>Click on the sun to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com" rel="license">
</map>

</body>
</html>

Output should be:

How to add HTML <area> rel license Attribute

How to add HTML <area> rel next Attribute

next The next document in a selection
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area rel attribute</h1>

<p>Click on the sun to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com" rel="next">
</map>

</body>
</html>

Output should be:

How to add HTML <area> rel next Attribute

How to add HTML <area> rel nofollow Attribute

nofollow Links to an unendorsed document, like a paid link.
("nofollow" is used by Google, to specify that the Google search spider should not follow that link)
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area rel attribute</h1>

<p>Click on the sun to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com" rel="nofollow">
</map>

</body>
</html>

Output should be:

How to add HTML <area> rel nofollow Attribute

How to add HTML <area> rel noreferrer Attribute

noreferrer Specifies that the browser should not send a HTTP referer header if the user follows the hyperlink
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area rel attribute</h1>

<p>Click on the sun to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com" rel="noreferrer">
</map>

</body>
</html>

Output should be:

How to add HTML <area> rel noreferrer Attribute

How to add HTML <area> rel prefetch Attribute

prefetch Specifies that the target document should be cached
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area rel attribute</h1>

<p>Click on the sun to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com" rel="prefetch">
</map>

</body>
</html>

Output should be:

How to add HTML <area> rel prefetch Attribute

How to add HTML <area> rel prev Attribute

prev The previous document in a selection
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area rel attribute</h1>

<p>Click on the sun to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com" rel="prev">
</map>

</body>
</html>

Output should be:

How to add HTML <area> rel prev Attribute

How to add HTML <area> rel search Attribute

search Links to a search tool for the document
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area rel attribute</h1>

<p>Click on the sun to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com" rel="search">
</map>

</body>
</html>

Output should be:

How to add HTML <area> rel search Attribute

How to add HTML <area> rel tag Attribute

tag A tag (keyword) for the current document
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area rel attribute</h1>

<p>Click on the sun to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com" rel="tag">
</map>

</body>
</html>

Output should be:

How to add HTML <area> rel tag Attribute

How to add HTML <area> shape Attribute

Use the shape attribute to specify the shape of each area  in the image map.

Definition and Usage

The shape attribute specifies the shape of an area.

The shape attribute is used together with the coords attribute to specify the size, shape, and placement of an area.

Browser Support

Syntax

<area shape="default|rect|circle|poly">

Attribute Values

Value Description
default Specifies the entire region
rect Defines a rectangular region
circle Defines a circular region
poly Defines a polygonal region
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area shape attribute</h1>

<p>Click on the sun or on one of the planets to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map id="planetmap" name="planetmap">
<area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com">
<area shape="circle" coords="90,58,3" alt="Mercury" href="https://horje.com/">
<area shape="circle" coords="124,58,8" alt="Venus" href="venus.htm">
</map>

</body>
</html>

Output should be:

How to add HTML <area> shape Attribute

How to add HTML <area> shape default Attribute

default Specifies the entire region
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area shape attribute</h1>

<p>Click on the sun or on one of the planets to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map id="planetmap" name="planetmap">
<area shape="default" coords="0,0,82,126" alt="Sun" href="https://horje.com">
<area shape="circle" coords="90,58,3" alt="Mercury" href="https://horje.com/">
<area shape="circle" coords="124,58,8" alt="Venus" href="https://horje.com">
</map>

</body>
</html>

Output should be:

How to add HTML <area> shape default Attribute

How to add HTML <area> shape rect Attribute

rect Defines a rectangular region
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area shape attribute</h1>

<p>Click on the sun or on one of the planets to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map id="planetmap" name="planetmap">
<area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com">
<area shape="circle" coords="90,58,3" alt="Mercury" href="https://horje.com/">
<area shape="circle" coords="124,58,8" alt="Venus" href="https://horje.com">
</map>

</body>
</html>

Output should be:

How to add HTML <area> shape rect Attribute

How to add HTML <area> shape circle Attribute

circle Defines a circular region
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area shape attribute</h1>

<p>Click on the sun or on one of the planets to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map id="planetmap" name="planetmap">
<area shape="circle" coords="0,0,82,126" alt="Sun" href="https://horje.com">
<area shape="circle" coords="90,58,3" alt="Mercury" href="https://horje.com/">
<area shape="circle" coords="124,58,8" alt="Venus" href="https://horje.com">
</map>

</body>
</html>

Output should be:

How to add HTML <area> shape circle Attribute

How to add HTML <area> shape poly Attribute

poly Defines a polygonal region
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area shape attribute</h1>

<p>Click on the sun or on one of the planets to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map id="planetmap" name="planetmap">
<area shape="poly" coords="0,0,82,126" alt="Sun" href="https://horje.com">
<area shape="circle" coords="90,58,3" alt="Mercury" href="https://horje.com/">
<area shape="circle" coords="124,58,8" alt="Venus" href="https://horje.com">
</map>

</body>
</html>

Output should be:

How to add HTML <area> shape poly Attribute

How to add HTML <area> target Attribute

Use the target attribute to specify where to open the linked document in the image map.

Definition and Usage

The target attribute specifies where to open the linked document.

Only used if the href attribute is present.

Browser Support

Syntax

<area target="_blank|_self|_parent|_top|framename">

Attribute Values

Value Description
_blank Opens the linked document in a new window or tab
_self Opens the linked document in the same frame as it was clicked
_parent Opens the linked document in the parent frame
_top Opens the linked document in the full body of the window
framename Opens the linked document in a named iframe
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area attribute</h1>

<p>Click on the picture or on one of the planets to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com" target="_blank">
  <area shape="circle" coords="90,58,3" alt="Mercury" href="https://horje.com">
  <area shape="circle" coords="124,58,8" alt="Venus" href="https://horje.com">
</map>

</body>
</html>

Output should be:

How to add HTML <area> target Attribute

How to add HTML <area> target _blank Attribute

_blank Opens the linked document in a new window or tab
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area attribute</h1>

<p>Click on the picture or on one of the planets to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com" target="_blank">
  <area shape="circle" coords="90,58,3" alt="Mercury" href="https://horje.com">
  <area shape="circle" coords="124,58,8" alt="Venus" href="https://horje.com">
</map>

</body>
</html>

Output should be:

How to add HTML <area> target _blank Attribute

How to add HTML <area> target _self Attribute

_self Opens the linked document in the same frame as it was clicked
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area attribute</h1>

<p>Click on the picture or on one of the planets to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com" target="_self">
  <area shape="circle" coords="90,58,3" alt="Mercury" href="https://horje.com">
  <area shape="circle" coords="124,58,8" alt="Venus" href="https://horje.com">
</map>

</body>
</html>

Output should be:

How to add HTML <area> target _self Attribute

How to add HTML <area> target _parent Attribute

_parent Opens the linked document in the parent frame
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area attribute</h1>

<p>Click on the picture or on one of the planets to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com" target="_parent">
  <area shape="circle" coords="90,58,3" alt="Mercury" href="https://horje.com">
  <area shape="circle" coords="124,58,8" alt="Venus" href="https://horje.com">
</map>

</body>
</html>

Output should be:

How to add HTML <area> target _parent Attribute

How to add HTML <area> target _top Attribute

_top Opens the linked document in the full body of the window
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area attribute</h1>

<p>Click on the picture or on one of the planets to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com" target="_top">
  <area shape="circle" coords="90,58,3" alt="Mercury" href="https://horje.com">
  <area shape="circle" coords="124,58,8" alt="Venus" href="https://horje.com">
</map>

</body>
</html>

Output should be:

How to add HTML <area> target _top Attribute

How to add HTML <area> target framename Attribute

framename Opens the linked document in a named iframe
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area attribute</h1>

<p>Click on the picture or on one of the planets to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com" target="framename">
  <area shape="circle" coords="90,58,3" alt="Mercury" href="https://horje.com">
  <area shape="circle" coords="124,58,8" alt="Venus" href="https://horje.com">
</map>

</body>
</html>

Output should be:

How to add HTML <area> target framename Attribute

How to add HTML <area> type Attribute

Use the type attribute to specify the MIME type of the target URL:

Definition and Usage

The type attribute specifies the Internet media type (formerly known as MIME type) of the target URL.

This attribute is only used if the href attribute is set.

Note: This attribute is purely advisory.

Browser Support

Syntax

<area type="media_type">

Attribute Values

Value Description
media_type The Internet media type of the linked document.
Look at IANA Media Types for a complete list of standard media types.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area type attribute</h1>

<p>Click on the sun to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com/avatar.png" type="image/gif">
</map>

</body>
</html>

Output should be:

How to add HTML <area> type Attribute

How to add HTML <area> type media Attribute

media_type The Internet media type of the linked document.
Look at IANA Media Types for a complete list of standard media types.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area type attribute</h1>

<p>Click on the sun to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="https://horje.com/avatar.png" type="image/gif">
</map>

</body>
</html>

Output should be:

How to add HTML <area> type media Attribute

# Tips-10) What is HTML <article> Tag

The <article> tag specifies independent, self-contained content.

An article should make sense on its own and it should be possible to distribute it independently from the rest of the site.

Potential sources for the <article> element:

Note: The <article> element does not render as anything special in a browser. However, you can use CSS to style the <article> element (see example below).

How to create HTML <article> Tag

Three articles with independent, self-contained content:
index.html
Example: HTML
 <article>
<h2>Google Chrome</h2>
<p>Google Chrome is a web browser developed by Google, released in 2008. Chrome is the world's most popular web browser today!</p>
</article>

<article>
<h2>Mozilla Firefox</h2>
<p>Mozilla Firefox is an open-source web browser developed by Mozilla. Firefox has been the second most popular web browser since January, 2018.</p>
</article>

<article>
<h2>Microsoft Edge</h2>
<p>Microsoft Edge is a web browser developed by Microsoft, released in 2015. Microsoft Edge replaced Internet Explorer.</p>
</article> 

Output should be:

How to create HTML <article> Tag

Browser Support for HTML <article> Tag

The numbers in the table specify the first browser version that fully supports the element.

Output should be:

Browser Support for HTML <article> Tag

How to Use CSS to style the <article> element:

The article element - Styled with CSS
index.html
Example: HTML
<style>
.all-browsers {
  margin: 0;
  padding: 5px;
  background-color: lightgray;
}

.all-browsers > h1, .browser {
  margin: 10px;
  padding: 5px;
}

.browser {
  background: white;
}

.browser > h2, p {
  margin: 4px;
  font-size: 90%;
}
</style>

Output should be:

How to Use CSS to style the <article> element:

How to edit Default CSS Settings for HTML <article> Tag

index.html
Example: HTML
<style>
article {
  display: block;
  color: blue;
}
</style>

Output should be:

How to edit Default CSS Settings for HTML <article> Tag

# Tips-11) What is HTML <aside> Tag

Tag Defines content aside from the page content.

The <aside> tag defines some content aside from the content it is placed in.

The aside content should be indirectly related to the surrounding content.

Tip: The <aside> content is often placed as a sidebar in a document.

Note: The <aside> element does not render as anything special in a browser. However, you can use CSS to style the <aside> element (see example below).

 

 

 

How to create HTML <aside> Tag

Display some content aside from the content it is placed in:
index.html
Example: HTML
<h1>The aside element</h1>

<p>My family and I visited The Epcot center this summer. The weather was nice, and Epcot was amazing! I had a great summer together with my family!</p>

<aside>
  <h4>Epcot Center</h4>
  <p>Epcot is a theme park at Walt Disney World Resort featuring exciting attractions, international pavilions, award-winning fireworks and seasonal special events.</p>
</aside>

Output should be:

How to create HTML <aside> Tag

What types of Browsers will Browser Support for HTML <aside> Tag

The numbers in the table specify the first browser version that fully supports the element.

Output should be:

What types of Browsers will Browser Support for HTML <aside> Tag

How to Use CSS to style the <aside> element

index.html
Example: HTML
<style>
aside {
  width: 30%;
  padding-left: 15px;
  margin-left: 15px;
  float: right;
  font-style: italic;
  background-color: lightgray;
}
</style>

Output should be:

How to Use CSS to style the <aside> element

How to set Default CSS Settings for HTML <aside> Tag

index.html
Example: HTML
<style>
aside {
  width: 30%;
  padding-left: 15px;
  margin-left: 15px;
  float: right;
  font-style: italic;
  background-color: lightgray;
}
</style>

Output should be:

How to set Default CSS Settings for HTML <aside> Tag

# Tips-12) What is HTML <audio> Tag

What is HTML <audio> Tag Defines embedded sound content.

The <audio> tag is used to embed sound content in a document, such as music or other audio streams.

The <audio> tag contains one or more <source> tags with different audio sources. The browser will choose the first source it supports.

The text between the <audio> and </audio> tags will only be displayed in browsers that do not support the <audio> element.

There are three supported audio formats in HTML: MP3, WAV, and OGG.

Tips and Notes

Tip: For video files, look at the <video> tag.

How to create HTML <audio> Tag

Play a sound file:
index.html
Example: HTML
<audio controls>
  <source src="https://www.w3schools.com/tags/horse.ogg" type="audio/ogg">
  <source src="https://www.w3schools.com/tags/horse.ogg" type="audio/mpeg">
  Your browser does not support the audio element.
</audio>

Output should be:

How to create HTML <audio> Tag

What Audio Format and Browser will Support for HTML <audio> Tag

Audio Format and Browser Support

Browser MP3 WAV OGG
Edge / IE YES YES* YES*
Chrome YES YES YES
Firefox YES YES YES
Safari YES YES NO
Opera YES YES YES
index.html

What types of Browsers will Browser Support for HTML <audio> Tag

The numbers in the table specify the first browser version that fully supports the element.

Output should be:

What types of Browsers will Browser Support for HTML <audio> Tag

Attributes for HTML <audio> Tag

Attribute Value Description
autoplay autoplay Specifies that the audio will start playing as soon as it is ready
controls controls Specifies that audio controls should be displayed (such as a play/pause button etc)
loop loop Specifies that the audio will start over again, every time it is finished
muted muted Specifies that the audio output should be muted
preload auto
metadata
none
Specifies if and how the author thinks the audio should be loaded when the page loads
src URL Specifies the URL of the audio file

How to add HTML <audio> autoplay Attribute

An audio file that will automatically start playing:

Definition and Usage

The autoplay attribute is a boolean attribute.

When present, the audio will automatically start playing as soon as it can do so without stopping.

Note: Chromium browsers do not allow autoplay in most cases. However, muted autoplay is always allowed.

Add muted after autoplay to let your audio file start playing automatically (but muted).

Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<audio autoplay>

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The audio autoplay attribute</h1>

<p>Click on the play button to play a sound:</p>

<audio controls autoplay>
  <source src="https://www.w3schools.com/tags/horse.ogg" type="audio/ogg">
  <source src="https://www.w3schools.com/tags/horse.ogg" type="audio/mpeg">
  Your browser does not support the audio element.
</audio>

</body>
</html>

Output should be:

How to add HTML <audio> autoplay Attribute

How to add HTML <audio> controls Attribute

An <audio> element with browser default controls.

Definition and Usage

The controls attribute is a boolean attribute.

When present, it specifies that audio controls should be displayed.

Audio controls should include:

Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<audio controls>

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The audio controls attribute</h1>

<p>Click on the play button to play a sound:</p>

<audio controls>
  <source src="https://www.w3schools.com/tags/horse.ogg" type="audio/ogg">
  <source src="https://www.w3schools.com/tags/horse.ogg" type="audio/mpeg">
  Your browser does not support the audio element.
</audio>

</body>
</html>

Output should be:

How to add HTML <audio> controls Attribute

How to add HTML <audio> loop Attribute

A song that will start over again, every time it is finished:

Definition and Usage

The loop attribute is a boolean attribute.

When present, it specifies that the audio will start over again, every time it is finished.

Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<audio loop>

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The audio loop attribute</h1>

<p>Click on the play button to play a sound:</p>

<audio controls loop>
  <source src="https://www.w3schools.com/tags/horse.ogg" type="audio/ogg">
  <source src="https://www.w3schools.com/tags/horse.ogg" type="audio/mpeg">
  Your browser does not support the audio element.
</audio>

</body>
</html>

Output should be:

How to add HTML <audio> loop Attribute

How to add HTML <audio> muted Attribute

A muted audio.

Definition and Usage

The muted attribute is a boolean attribute.

When present, it specifies that the audio output should be muted.

Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<audio muted>

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The audio muted attribute</h1>

<p>Click on the play button to play a sound:</p>

<audio controls muted>
  <source src="https://www.w3schools.com/tags/horse.ogg" type="audio/ogg">
  <source src="https://www.w3schools.com/tags/horse.ogg" type="audio/mpeg">
  Your browser does not support the audio element.
</audio>

</body>
</html>

Output should be:

How to add HTML <audio> muted Attribute

How to add HTML <audio> preload Attribute

Author thinks that the sound should NOT be loaded when the page loads.

Definition and Usage

The preload attribute specifies if and how the author thinks that the audio file should be loaded when the page loads.

The preload attribute allows the author to provide a hint to the browser about what he/she thinks will lead to the best user experience. This attribute may be ignored in some instances.

Note: The preload attribute is ignored if autoplay is present.

Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<audio preload="auto|metadata|none">

Attribute Values

Value Description
auto The author thinks that the browser should load the entire audio file when the page loads
metadata The author thinks that the browser should load only metadata when the page loads
none The author thinks that the browser should NOT load the audio file when the page loads
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The audio preload attribute</h1>

<p>Click on the play button to play a sound:</p>

<audio controls preload="none">
  <source src="https://www.w3schools.com/tags/horse.ogg" type="audio/ogg">
  <source src="https://www.w3schools.com/tags/horse.ogg" type="audio/mpeg">
  Your browser does not support the audio element.
</audio>

</body>
</html>

Output should be:

How to add HTML <audio> preload Attribute

How to add HTML <audio> preload auto Attribute

auto The author thinks that the browser should load the entire audio file when the page loads
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The audio preload attribute</h1>

<p>Click on the play button to play a sound:</p>

<audio controls preload="auto">
  <source src="https://www.w3schools.com/tags/horse.ogg" type="audio/ogg">
  <source src="https://www.w3schools.com/tags/horse.ogg" type="audio/mpeg">
  Your browser does not support the audio element.
</audio>

</body>
</html>

Output should be:

How to add HTML <audio> preload auto Attribute

How to add HTML <audio> preload metadata Attribute

metadata The author thinks that the browser should load only metadata when the page loads
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The audio preload attribute</h1>

<p>Click on the play button to play a sound:</p>

<audio controls preload="metadata">
  <source src="https://www.w3schools.com/tags/horse.ogg" type="audio/ogg">
  <source src="https://www.w3schools.com/tags/horse.ogg" type="audio/mpeg">
  Your browser does not support the audio element.
</audio>

</body>
</html>

Output should be:

How to add HTML <audio> preload metadata Attribute

How to add HTML <audio> preload none Attribute

none The author thinks that the browser should NOT load the audio file when the page loads
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The audio preload attribute</h1>

<p>Click on the play button to play a sound:</p>

<audio controls preload="none">
  <source src="https://www.w3schools.com/tags/horse.ogg" type="audio/ogg">
  <source src="https://www.w3schools.com/tags/horse.ogg" type="audio/mpeg">
  Your browser does not support the audio element.
</audio>

</body>
</html>

Output should be:

How to add HTML <audio> preload none Attribute

How to add HTML <audio> src Attribute

Play a sound.

Definition and Usage

The src attribute specifies the location (URL) of the audio file.

The example above uses an Ogg file, and will work in Firefox, Opera, Chrome, and Edge. However, to play the audio file in IE or Safari, we must use an MP3 file.

To make it work in all browsers - use <source> elements inside the <audio> element. Each <source> element can link to different audio files. The browser will use the first recognized format:

Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Note: The src attribute is supported in all of the major browsers, however, the file format may not be supported in all browsers!


Syntax

<audio src="URL">

Attribute Values

Value Description
URL The URL of the audio file.

Possible values:

  • An absolute URL - points to another web site (like src="http://www.example.com/horse.ogg")
  • A relative URL - points to a file within a web site (like src="horse.ogg")
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The audio src attribute</h1>

<p>Click on the play button to play a sound:</p>

<audio src="https://www.w3schools.com/tags/horse.ogg" controls>
Your browser does not support the audio element.
</audio>

<p><b>Note:</b> The .ogg fileformat is not supported in IE or Safari.</p>

</body>
</html>

Output should be:

How to add HTML <audio> src Attribute

# Tips-13) What is HTML <b> Tag

<b> Defines bold text.

The <b> tag specifies bold text without any extra importance.

How to create HTML <b> Tag

Make some text bold (without marking it as important):
index.html
Example: HTML
 <p>This is normal text - <b>and this is bold text</b>.</p> 

Output should be:

How to create HTML <b> Tag

Tips and Notes for HTML <b> Tag

Note: According to the HTML5 specification, the <b> tag should be used as a LAST resort when no other tag is more appropriate. The specification states that headings should be denoted with the <h1> to <h6> tags, emphasized text should be denoted with the <em> tag, important text should be denoted with the <strong> tag, and marked/highlighted text should be denoted with the <mark> tag. Tip: You can also use the following CSS to set bold text: "font-weight: bold;".

What Audio Format and Browser will Support for HTML <b> Tag

Output should be:

What Audio Format and Browser will Support for HTML <b> Tag

How to Use CSS to set bold text

Use CSS to Set Bold Text This is normal text - and this is bold text.
index.html
Example: HTML
<p>This is normal text - <span style="font-weight:bold;">and this is bold text</span>.</p>

Output should be:

How to Use CSS to set bold text

How to set Default CSS Settings

Most browsers will display the <b> element with the following default values: Change the default CSS settings to see the effect.
index.html
Example: HTML
<style>
b { 
  font-weight: bold;
}
</style>

Output should be:

How to set Default CSS Settings

# Tips-14) What is HTML <base> Tag

HTML <base> Tag Specifies the base URL/target for all relative URLs in a document.

The <base> tag specifies the base URL and/or target for all relative URLs in a document.

The <base> tag must have either an href or a target attribute present, or both.

There can only be one single <base> element in a document, and it must be inside the <head> element.

How to use HTML <base> Tag

Specify a default URL and a default target for all links on a page:
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <base href="https://horje.com/learn/634/what-is-html-b-tag" target="_blank">
</head>

Output should be:

How to use HTML <base> Tag

What Audio Format and Browser will Support for HTML <base> Tag

Output should be:

What Audio Format and Browser will Support for HTML <base> Tag

Attributes for HTML <base> Tag

Attribute Value Description
href URL Specifies the base URL for all relative URLs in the page
target _blank
_parent
_self
_top
Specifies the default target for all hyperlinks and

How to add HTML <base> href Attribute

Specify a base URL for all relative URLs on a page.

Definition and Usage

The href attribute specifies the base URL for all relative URLs on a page.

Syntax

<base href="URL">

Attribute Values

Value Description
URL An absolute URL that acts as the base URL (like "http://www.example.com/")
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <base href="https://horje.com">
</head>
<body>

<h1>The base href attribute</h1>

<p><img src="https://horje.com/avatar.png" width="24" height="39" alt="Stickman"> - Notice that we have only specified a relative address for the image. Since we have specified a base URL in the head section, the browser will look for the image at "https://horje.com/avatar.png".</p>

</body>
</html>

Output should be:

How to add HTML <base> href Attribute

How to add HTML <base> target Attribute

Specify a default target for all hyperlinks and forms on a page.

Definition and Usage

The target attribute specifies the default target for all hyperlinks and forms in the page.

This attribute can be overridden by using the target attribute for each hyperlink/form.

Browser Support

Syntax

<base target="_blank|_self|_parent|_top">

Attribute Values

Value Description
_blank Opens the link in a new window or tab
_self Default. Opens the link in the same frame as it was clicked
_parent Opens the link in the parent frame
_top Opens the link in the full body of the window
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <base target="_blank">
</head>
<body>

<h1>The base target attribute</h1>

<p><a href="https://horje.com">Horje.com</a> - Notice that the link opens in a new window, even if it has no target="_blank" attribute. This is because the target attribute of the base element is set to "_blank".</p>

</body>
</html>

Output should be:

How to add HTML <base> target Attribute

How to add HTML <base> target _blank Attribute

_blank Opens the link in a new window or tab
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <base target="_blank">
</head>
<body>

<h1>The base target attribute</h1>

<p><a href="https://horje.com">Horje.com</a> - Notice that the link opens in a new window, even if it has no target="_blank" attribute. This is because the target attribute of the base element is set to "_blank".</p>

</body>
</html>

Output should be:

How to add HTML <base> target _blank Attribute

How to add HTML <base> target _self Attribute

_self Default. Opens the link in the same frame as it was clicked
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <base target="_self">
</head>
<body>

<h1>The base target attribute</h1>

<p><a href="https://horje.com">Horje.com</a> - Notice that the link opens in a new window, even if it has no target="_blank" attribute. This is because the target attribute of the base element is set to "_self".</p>

</body>
</html>

Output should be:

How to add HTML <base> target _self Attribute

How to add HTML <base> target _parent Attribute

_parent Opens the link in the parent frame
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <base target="_parent">
</head>
<body>

<h1>The base target attribute</h1>

<p><a href="https://horje.com">Horje.com</a> - Notice that the link opens in a new window, even if it has no target="_blank" attribute. This is because the target attribute of the base element is set to "_parent".</p>

</body>
</html>

Output should be:

How to add HTML <base> target _parent Attribute

How to add HTML <base> target _top Attribute

_top Opens the link in the full body of the window
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <base target="_top">
</head>
<body>

<h1>The base target attribute</h1>

<p><a href="https://horje.com">Horje.com</a> - Notice that the link opens in a new window, even if it has no target="_blank" attribute. This is because the target attribute of the base element is set to "_top".</p>

</body>
</html>

Output should be:

How to add HTML <base> target _top Attribute

# Tips-15) What is HTML <basefont> Tag

Not Supported in HTML5.

The <basefont> tag was used in HTML 4 to specify a default text-color, font-size or font-family for all the text in an HTML document.

What to Use Instead of HTML <basefont> Tag?

Specify a default text-color for a page (with CSS):
index.html
Example: HTML
 <html>
<head>
<style>
body {
  color: red;
}
</style>
</head>
<body>

<h1>This is a heading</h1>
<p>This is a paragraph.</p>

</body>
</html> 

Output should be:

What to Use Instead of HTML <basefont> Tag?

Specify a default font-family for a page (with CSS):

index.html
Example: HTML
 <html>
<head>
<style>
body {
  font-family: courier, serif;
}
</style>
</head>
<body>

<h1>This is a heading</h1>
<p>This is a paragraph.</p>

</body>
</html> 

Output should be:

Specify a default font-size for a page (with CSS):

 <html>
<head>
<style>
body {
  font-size: 50px;
}
</style>
</head>
<body>

<h1>This is a heading</h1>
<p>This is a paragraph.</p>

</body>
</html> 

Output should be:


# Tips-16) What is HTML <bdi> Tag

HTML <bdi> Tag Isolates a part of text that might be formatted in a different direction from other text outside it.

BDI stands for Bi-Directional Isolation.

The <bdi> tag isolates a part of text that might be formatted in a different direction from other text outside it.

This element is useful when embedding user-generated content with an unknown text direction.

How to create HTML <bdi> Tag

Isolate the usernames from the surrounding text-direction settings:
index.html
Example: HTML
 <ul>
  <li>User <bdi>hrefs</bdi>: 60 points</li>
  <li>User <bdi>jdoe</bdi>: 80 points</li>
  <li>User <bdi>إيان</bdi>: 90 points</li>
</ul> 

Output should be:

How to create HTML <bdi> Tag

What Type of Browsers will Support for HTML <bdi> Tag

Following Browsers will Support for HTML <bdi> Tag
What Type of Browsers will Support for HTML <bdi> Tag

# Tips-17) What is HTML <bdo> Tag

HTML <bdo> Tag Overrides the current text direction.

BDO stands for Bi-Directional Override.

The <bdo> tag is used to override the current text direction.

How to create HTML <bdo> Tag

index.html
Example: HTML
<p>This paragraph will go left-to-right.</p>  
<p><bdo dir="rtl">This paragraph will go right-to-left.</bdo></p>  

Output should be:

How to create HTML <bdo> Tag

What Type of Browsers will Support for HTML <bdo> Tag

Following Browsers will support for HTML <bdo> Tag
What Type of Browsers will Support for HTML <bdo> Tag

Attributes for HTML <bdo> Tag

Attribute Value Description
dir ltr
rtl
Required. Specifies the text direction of the text inside the <bdo> element

How to set Default CSS Settings for HTML <bdo> Tag

Most browsers will display the <bdo> element with the following default values:

<style>
bdo {
  unicode-bidi: bidi-override;
}
</style>

Output should be:

How to set Default CSS Settings for HTML <bdo> Tag

How to add HTML <bdo> dir Attribute

Specify the text direction.

Definition and Usage

The required dir attribute specifies the text direction of the text inside a <bdo> element.

Browser Support

Syntax

<bdo dir="ltr|rtl">

Attribute Values

Value Description
ltr Left-to-right text direction
rtl Right-to-left text direction
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The bdo rtl attribute</h1>

<p>Hello world. <bdo dir="rtl">Hello world</bdo></p>

</body>
</html>

Output should be:

How to add HTML <bdo> dir Attribute

How to add HTML <bdo> dir ltr Attribute

ltr Left-to-right text direction
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The bdo rtl attribute</h1>

<p>Hello world. <bdo dir="ltr">Hello world</bdo></p>

</body>
</html>

Output should be:

How to add HTML <bdo> dir ltr Attribute

How to add HTML <bdo> dir rtl Attribute

rtl Right-to-left text direction
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The bdo rtl attribute</h1>

<p>Hello world. <bdo dir="rtl">Hello world</bdo></p>

</body>
</html>

Output should be:

How to add HTML <bdo> dir rtl Attribute

# Tips-18) What is HTML <big> Tag

Not Supported in HTML5.

The tag was used in HTML 4 to define bigger text.

Not supported in HTML5. Use CSS instead.
Defines big text.

What to Use Instead of HTML <big> Tag?

Specify different font-sizes for HTML elements (with CSS):

index.html
Example: HTML
 <html>
<head>
<style>
p.ex1 {
  font-size: 30px;
}
p.ex2 {
  font-size: 50px;
}
</style>
</head>
<body>

<p>This is a normal paragraph.</p>
<p class="ex1">This is a bigger paragraph.</p>
<p class="ex2">This is a much bigger paragraph.</p>

</body>
</html> 

Output should be:

What to Use Instead of HTML <big> Tag?

Tips and Notes for HTML <big> Tag

Tip: Use <q> for inline (short) quotations.


# Tips-19) What is HTML <blockquote> Tag

The <blockquote> tag specifies a section that is quoted from another source.

Browsers usually indent <blockquote> elements (look at example below to see how to remove the indentation).

<blockquote> Defines a section that is quoted from another source

How to create HTML <blockquote> Tag

A section that is quoted from another source:
index.html
Example: HTML
 <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> 

Output should be:

How to create HTML <blockquote> Tag

Tips and Notes for HTML <blockquote> Tag

Tip: Use <q> for inline (short) quotations.

What Type of Browsers will Support for HTML <blockquote> Tag

Following Browsers will support for HTML <blockquote> Tag
What Type of Browsers will Support for HTML <blockquote> Tag

Attributes for HTML <blockquote> Tag

Attribute Value Description
cite URL Specifies the source of the quotation

How to Use CSS to remove the indentation from the blockquote element:

index.html
Example: HTML
 <html>
<head>
<style>
blockquote {
  margin-left: 0;
}
</style>
</head>
<body>

<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>

</body>
</html> 

Output should be:

How to Use CSS to remove the indentation from the blockquote element:

How to set Default CSS Settings for HTML <blockquote> Tag

Most browsers will display the <blockquote> element with the following default values:
index.html
Example: HTML
<style>
blockquote { 
  display: block;
  margin-top: 1em;
  margin-bottom: 1em;
  margin-left: 40px;
  margin-right: 40px;
}
</style>
<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>

Output should be:

How to set Default CSS Settings for HTML <blockquote> Tag

How to add HTML <blockquote> cite Attribute

A section that is quoted from another source.

Definition and Usage

The cite attribute specifies the source of a quotation.

Tip: It's a good habit to always add the source of a quotation, if any.

Browser Support

The cite attribute does not render as anything special in any of the major browsers, but it can be used by search engines to get more information about the quotation.


Syntax

<blockquote cite="URL">

Attribute Values

Value Description
URL The source of the quotation.

Possible values:

  • An absolute URL - points to another web site (like cite="http://www.example.com/page.htm")
  • A relative URL - points to a file within a web site (like cite="page.htm")
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The blockquote element</h1>

<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>

</body>
</html>

Output should be:

How to add HTML <blockquote> cite Attribute

# Tips-20) What is HTML <body> Tag

<body> Defines the document's body.

The <body> tag defines the document's body.

The <body> element contains all the contents of an HTML document, such as headings, paragraphs, images, hyperlinks, tables, lists, etc.

Note: There can only be one <body> element in an HTML document.

How to create HTML <body> Tag

A simple HTML document:
index.html
Example: HTML
 <html>
<head>
  <title>Title of the document</title>
</head>

<body>
  <h1>This is a heading</h1>
  <p>This is a paragraph.</p>
</body>

</html> 

Output should be:

How to create HTML <body> Tag

What Type of Browsers will Support for HTML <body> Tag

Following Browsers will support for HTML <body> Tag
What Type of Browsers will Support for HTML <body> Tag

How to Add a background image to a document (with CSS)

Follow the Example.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
body {
  background-image: url(https://horje.com/avatar.png);
}
</style>
</head>
<body>

<h1>Hello world!</h1>
<p><a href="https://horje.com">Visit Horje.com!</a></p>

</body>
</html>

Output should be:

How to Add a background image to a document (with CSS)

How to Set the background color of a html body (with CSS)

Follow the Example.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
body {
  background-color: #E6E6FA;
}
</style>
</head>
<body>

<h1>Hello world!</h1>
<p><a href="https://horje.com">Visit Horje.com!</a></p>

</body>
</html>

Output should be:

How to Set the background color of a html body (with CSS)

How to Set the color of text in a document (with CSS)

Follow the Example.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
body {
  color: green;
}
</style>
</head>
<body>

<h1>Hello world!</h1>
<p>This is some text.</p>
<p><a href="https://horje.com">Visit Horje.com!</a></p>

</body>
</html>

Output should be:

How to Set the color of text in a document (with CSS)

How to Set the color of unvisited links in a HTML Body (with CSS)

Follow the Example.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
a:link {
  color: #0000FF;
}
</style>
</head>
<body>

<p><a href="https://horje.com">Horje.com</a></p>
<p><a href="https://horje.com/html/">HTML Tutorial</a></p>

</body>
</html>

Output should be:

How to Set the color of unvisited links in a HTML Body (with CSS)

How to Set the color of active links in a HTML Body (with CSS)

Follow the Example.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
a:active {
  color: #00FF00;
}
</style>
</head>
<body>

<p><a href="https://horje.com">Horje.com</a></p>
<p><a href="https://horje.com/html/">HTML Tutorial</a></p>

</body>
</html>

Output should be:

How to Set the color of active links in a HTML Body (with CSS)

How to Set the color of visited links in a HTML Body (with CSS)

Follow the Example

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
a:visited {
  color: #FF0000;
}
</style>
</head>
<body>

<p><a href="https://horje.com">Horje.com</a></p>
<p><a href="https://horje.com/html/">HTML Tutorial</a></p>

</body>
</html>

Output should be:

How to Set the color of visited links in a HTML Body (with CSS)

How to set Default CSS Settings for HTML <body> Tag

Follow the Example.

index.html
Example: HTML
<style>
body { 
  display: block;
  margin: 8px;
}
 
body:focus { 
  outline: none;
}
</style>
<body>
The content of the document......
<p>Change the default CSS settings to see the effect.</p>
</body>

Output should be:

How to set Default CSS Settings for HTML <body> Tag

# Tips-21) What is HTML <br> Tag

HTML <br> tag Defines a single line break.

The <br> tag inserts a single line break.

The <br> tag is useful for writing addresses or poems.

The <br> tag is an empty tag which means that it has no end tag.

How to create HTML <br> Tag

Insert single line breaks in a text:
index.html
Example: HTML
<p>To force<br> line breaks<br> in a text,<br> use the br<br> elemen

Output should be:

How to create HTML <br> Tag

Tips and Notes for HTML <br> Tag

Note: Use the <br> tag to enter line breaks, not to add space between paragraphs.

What Type of Browsers will Support for HTML <br> Tag

Following Browsers will support for HTML <br> Tag
What Type of Browsers will Support for HTML <br> Tag

Hwo to Use HTML <br> Tag in a poem

Follow the Example.

index.html
Example: HTML
 <p>Be not afraid of greatness.<br>
Some are born great,<br>
some achieve greatness,<br>
and others have greatness thrust upon them.</p>

<p><em>-William Shakespeare</em></p> 

Output should be:

Hwo to Use HTML <br> Tag in a poem

# Tips-22) What is HTML <button> Tag

<button> Defines a clickable button.

The <button> tag defines a clickable button.

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!

Tip: Always specify the type attribute for a <button> element, to tell browsers what type of button it is.

How to create HTML <button> Tag

A clickable button is marked up as follows:
index.html
Example: HTML
 <button type="button">Click Me!</button> 

Output should be:

How to create HTML <button> Tag

What Type of Browsers will Support for HTML <button> Tag

Following Browsers will support for HTML <button> Tag
What Type of Browsers will Support for HTML <button> Tag

Attributes for HTML <button> Tag

Attribute Value Description
autofocus autofocus Specifies that a button should automatically get focus when the page loads
disabled disabled Specifies that a button should be disabled
form form_id Specifies which form the button belongs to
formaction URL Specifies where to send the form-data when a form is submitted. Only for type="submit"
formenctype application/x-www-form-urlencoded
multipart/form-data
text/plain
Specifies how form-data should be encoded before sending it to a server. Only for type="submit"
formmethod get
post
Specifies how to send the form-data (which HTTP method to use). Only for type="submit"
formnovalidate formnovalidate Specifies that the form-data should not be validated on submission. Only for type="submit"
formtarget _blank
_self
_parent
_top
framename
Specifies where to display the response after submitting the form. Only for type="submit"
popovertarget element_id Specifies a which popover element to invoke
popovertargetaction hide
show
toggle
Specifies what happens to the popover element when the button is clicked
name name Specifies a name for the button
type button
reset
submit
Specifies the type of button
value text Specifies an initial value for the button

How to Use CSS to style buttons

Follow the Example
index.html
Example: HTML
 <!DOCTYPE html>
<html>
<head>
<style>
.button {
  border: none;
  color: white;
  padding: 15px 32px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
  margin: 4px 2px;
  cursor: pointer;
}

.button1 {background-color: #04AA6D;} /* Green */
.button2 {background-color: #008CBA;} /* Blue */
</style>
</head>
<body>

<button class="button button1">Green</button>
<button class="button button2">Blue</button>

</body>
</html> 

Output should be:

How to Use CSS to style buttons

How to Use CSS to style buttons (with hover effect)

Follow the Example.

The button element - Styled with CSS

Use the :hover selector to change the style of the button when you move the mouse over it.
Tip: Use the transition-duration property to determine the speed of the "hover" effect:

 <!DOCTYPE html>
<html>
<head>
<style>
.button {
  border: none;
  color: white;
  padding: 16px 32px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
  margin: 4px 2px;
  transition-duration: 0.4s;
  cursor: pointer;
}

.button1 {
  background-color: white;
  color: black;
  border: 2px solid #04AA6D;
}

.button1:hover {
  background-color: #04AA6D;
  color: white;
}

.button2 {
  background-color: white;
  color: black;
  border: 2px solid #008CBA;
}

.button2:hover {
  background-color: #008CBA;
  color: white;
}

</style>
</head>
<body>

<button class="button button1">Green</button>
<button class="button button2">Blue</button>

</body>
</html> 

Output should be:

How to Use CSS to style buttons (with hover effect)

How to add HTML <button> autofocus Attribute

A button with autofocus.

Definition and Usage

The autofocus attribute is a boolean attribute.

When present, it specifies that a button should automatically get focus when the page loads.

Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<button type="button" autofocus>

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The button autofocus attribute</h1>

<button type="button" autofocus onclick="alert('Hello world!')">Click Me!</button>

</body>
</html>

Output should be:

How to add HTML <button> autofocus Attribute

How to add HTML <button> disabled Attribute

A disabled button.

Definition and Usage

The disabled attribute is a boolean attribute.

When present, it specifies that the button should be disabled.

A disabled button is unusable and un-clickable.

The disabled attribute can be set to keep a user from clicking on the button until some other condition has been met (like selecting a checkbox, etc.). Then, a JavaScript could remove the disabled value, and make the button clickable again.

Browser Support

Syntax

<button disabled>

index.html
Example: HTML
<button type="button" disabled>Click Me!</button>

Output should be:

How to add HTML <button> disabled Attribute

How to add HTML <button> hidden Attribute

Hide your HTML Button

index.html
Example: HTML
<button type="button" hidden>Click Me!</button>

Output should be:

How to add HTML <button> hidden Attribute

How to add HTML <button> form Attribute

A button located outside a form (but still a part of the form):

Definition and Usage

The form attribute specifies the form the button belongs to.

The value of this attribute must be equal to the id attribute of a <form> element in the same document.

Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<button form="form_id">

Attribute Values

Value Description
form_id Specifies the form element the <button> element belongs to. The value of this attribute must be the id attribute of a <form> element in the same document.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The button form attribute</h1>

<form action="/action_page.php" method="get" id="nameform">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname">
</form>

<p>The button below is outside the form element, but still part of the form.</p>

<button type="submit" form="nameform" value="Submit">Submit</button>

</body>
</html>

Output should be:

How to add HTML <button> form Attribute

How to add HTML <button> formaction Attribute

A form with two submit buttons. The first submit button submits the form data to "action_page.php", and the second submits to "action_page2.php":

Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<button type="submit" formaction="URL">

Attribute Values

Value Description
URL Specifies where to send the form data.

Possible values:

  • An absolute URL - the full address of a page (like href="http://www.example.com/formresult.asp")
  • A relative URL - points to a file within the current site (like href="formresult.asp")
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The button formaction attribute</h1>

<form action="/action_page.php" method="get">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <button type="submit">Submit</button>
  <button type="submit" formaction="/action_page2.php">Submit to another page</button>
</form>

</body>
</html>

Output should be:

How to add HTML <button> formaction Attribute

How to add HTML <button> formenctype Attribute

A form with two submit buttons. The first submit button submits the form data with default character encoding, and the second submits the form data without character encoding.

Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<button type="submit" formenctype="value">

Attribute Values

Value Description
application/x-www-form-urlencoded Default. All characters will be encoded before sent
multipart/form-data  This value is necessary if the user will upload a file through the form
text/plain Sends data without any encoding at all. Not recommended
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The button formenctype attribute</h1>

<form action="/action_page_binary.asp" method="post">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname" value="Ståle"><br><br>
  <button type="submit">Submit with character encoding</button>
  <button type="submit" formenctype="text/plain">Submit without character encoding</button>
</form>

</body>
</html>

Output should be:

How to add HTML <button> formenctype Attribute

How to add HTML <button> formenctype application/x-www-form-urlencoded Attribute

application/x-www-form-urlencoded Default. All characters will be encoded before sent
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The button formenctype attribute</h1>

<form action="/action_page_binary.asp" method="post">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname" value="Ståle"><br><br>
  <button type="submit">Submit with character encoding</button>
  <button type="submit" formenctype="application/x-www-form-urlencoded">Submit without character encoding</button>
</form>

</body>
</html>

Output should be:

How to add HTML <button> formenctype application/x-www-form-urlencoded Attribute

How to add HTML <button> formenctype multipart/form-data Attribute

multipart/form-data  This value is necessary if the user will upload a file through the form
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The button formenctype attribute</h1>

<form action="/action_page_binary.asp" method="post">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname" value="Ståle"><br><br>
  <button type="submit">Submit with character encoding</button>
  <button type="submit" formenctype="multipart/form-data">Submit without character encoding</button>
</form>

</body>
</html>

Output should be:

How to add HTML <button> formenctype multipart/form-data Attribute

How to add HTML <button> formenctype text/plain Attribute

text/plain Sends data without any encoding at all. Not recommended
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The button formenctype attribute</h1>

<form action="/action_page_binary.asp" method="post">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname" value="Ståle"><br><br>
  <button type="submit">Submit with character encoding</button>
  <button type="submit" formenctype="text/plain">Submit without character encoding</button>
</form>

</body>
</html>

Output should be:

How to add HTML <button> formenctype text/plain Attribute

How to add HTML <button> formmethod Attribute

A form with two submit buttons. The first submit button submits the form data with method="get", and the second submits the form data with method="post":

Definition and Usage

The formmethod attribute specifies which HTTP method to use when sending the form-data. This attribute overrides the form's method attribute.

The formmethod attribute is only used for buttons with type="submit".

The form-data can be sent as URL variables (with method="get") or as HTTP post (with method="post").

Notes on the "get" method:

Notes on the "post" method:

Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<button type="submit" formmethod="get|post">

Attribute Values

Value Description
get Appends the form-data to the URL: URL?name=value&name=value
post Sends the form-data as an HTTP post transaction
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The button formmethod attribute</h1>

<form action="/action_page.php" method="get" target="_blank">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <button type="submit">Submit</button>
  <button type="submit" formmethod="post">Submit using POST</button>
</form>

</body>
</html>

Output should be:

How to add HTML <button> formmethod Attribute

How to add HTML <button> formmethod get Attribute

get Appends the form-data to the URL: URL?name=value&name=value
index.html
Example: HTML
<form action="/action_page.php" method="get" target="_blank">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <button type="submit">Submit</button>
  <button type="submit" formmethod="get">Submit using POST</button>
</form>

Output should be:

How to add HTML <button> formmethod get Attribute

How to add HTML <button> formmethod post Attribute

post Sends the form-data as an HTTP post transaction
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The button formmethod attribute</h1>

<form action="/action_page.php" method="get" target="_blank">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <button type="submit">Submit</button>
  <button type="submit" formmethod="post">Submit using POST</button>
</form>

</body>
</html>

Output should be:

How to add HTML <button> formmethod post Attribute

How to add HTML <button> formnovalidate Attribute

A form with two submit buttons. The first submit button submits the form data with default validation, and the second submits the form data without validation:

Definition and Usage

The formnovalidate attribute is a boolean attribute.

When present, it specifies that the form-data should not be validated on submission. This attribute overrides the form's novalidate attribute.

The formnovalidate attribute is only used for buttons with type="submit".

Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<button type="submit" formnovalidate>

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The button formnovalidate attribute</h1>

<form action="/action_page.php" method="get">
  <label for="email">Enter your email:</label>
  <input type="email" id="email" name="email"><br><br>
  <button type="submit">Submit</button>
  <button type="submit" formnovalidate>Submit without validation</button>
</form>

<p><strong>Note:</strong> The formnovalidate attribute of the button tag is not supported in Safari.</p>

</body>
</html>

Output should be:

How to add HTML <button> formnovalidate Attribute

How to add HTML <button> formtarget Attribute

A form with two submit buttons. The first submit button submits the form data with default target ("_self"), and the second submits the form data to a new window (target="_blank"):

Definition and Usage

The formtarget attribute specifies where to display the response after submitting the form. This attribute overrides the form's target attribute.

The formtarget attribute is only used for buttons with type="submit".

Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<button type="submit" formtarget="_blank|_self|_parent|_top|framename">

Attribute Values

Value Description
_blank Loads the response in a new window/tab
_self Loads the response in the same frame (this is default)
_parent Loads the response in the parent frame
_top Loads the response in the full body of the window
framename Loads the response in a named iframe
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The button formtarget attribute</h1>

<form action="/action_page.php" method="get">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <button type="submit">Submit</button>
  <button type="submit" formtarget="_blank">Submit to a new window/tab</button>
</form>

</body>
</html>

Output should be:

How to add HTML <button> formtarget Attribute

How to add HTML <button> formtarget _blank Attribute

_blank Loads the response in a new window/tab
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The button formtarget attribute</h1>

<form action="/action_page.php" method="get">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <button type="submit">Submit</button>
  <button type="submit" formtarget="_blank">Submit to a new window/tab</button>
</form>

</body>
</html>

Output should be:

How to add HTML <button> formtarget _blank Attribute

How to add HTML <button> formtarget _self Attribute

_self Loads the response in the same frame (this is default)
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The button formtarget attribute</h1>

<form action="/action_page.php" method="get">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <button type="submit">Submit</button>
  <button type="submit" formtarget="_self">Submit to a new window/tab</button>
</form>

</body>
</html>

Output should be:

How to add HTML <button> formtarget _self Attribute

How to add HTML <button> formtarget _parent Attribute

_parent Loads the response in the parent frame
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The button formtarget attribute</h1>

<form action="/action_page.php" method="get">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <button type="submit">Submit</button>
  <button type="submit" formtarget="_parent">Submit to a new window/tab</button>
</form>

</body>
</html>

Output should be:

How to add HTML <button> formtarget _parent Attribute

How to add HTML <button> formtarget _blank Attribute

_top Loads the response in the full body of the window
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The button formtarget attribute</h1>

<form action="/action_page.php" method="get">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <button type="submit">Submit</button>
  <button type="submit" formtarget="_top">Submit to a new window/tab</button>
</form>

</body>
</html>

Output should be:

How to add HTML <button> formtarget _blank Attribute

How to add HTML <button> formtarget framename Attribute

framename Loads the response in a named iframe
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The button formtarget attribute</h1>

<form action="/action_page.php" method="get">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <button type="submit">Submit</button>
  <button type="submit" formtarget="framename">Submit to a new window/tab</button>
</form>

</body>
</html>

Output should be:

How to add HTML <button> formtarget framename Attribute

How to add HTML <button> popovertarget Attribute

Refer to a popover element with the popovertarget attribute to show/hide the specified popover element.

Definition and Usage

With the popovertarget attribute you can refer to the popover element with the specified id, and toggle between showing and hiding it:

Browser Support

Syntax

<button popovertarget="element_id">


Attribute Values

Value Description
element_id The id of the popover element related to this button
index.html
Example: HTML
<h1 popover id="myheader">Hello</h1>
<button popovertarget="myheader">Click me!</button>

Output should be:

How to add HTML <button> popovertarget Attribute

How to add HTML <button> popovertargetaction Attribute

When the button is clicked, the popover element will show.

Definition and Usage

The popovertargetaction attribute allows you to define what happens when you click the button.

You can choose between the values "show", "hide", and "toggle".

Browser Support

Syntax

<button popovertarget="element_id popovertargetaction="hide|show|toggle"">

Attribute Values

Value Description  
hide The popover element is hidden when you click the button  
show The popover element is showed when you click the button  
toggle Default value. The popover element is toggled between hidding and showing when you click the button  

 

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The button popovertargetaction Attribute</h1>

<h1 popover id="myheader">Hello</h1>

<button popovertarget="myheader" popovertargetaction="show">Show popover</button>

<p>Click the button and it will show the popover element.</p>

</body>
</html>

Output should be:

How to add HTML <button> popovertargetaction Attribute

How to add HTML <button> popovertargetaction hide Attribute

hide The popover element is hidden when you click the button
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The button popovertargetaction Attribute</h1>

<h1 popover id="myheader">Hello</h1>

<button popovertarget="myheader" popovertargetaction="hide">Show popover</button>

<p>Click the button and it will show the popover element.</p>

</body>
</html>

Output should be:

How to add HTML <button> popovertargetaction hide Attribute

How to add HTML <button> popovertargetaction show Attribute

show The popover element is showed when you click the button
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The button popovertargetaction Attribute</h1>

<h1 popover id="myheader">Hello</h1>

<button popovertarget="myheader" popovertargetaction="show">Show popover</button>

<p>Click the button and it will show the popover element.</p>

</body>
</html>

Output should be:

How to add HTML <button> popovertargetaction show Attribute

How to add HTML <button> popovertargetaction toggle Attribute

toggle Default value. The popover element is toggled between hidding and showing when you click the button
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The button popovertargetaction Attribute</h1>

<h1 popover id="myheader">Hello</h1>

<button popovertarget="myheader" popovertargetaction="toggle">Show popover</button>

<p>Click the button and it will show the popover element.</p>

</body>
</html>

Output should be:

How to add HTML <button> popovertargetaction toggle Attribute

How to add HTML <button> name Attribute

Two buttons with equal names, that submit different values when clicked.

Definition and Usage

The name attribute specifies the name for a <button> element.

The name attribute is used to reference form-data after the form has been submitted, or to reference the element in a JavaScript.

Tip: Several <button> elements can share the same name. This allows you to have several buttons with equal names, which can submit different values when used in a form.

Browser Support

Syntax

<button name="name">

Attribute Values

Value Description
name The name of the button
index.html
Example: HTML
<form action="/action_page.php" method="get">
Choose your favorite subject:
<button name="subject" type="submit" value="HTML">HTML</button>
<button name="subject" type="submit" value="CSS">CSS</button>
</form>

Output should be:

How to add HTML <button> name Attribute

How to add HTML <button> type Attribute

Two button elements that act as one submit button and one reset button (in a form):

Definition and Usage

The type attribute specifies the type of button.

Tip: Always specify the type attribute for the <button> element. Different browsers may use different default types for the <button> element.

Browser Support

Syntax

<button type="button|submit|reset">

Attribute Values

Value Description
button The button is a clickable button
submit The button is a submit button (submits form-data)
reset The button is a reset button (resets the form-data to its initial values)
index.html
Example: HTML
<form action="/action_page.php" method="get">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <button type="submit" value="Submit">Submit</button>
  <button type="reset" value="Reset">Reset</button>
</form> 

Output should be:

How to add HTML <button> type Attribute

How to add HTML <button> type button Attribute

button The button is a clickable button
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The button type attribute</h1>

<form action="/action_page.php" method="get">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <button type="submit" value="Submit">Submit</button>
  <button type="button" value="Reset">Reset</button>
</form>

</body>
</html>

Output should be:

How to add HTML <button> type button Attribute

How to add HTML <button> type submit Attribute

submit The button is a submit button (submits form-data)
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The button type attribute</h1>

<form action="/action_page.php" method="get">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <button type="submit" value="Submit">Submit</button>
  <button type="submit" value="Reset">Reset</button>
</form>

</body>
</html>

Output should be:

How to add HTML <button> type submit Attribute

How to add HTML <button> type reset Attribute

reset The button is a reset button (resets the form-data to its initial values)
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The button type attribute</h1>

<form action="/action_page.php" method="get">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <button type="submit" value="Submit">Submit</button>
  <button type="reset" value="Reset">Reset</button>
</form>

</body>
</html>

Output should be:

How to add HTML <button> type reset Attribute

How to add HTML <button> value Attribute

Two buttons with equal names, that submit different values when clicked.

Definition and Usage

The value attribute specifies the initial value for a <button> in an HTML form.

Note: In a form, the button and its value is only submitted if the button itself was used to submit the form.

Browser Support

Note: If you use the <button> element in an HTML form, Internet Explorer, prior version 8, will submit the text between the <button> and </button> tags, while the other browsers will submit the content of the value attribute.


Syntax

<button value="value">

Attribute Values

Value Description
value The initial value of the button
index.html
Example: HTML
<form action="/action_page.php" method="get">
  Choose your favorite subject:
  <button name="subject" type="submit" value="fav_HTML">HTML</button>
  <button name="subject" type="submit" value="fav_CSS">CSS</button>
</form> 

Output should be:

How to add HTML <button> value Attribute

# Tips-23) What is HTML <canvas> Tag

The <canvas> tag is used to draw graphics, on the fly, via scripting (usually JavaScript).

The <canvas> tag is transparent, and is only a container for graphics, you must use a script to actually draw the graphics.

Any text inside the <canvas> element will be displayed in browsers with JavaScript disabled and in browsers that do not support <canvas>.

How to create HTML <canvas> Tag

Draw a red rectangle on the fly, and show it inside the <canvas> element:
index.html
Example: HTML
 <canvas id="myCanvas">
Your browser does not support the canvas tag.
</canvas>

<script>
let canvas = document.getElementById("myCanvas");
let ctx = canvas.getContext("2d");
ctx.fillStyle = "#FF0000";
ctx.fillRect(0, 0, 80, 80);
</script> 

Output should be:

How to create HTML <canvas> Tag

Tips and Notes for HTML <canvas> Tag

Tip: Learn more about the <canvas> element in our HTML Canvas Tutorial.

What Type of Browsers will Support for HTML <canvas> Tag

The numbers in the table specify the first browser version that fully supports the element.
What Type of Browsers will Support for HTML <canvas> Tag

Attributes for HTML <canvas> Tag

Attribute Value Description
height pixels Specifies the height of the canvas. Default value is 150
width pixels Specifies the width of the canvas Default value is 300

Another <canvas> example

Follow the Example

index.html
Example: HTML
 <canvas id="myCanvas">
Your browser does not support the canvas tag.
</canvas>

<script>
let c = document.getElementById("myCanvas");
let ctx = c.getContext("2d");
ctx.fillStyle = "red";
ctx.fillRect(20, 20, 75, 50);
//Turn transparency on
ctx.globalAlpha = 0.2;
ctx.fillStyle = "blue";
ctx.fillRect(50, 50, 75, 50);
ctx.fillStyle = "green";
ctx.fillRect(80, 80, 75, 50);
</script> 

Output should be:

Another <canvas> example

Default CSS Settings For HTML <canvas> Tag

Most browsers will display the <canvas> element with the following default values:

index.html
Example: HTML
<style>
canvas {
  border:1px solid black;
}
</style>
<canvas id="myCanvas">Your browser does not support the HTML5 canvas tag.</canvas>
<script>
let c = document.getElementById("myCanvas");
let ctx = c.getContext("2d");
ctx.fillStyle = "#FF0000";
ctx.fillRect(0, 0, 80, 100);
</script>

Output should be:

Default CSS Settings For HTML <canvas> Tag

How to add HTML <canvas> height Attribute

A <canvas> element with a height and width of 200 pixels.

More "Try it Yourself" examples below.

Definition and Usage

The height attribute specifies the height of the <canvas> element, in pixels.

Tip: Use the width attribute to specify the width of the <canvas> element, in pixels.

Tip: Each time the height or width of a canvas is re-set, the canvas content will be cleared (see example at bottom of page).

Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<canvas height="pixels">

Attribute Values

Value Description
pixels Specifies the height of the canvas, in pixels (e.g. "100"). Default value is 150

 

index.html
Example: HTML
<canvas id="myCanvas" width="200" height="200" style="border:1px solid">

Output should be:

How to add HTML <canvas> height Attribute

How to add HTML <canvas> width Attribute

A <canvas> element with a height and width of 200 pixels:

More "Try it Yourself" examples below.

Definition and Usage

The width attribute specifies the width of the <canvas> element, in pixels.

Tip: Use the height attribute to specify the height of the <canvas> element, in pixels.

Tip: Each time the height or width of a canvas is re-set, the canvas content will be cleared (see example at bottom of page).

Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<canvas width="pixels">

Attribute Values

Value Description
pixels Specifies the width of the canvas, in pixels (e.g. "100"). Default value is 300

 

index.html
Example: HTML
<canvas id="myCanvas" width="200" height="200" style="border:1px solid">

Output should be:

How to add HTML <canvas> width Attribute

How to Clear the canvas by setting the width attribute to 400px (using JavaScript)

Follow the Example.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<canvas id="myCanvas" width="200" height="200" style="border:1px solid">
Your browser does not support the HTML5 canvas tag.
</canvas>
<br>

<script>
const c = document.getElementById("myCanvas");
const ctx = c.getContext("2d");
ctx.fillStyle = "#92B901";
ctx.fillRect(50, 50, 100, 100);

function clearCanvas() {
  c.width = 400;
}
</script>

<button onclick="clearCanvas()">Clear canvas</button>

</body>
</html>

Output should be:

How to Clear the canvas by setting the width attribute to 400px (using JavaScript)

# Tips-24) What is HTML <caption> Tag

The <caption> tag defines a table caption.

The <caption> tag must be inserted immediately after the <table> tag.

Tip: By default, a table caption will be center-aligned above a table. However, the CSS properties text-align and caption-side can be used to align and place the caption.

How to create HTML <caption> Tag

A table with a caption:
index.html
Example: HTML
<table>
  <caption>Monthly savings</caption>
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
</table> 

Output should be:

How to create HTML <caption> Tag

What Type of Browsers will Support for HTML <caption> Tag

Output should be:

What Type of Browsers will Support for HTML <caption> Tag

How to take Position table captions (with CSS)

Follow the Example.
index.html
Example: HTML
<table>
  <caption style="text-align:right">My savings</caption>
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
</table>
<br>

<table>
  <caption style="caption-side:bottom">My savings</caption>
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
</table>

Output should be:

How to take Position table captions (with CSS)

How to set Default CSS Settings for HTML <caption> Tag

Follow the Example.

index.html
Example: HTML
<style>
table,th,td {
  border:1px solid black;
}

caption { 
  display: table-caption;
  text-align: center;
}
</style>
<table>
  <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>

Output should be:

How to set Default CSS Settings for HTML <caption> Tag

# Tips-25) What is HTML <center> Tag

Not Supported in HTML5.

The <center> tag was used in HTML4 to center-align text.

It Defines centered text.

How to create HTML <center> Tag

Center-align text (with CSS)
index.html
Example: HTML
<center>2024</center>

Output should be:

How to create HTML <center> Tag

How to create HTML <center> Tag with CSS

Here is an example with CSS.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
h1 {text-align: center;}
p {text-align: center;}
div {text-align: center;}
</style>
</head>
<body>

<h1>This is a heading</h1>
<p>This is a paragraph.</p>
<div>This is a div.</div>

</body>
</html>

Output should be:

How to create HTML <center> Tag with CSS

# Tips-26) What is HTML <cite> Tag

The <cite> tag defines the title of a creative work (e.g. a book, a poem, a song, a movie, a painting, a sculpture, etc.).

Note: A person's name is not the title of a work.

The text in the <cite> element usually renders in italic.

How to create HTML <cite> Tag

The cite element
index.html
Example: HTML
<img src="https://horje.com/avatar.png" width="220" height="277" alt="The Scream">
<p><cite>The Scream</cite> by Edward Munch. Painted in 1893.</p>

What Type of Browsers will Support for HTML <cite> Tag

Following browsers will support for it.
What Type of Browsers will Support for HTML <cite> Tag

How to set Default CSS Settings for HTML <cite> Tag

Most browsers will display the <cite> element with the following default values:
style.css
Example: CSS
<style>
cite { 
  font-style: italic;
}
</style>

Output should be:

How to set Default CSS Settings for HTML <cite> Tag

# Tips-27) What is HTML <code> Tag

The <code> tag is used to define a piece of computer code. The content inside is displayed in the browser's default monospace font.

Tip: This tag is not deprecated. However, it is possible to achieve richer effect by using CSS (see example below).

Also look at:

Tag Description
<samp> Defines sample output from a computer program
<kbd> Defines keyboard input
<var> Defines a variable
<pre> Defines preformatted text

How to create HTML <code> Tag

Define some text as computer code in a document
index.html
Example: HTML
 <p>The HTML <code>button</code> tag defines a clickable button.</p>

<p>The CSS <code>background-color</code> property defines the background color of an element.</p> 

Output should be:

How to create HTML <code> Tag

What Type of Browsers will Support for HTML <code> Tag

Following Browsers will support for it.
What Type of Browsers will Support for HTML <code> Tag

How to Use CSS to style the <code> element

Follow the Example.
index.html
Example: HTML
<style>
code {
  font-family: Consolas,"courier new";
  color: crimson;
  background-color: #f1f1f1;
  padding: 2px;
  font-size: 105%;
}
</style>

<p>The HTML <code>button</code> tag defines a clickable button.</p>
<p>The CSS <code>background-color</code> property defines the background color of an element.</p>

Output should be:

How to Use CSS to style the <code> element

How to set Default CSS Settings for HTML <code> Tag

Most browsers will display the <code> element with the following default values:
index.html
Example: HTML
<style>
code { 
  font-family: monospace;
}
</style>

Output should be:

How to set Default CSS Settings for HTML <code> Tag

How to add HTML <samp> Tag for Coding view

Define some text as sample output from a computer program in a document:

Definition and Usage

The <samp> tag is used to define sample output from a computer program. The content inside is displayed in the browser's default monospace font.

Tip: This tag is not deprecated. However, it is possible to achieve richer effect by using CSS.

Also look at:

Tag Description
<code> Defines a piece of computer code
<kbd> Defines keyboard input
<var> Defines a variable
<pre> Defines preformatted text

Browser Support

index.html
Example: HTML
<p>Message from my computer:</p>
<p><samp>File not found.<br>Press F1 to continue</samp></p>

Output should be:

How to add HTML <samp> Tag for Coding view

How to set Default CSS Settings HTML <samp> Tag for Coding view

Most browsers will display the <samp> element with the following default values:

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
samp { 
  font-family: monospace;
}
</style>
</head>
<body>

<p>A samp element is displayed like this:</p>

<samp>Sample output from a computer program</samp>

<p>Change the default CSS settings to see the effect.</p>

</body>
</html>

Output should be:

How to set Default CSS Settings HTML <samp> Tag for Coding view

How to add HTML <kbd> Tag for Coding view

Define some text as keyboard input in a document.

More "Try it Yourself" examples below.

Definition and Usage

The <kbd> tag is used to define keyboard input. The content inside is displayed in the browser's default monospace font.

Tip: This tag is not deprecated. However, it is possible to achieve richer effect by using CSS (see example below).

Also look at:

Tag Description
<code> Defines a piece of computer code
<samp> Defines sample output from a computer program
<var> Defines a variable
<pre> Defines preformatted text

Browser Support

 

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The kbd element</h1>

<p>Press <kbd>Ctrl</kbd> + <kbd>C</kbd> to copy text (Windows).</p>

<p>Press <kbd>Cmd</kbd> + <kbd>C</kbd> to copy text (Mac OS).</p>

</body>
</html>

Output should be:

How to add HTML <kbd> Tag for Coding view

How to add HTML <var> Tag for coding view

Define some text as variables in a document:

Definition and Usage

The <var> tag is used to defines a variable in programming or in a mathematical expression. The content inside is typically displayed in italic.

Tip: This tag is not deprecated. However, it is possible to achieve richer effect by using CSS.

Also look at:

Tag Description
<code> Defines a piece of computer code
<samp> Defines sample output from a computer program
<kbd> Defines keyboard input
<pre> Defines preformatted text

Browser Support

 

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The var element</h1>

<p>The area of a triangle is: 1/2 x <var>b</var> x <var>h</var>, where <var>b</var> is the base, and <var>h</var> is the vertical height.</p>

</body>
</html>

Output should be:

How to add HTML <var> Tag for coding view

How to set Default CSS Settings HTML <var> Tag for coding view

Most browsers will display the <var> element with the following default values.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
var { 
  font-style: italic;
}
</style>
</head>
<body>

<p>A var element is displayed like this:</p>

<var>Variable</var>

<p>Change the default CSS settings to see the effect.</p>

</body>
</html>

Output should be:

How to set Default CSS Settings HTML <var> Tag for coding view

How to add HTML <pre> Tag

Preformatted text.

Definition and Usage

The <pre> tag defines preformatted text.

Text in a <pre> element is displayed in a fixed-width font, and the text preserves both spaces and line breaks. The text will be displayed exactly as written in the HTML source code.

Also look at:

Tag Description
<code> Defines a piece of computer code
<samp> Defines sample output from a computer program
<kbd> Defines keyboard input
<var> Defines a variable

Browser Support

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The pre element</h1>

<pre>
Text in a pre element
is displayed in a fixed-width
font, and it preserves
both      spaces and
line breaks
</pre>

</body>
</html>

Output should be:

How to add HTML <pre> Tag

How to create a pre-formatted text with a fixed width (with CSS)

Follow the Example.

index.html
Example: HTML
 <div style="width:200px;overflow:auto">
<pre>This is a pre with a fixed width. It will use as much space as specified.</pre>
</div> 

Output should be:

How to create a pre-formatted text with a fixed width (with CSS)

How to add Default CSS Settings HTML <pre> Tag for coing view

Most browsers will display the <pre> element with the following default values.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
pre {
  display: block;
  font-family: monospace;
  white-space: pre;
  margin: 1em 0;
} 
</style>
</head>
<body>

<p>A pre element is displayed like this:</p>

<pre>
Text in a pre element
is displayed in a fixed-width
font, and it preserves
both      spaces and
line breaks
</pre>

<p>Change the default CSS settings to see the effect.</p>

</body>
</html>

Output should be:

How to add Default CSS Settings HTML <pre> Tag for coing view

# Tips-28) What is HTML <col> Tag

The tag specifies column properties for each column within a element.

The tag is useful for applying styles to entire columns, instead of repeating the styles for each cell, for each row.

How to create HTML <col> Tag

Set the background color of the three columns with the <colgroup> and <col> tags:
index.html
Example: HTML
 <table>
  <colgroup>
    <col span="2" style="background-color:red">
    <col style="background-color:yellow">
  </colgroup>
  <tr>
    <th>ISBN</th>
    <th>Title</th>
    <th>Price</th>
  </tr>
  <tr>
    <td>3476896</td>
    <td>My first HTML</td>
    <td>$53</td>
  </tr>
</table> 

Output should be:

How to create HTML <col> Tag

What Type of Browsers will Support for HTML <col> Tag

Following browsers will support.
What Type of Browsers will Support for HTML <col> Tag

Attributes for HTML <col> Tag

Attribute Value Description
span number Specifies the number of columns a <col> element should span

How to set Default CSS Settings for HTML <col> Tag

Most browsers will display the <col> element with the following default values:
index.html
Example: HTML
<style>
table, th, td {
  border: 1px solid black;
}

col {
  display: table-column;
} 
</style>

Output should be:

How to set Default CSS Settings for HTML <col> Tag

How to add HTML <col> span Attribute

Here, the first two columns should have a background color of red.

Definition and Usage

The span attribute defines the number of columns a <col> element should span.


Browser Support

Syntax

<col span="number">

Attribute Values

Value Description
number Sets the number of columns a <col> element should span
index.html
Example: HTML
<table>
  <colgroup>
    <col span="2" style="background-color:red">
    <col style="background-color:yellow">
  </colgroup>
  <tr>
    <th>ISBN</th>
    <th>Title</th>
    <th>Price</th>
  </tr>
  <tr>
    <td>3476896</td>
    <td>My first HTML</td>
    <td>$53</td>
  </tr>
  <tr>
    <td>5869207</td>
    <td>My first CSS</td>
    <td>$49</td>
  </tr>
</table>

Output should be:

How to add HTML <col> span Attribute

# Tips-29) How to create HTML <colgroup> Tag

The <colgroup> tag specifies a group of one or more columns in a table for formatting.

The <colgroup> tag is useful for applying styles to entire columns, instead of repeating the styles for each cell, for each row.

Note: The <colgroup> tag must be a child of a <table> element, after any <caption> elements and before any <thead>, <tbody>, <tfoot>, and <tr> elements.

Tip: To define different properties to a column within a <colgroup>, use the <col> tag within the <colgroup> tag.

How to create HTML <colgroup> Tag

Set the background color of the three columns with the <colgroup> and <col> tags
index.html
Example: HTML
 <table>
  <colgroup>
    <col span="2" style="background-color:red">
    <col style="background-color:yellow">
  </colgroup>
  <tr>
    <th>ISBN</th>
    <th>Title</th>
    <th>Price</th>
  </tr>
  <tr>
    <td>3476896</td>
    <td>My first HTML</td>
    <td>$53</td>
  </tr>
</table> 

Output should be:

How to create HTML <colgroup> Tag

What Type of Browsers will Support for HTML <colgroup> Tag

Following Browser will support for it.

Output should be:

What Type of Browsers will Support for HTML <colgroup> Tag

Attributes for HTML <colgroup> Tag

Attribute Value Description
span number Specifies the number of columns a column group should span

How to set Default CSS Settings for HTML <colgroup> Tag

Most browsers will display the <colgroup> element with the following default values
index.html
Example: HTML
<style>
table, th, td {
  border: 1px solid black;
}

colgroup {
  display: table-column-group;
} 
</style>

Output should be:

How to set Default CSS Settings for HTML <colgroup> Tag

How to add HTML <colgroup> span Attribute

Set the background color of the first two columns using the <colgroup> span attribute:

Definition and Usage

The span attribute defines the number of columns a <colgroup> element should span.

Tip: To define different properties to a column within a <colgroup>, use the <col> tag within the <colgroup> tag.

Browser Support

Syntax

<colgroup span="number">

Attribute Values

Value Description
number Sets the number of columns a column group should span
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
  border: 1px solid black;
}
</style>
</head>
<body>

<h1>The colgroup span attribute</h1>

<table>
  <colgroup span="2" style="background:red"></colgroup>
  <tr>
    <th>ISBN</th>
    <th>Title</th>
    <th>Price</th>
  </tr>
  <tr>
    <td>3476896</td>
    <td>My first HTML</td>
    <td>$53</td>
  </tr>
  <tr>
    <td>5869207</td>
    <td>My first CSS</td>
    <td>$49</td>
  </tr>
</table>

</body>
</html>

Output should be:

How to add HTML <colgroup> span Attribute

# Tips-30) What is HTML <data> Tag

The tag is used to add a machine-readable translation of a given content.

This element provides both a machine-readable value for data processors, and a human-readable value for rendering in a browser.

Tip: If the content is time- or date-related, use the element instead.

How to create HTML <data> Tag

The following example displays product names but also associates each name with a product number
index.html
Example: HTML
 <ul>
  <li><data value="21053">Cherry Tomato</data></li>
  <li><data value="21054">Beef Tomato</data></li>
  <li><data value="21055">Snack Tomato</data></li>
</ul> 

Output should be:

How to create HTML <data> Tag

What Type of Browsers will Support for HTML <data> Tag

Following browsers will support for HTML <data> Tag
What Type of Browsers will Support for HTML <data> Tag

Attributes for HTML <data> Tag

Attribute Value Description
value machine-readable format Specifies the machine-readable translation of the content of the element

# Tips-31) What is HTML <datalist> Tag

The <datalist> tag specifies a list of pre-defined options for an <input> element.

The <datalist> tag is used to provide an "autocomplete" feature for <input> elements. Users will see a drop-down list of pre-defined options as they input data.

The <datalist> element's id attribute must be equal to the <input> element's list attribute (this binds them together).

How to create HTML <datalist> Tag

A datalist with pre-defined options (connected to an <input> element). The datalist tag is not supported in Safari 12.0 (or earlier).
index.html
Example: HTML
 <label for="browser">Choose your browser from the list:</label>
<input list="browsers" name="browser" id="browser">

<datalist id="browsers">
  <option value="Edge">
  <option value="Firefox">
  <option value="Chrome">
  <option value="Opera">
  <option value="Safari">
</datalist> 

Output should be:

How to create HTML <datalist> Tag

What Type of Browsers will Support for HTML <datalist> Tag

The numbers in the table specify the first browser version that fully supports the element.
What Type of Browsers will Support for HTML <datalist> Tag

How to set Default CSS Settings for HTML <datalist> Tag

Most browsers will display the <datalist> element with the following default values:
index.html
Example: HTML
<style>
datalist {
  display: none;
}
</style>

Output should be:

How to set Default CSS Settings for HTML <datalist> Tag

# Tips-32) What is HTML <dd> Tag

The <dd> tag is used to describe a term/name in a description list.

The <dd> tag is used in conjunction with <dl> (defines a description list) and <dt> (defines terms/names).

Inside a <dd> tag you can put paragraphs, line breaks, images, links, lists, etc.

How to create HTML <dd> Tag

A description list, with terms and descriptions
index.html
Example: HTML
 <dl>
  <dt>Coffee</dt>
  <dd>Black hot drink</dd>
  <dt>Milk</dt>
  <dd>White cold drink</dd>
</dl> 

Output should be:

How to create HTML <dd> Tag

What Type of Browsers will Support for HTML <dd> Tag

Following Browsers will support for IT.
What Type of Browsers will Support for HTML <dd> Tag

How to set Default CSS Settings for HTML <dd> Tag

Most browsers will display the <dd> element with the following default values
index.html
Example: HTML
<style>
dd { 
  display: block;
  margin-left: 40px;
}
</style>

Output should be:

How to set Default CSS Settings for HTML <dd> Tag

# Tips-33) What is HTML <del> Tag

The <del> tag defines text that has been deleted from a document. Browsers will usually strike a line through deleted text.

How to create HTML <del> Tag

A text with a deleted part, and a new, inserted part
index.html
Example: HTML
<p>My favorite color is <del>blue</del> <ins>red</ins>!</p>

Output should be:

How to create HTML <del> Tag

Tips and Notes for HTML <del> Tag

Tip: Also look at the <ins> tag to markup inserted text.

What Type of Browsers will Support for HTML <del> Tag

Following Browsers will support for HTML <del> Tag
What Type of Browsers will Support for HTML <del> Tag

Attributes for HTML <del> Tag

Attribute Value Description
cite URL Specifies a URL to a document that explains the reason why the text was deleted/changed
datetime YYYY-MM-DDThh:mm:ssTZD Specifies the date and time of when the text was deleted/changed

How to Use CSS to style <del> and <ins>

The del and ins elements + CSS
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
del {background-color: tomato;}
ins {background-color: yellow;}
</style>
</head>
<body>

<h1>The del and ins elements + CSS</h1>

<p>My favorite color is <del>blue</del> <ins>red</ins>!</p>

</body>
</html>

Output should be:

How to Use CSS to style <del> and <ins>

How to set Default CSS Settings for HTML <del> Tag

Most browsers will display the <del> element with the following default values
index.html
Example: HTML
<style>
del { 
  text-decoration: line-through;
}
</style>

Output should be:

How to set Default CSS Settings for HTML <del> Tag

How to add HTML <del> cite Attribute

A deleted text, with a URL to a document that explains why the text was deleted:

Definition and Usage

The cite attribute specifies a URL to a document that explains the reason why the text was deleted.


Browser Support

Note: The cite attribute has no visual effect in ordinary web browsers, but can be used by screen readers.


Syntax

<del cite="URL">

Attribute Values

Value Description
URL Specifies the address to the document that explains why the text was deleted.

Possible values:

  • An absolute URL - Points to another web site (like cite="http://www.example.com/page.htm")
  • A relative URL - Points to a page within a web site (like cite="page.htm")
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The del cite attribute</h1>

<p><del cite="del_demo_cite.htm">This text has been deleted</del></p>

</body>
</html>

Output should be:

How to add HTML <del> cite Attribute

How to add HTML <del> datetime Attribute

A deleted text, with a date and time of when the text was deleted.

Definition and Usage

The datetime attribute specifies the date and time when the text was deleted.


Browser Support

Note: The datetime attribute has no visual effect in ordinary web browsers, but can be used by screen readers.


Syntax

<del datetime="YYYY-MM-DDThh:mm:ssTZD">

Attribute Values

Value Description
YYYY-MM-DDThh:mm:ssTZD The date and time of when the text was deleted.

Explanation of components:

  • YYYY - year (e.g. 2012)
  • MM - month (e.g. 01 for January)
  • DD - day of the month (e.g. 08)
  • T or a space - a separator (required if time is also specified)
  • hh - hour (e.g. 22 for 10.00pm)
  • mm - minutes (e.g. 55)
  • ss - seconds (e.g. 03)
  • TZD - Time Zone Designator (Z denotes Zulu, also known as Greenwich Mean Time)
index.html
Example: HTML
<p>
<del datetime="2015-11-15T22:55:03Z">This text has been deleted</del>
</p>

Output should be:

How to add HTML <del> datetime Attribute

# Tips-34) What is HTML <details> Tag

The <details> tag specifies additional details that the user can open and close on demand.

The <details> tag is often used to create an interactive widget that the user can open and close. By default, the widget is closed. When open, it expands, and displays the content within.

Any sort of content can be put inside the <details> tag. 

Tip: The <summary> tag is used in conjunction with <details> to specify a visible heading for the details.

How to create HTML <details> Tag

Specify details that the user can open and close on demand
index.html
Example: HTML
 <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> 

Output should be:

How to create HTML <details> Tag

What Type of Browsers will Support for HTML <details> Tag

The numbers in the table specify the first browser version that fully supports the element.
What Type of Browsers will Support for HTML <details> Tag

Attributes for HTML <details> Tag

Attribute Value Description
open open Specifies that the details should be visible (open) to the user

How to set Default CSS Settings for HTML <details> Tag

The details and summary elements + CSS.
index.html
Example: HTML
 <html>
<style>
details > summary {
  padding: 4px;
  width: 200px;
  background-color: #eeeeee;
  border: none;
  box-shadow: 1px 1px 2px #bbbbbb;
  cursor: pointer;
}

details > p {
  background-color: #eeeeee;
  padding: 4px;
  margin: 0;
  box-shadow: 1px 1px 2px #bbbbbb;
}
</style>
<body>

<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>

</body>
</html> 

Output should be:

How to set Default CSS Settings for HTML <details> Tag

How to set Default CSS Settings for HTML <details> Tag

Most browsers will display the <details> element with the following default values.
index.html
Example: HTML
<style>
details {
  display: block;
}
</style>

Output should be:

How to set Default CSS Settings for HTML <details> Tag

How to add HTML <details> open Attribute

Definition and Usage

The open attribute is a boolean attribute.

When present, it specifies that the details should be visible (open) to the user.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<details open>

index.html
Example: HTML
<details open>
  <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> 

Output should be:

How to add HTML <details> open Attribute

# Tips-35) What is HTML <dfn> Tag

The <dfn> tag stands for the "definition element", and it specifies a term that is going to be defined within the content.

The nearest parent of the <dfn> tag must also contain the definition/explanation for the term.

The term inside the <dfn> tag can be any of the following.

Method-1: How to create HTML <dfn> Tag

Just as the content of the <dfn> element:
index.html
Example: HTML
<p><dfn>HTML</dfn> is the standard markup language for creating web pages.</p>

Output should be:

Method-1: How to create HTML <dfn> Tag

Method-2: How to create HTML <dfn> Tag

with the title attribute added
index.html
Example: HTML
<p><dfn title="HyperText Markup Language">HTML</dfn> is the standard markup language for creating web pages.</p> 

Output should be:

Method-2: How to create HTML <dfn> Tag

Method-3: How to create HTML <dfn> Tag

with an tag inside the element
index.html
Example: HTML
<p><dfn><abbr title="HyperText Markup Language">HTML</abbr></dfn> is the standard markup language for creating web pages.</p>

Output should be:

Method-3: How to create HTML <dfn> Tag

Method-4: How to create HTML <dfn> Tag

with the id attribute added. Then, whenever a term is used, it can refer back to the definition with an <a> tag

index.html
Example: HTML
<p><dfn id="html-def">HTML</dfn> is the standard markup 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> 

Output should be:

Method-4: How to create HTML <dfn> Tag

How to set Default CSS Settings for HTML <dfn> Tag

Most browsers will display the <dfn> element with the following default values.

index.html
Example: HTML
<style>
dfn { 
  font-style: italic;
}
</style>

Output should be:

How to set Default CSS Settings for HTML <dfn> Tag

# Tips-36) What is HTML <dialog> Tag

The <dialog> tag defines a dialog box or subwindow.

The <dialog> element makes it easy to create popup dialogs and modals on a web page.

How to create HTML <diolog> Tag

Using the <dialog> element

index.html
Example: HTML
<dialog open>This is an open dialog window</dialog>

Output should be:

How to create HTML <diolog> Tag

What Type of Browsers will Support for HTML <dialog> Tag

The numbers in the table specify the first browser version that fully supports the element.
What Type of Browsers will Support for HTML <dialog> Tag

Attributes for HTML <diolog> Tag

Attribute Value Description
open open Specifies that the dialog element is active and that the user can interact with it

How to add HTML <dialog> open Attribute

Using the <dialog> element.

Definition and Usage

The open attribute is a boolean attribute.

When present, it specifies that the dialog element is active and that the user can interact with it.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<dialog open>

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The dialog element</h1>

<p>This is some text.</p>

<p>This is some text.</p>

<dialog open>This is an open dialog window</dialog>

<p>This is some text.</p>

<p>This is some text.</p>

</body>
</html>

Output should be:

How to add HTML <dialog> open Attribute

# Tips-37) What is HTML <dir> Tag

Not Supported in HTML5.

The <dir> tag was used in HTML 4 to list directory titles.

It is also Defined a directory list.

What to Use Instead of HTML <dir> Tag?

Use <ul> to create a directory list
index.html
Example: HTML
<ul>
  <li>html</li>
  <li>xhtml</li>
  <li>css</li>
</ul>  

Output should be:

What to Use Instead of HTML <dir> Tag?

How to Reduce line-height in a list (with CSS)

Reduce line-height in a list (with CSS)

index.html
Example: HTML
<ul style="line-height:80%">
  <li>html</li>
  <li>xhtml</li>
  <li>css</li>
</ul>  

Output should be:

How to Reduce line-height in a list (with CSS)

# Tips-38) What is HTML <div> Tag

A <div> tag is used to maintain CSS Style in the most cases.

The <div> tag defines a division or a section in an HTML document.

The <div> tag is used as a container for HTML elements - which is then styled with CSS or manipulated with JavaScript.

The <div> tag is easily styled by using the class or id attribute.

Any sort of content can be put inside the <div> tag! 

Note: By default, browsers always place a line break before and after the <div> element.

How to create HTML <div> Tag

A <div> section in a document that is styled with CSS
index.html
Example: HTML
 <html>
<head>
<style>
.myDiv {
  border: 5px outset red;
  background-color: lightblue;
  text-align: center;
}
</style>
</head>
<body>

<div class="myDiv">
  <h2>This is a heading in a div element</h2>
  <p>This is some text in a div element.</p>
</div>

</body>
</html> 

Output should be:

How to create HTML <div> Tag

What Type of Browsers will Support for HTML <div> Tag

Following Browsers will support for HTML <div> Tag.
What Type of Browsers will Support for HTML <div> Tag

How to set Default CSS Settings for HTML <div> Tag

Most browsers will display the <div> element with the following default values.
index.html
Example: HTML
<style>
div { 
  display: block;
}
</style>

Output should be:

How to set Default CSS Settings for HTML <div> Tag

# Tips-39) What is HTML <dl> Tag

The <dl> tag defines a description list.

The <dl> tag is used in conjunction with <dt> (defines terms/names) and <dd> (describes each term/name).

How t create HTML <dl> Tag

 <dl>
  <dt>Coffee</dt>
  <dd>Black hot drink</dd>
  <dt>Milk</dt>
  <dd>White cold drink</dd>
</dl> 

Output should be:

How t create HTML <dl> Tag

What Type of Browsers will Support for HTML <dl> Tag

Following Browsers will support for HTML <dl> Tag
What Type of Browsers will Support for HTML <dl> Tag

What Type of Browsers will Support for HTML <div> Tag

<style>
dl {
  display: block;
  margin-top: 1em;
  margin-bottom: 1em;
  margin-left: 0;
  margin-right: 0;
}
</style>

Output should be:

What Type of Browsers will Support for HTML <div> Tag

# Tips-40) What is HTML <dt> Tag

The <dt> tag defines a term/name in a description list.

The <dt> tag is used in conjunction with <dl> (defines a description list) and <dd> (describes each term/name).

How to create HTML <dt> Tag

A description list, with terms and descriptions
index.html
Example: HTML
 <dl>
  <dt>Coffee</dt>
  <dd>Black hot drink</dd>
  <dt>Milk</dt>
  <dd>White cold drink</dd>
</dl> 

Output should be:

How to create HTML <dt> Tag

What Type of Browsers will Support for HTML <dt> Tag

See which browsers will support
What Type of Browsers will Support for HTML <dt> Tag

How to set Default CSS Settings for HTML <dt> Tag

Most browsers will display the <dt> element with the following default values:
index.html
Example: HTML
<style>
dt {
  display: block;
}
</style>

Output should be:

How to set Default CSS Settings for HTML <dt> Tag

# Tips-41) What is HTML <em> Tag

HTML <em> Tag Mark up emphasized text in a document:

The <em> tag is used to define emphasized text. The content inside is typically displayed in italic.

A screen reader will pronounce the words in <em> with an emphasis, using verbal stress.

How to create HTML <em> Tag

HTML <em> Tag Mark up emphasized text in a document:
index.html
Example: HTML
<p>You <em>have</em> to hurry up!</p>

<p>We <em>cannot</em> live like this.</p>

Output should be:

How to create HTML <em> Tag

The following browser are supported

Which browser will support
The following browser are supported

How to set Default CSS Settings for HTML <em> Tag

Most browsers will display the <em> element with the following default values
index.html
Example: HTML
<style>
em { 
  font-style: italic;
}
</style>

Output should be:

How to set Default CSS Settings for HTML <em> Tag

# Tips-42) What is HTML <embed> Tag

The <embed> tag defines a container for an external resource, such as a web page, a picture, a media player, or a plug-in application.

Warning

Most browsers no longer support Java Applets and Plug-ins.

ActiveX controls are no longer supported in any browsers.

The support for Shockwave Flash has also been turned off in modern browsers.

Suggestion

To display a picture, it is better to use the <img> tag.

To display HTML, it is better to use the <iframe> tag.

To display video or audio, it is better to use the <video> and <audio> tags.

How to create An embedded image

The embed element
index.html
Example: HTML
<embed type="image/jpg" src="https://horje.com/avatar.png" width="300" height="200"> 

Output should be:

How to create An embedded image

How to create An embedded HTML page

The embed element
index.html
Example: HTML
<embed type="text/html" src="https://horje.com/learn/665/what-is-html-em-tag"  width="500" height="200">

Output should be:

How to create An embedded HTML page

How to create An embedded video

embedded video
index.html
Example: HTML
<embed type="video/webm" src="https://www.w3schools.com/tags/movie.mp4" width="400" height="300">

Output should be:

How to create An embedded video

What Browser will support for HTML embed Tag

Which browsers will support
What Browser will support for HTML embed Tag

Attributes for HTML <embed> Tag

Attribute Value Description
height pixels Specifies the height of the embedded content
src URL Specifies the address of the external file to embed
type media_type Specifies the media type of the embedded content
width pixels Specifies the width of the embedded content

How to set Default CSS Settings for HTML <embed> Tag

Most browsers will display the <embed> element with the following default values
index.html
Example: HTML
<style>
embed:focus {
  outline: none;
}
</style>

Output should be:

How to set Default CSS Settings for HTML <embed> Tag

How to add HTML <embed> height Attribute

A picture with a height and width of 200 pixels.

Definition and Usage

The height attribute specifies the height of the embedded content, in pixels.

Tip: Use the width attribute to specify the width of the embedded content.


Browser Support

Syntax

<embed height="pixels">

Attribute Values

Value Description
pixels The height of the embedded content, in pixels (i.e. height="100")
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The embed height and width attributes</h1>

<embed type="image/jpg" src="https://horje.com/avatar.png" width="200" height="200">

</body>
</html>

Output should be:

How to add HTML <embed> height Attribute

How to add HTML <embed> src Attribute

An embedded picture.

Definition and Usage

The src attribute specifies the address of the external file to embed.


Browser Support

Syntax

<embed src="URL">

Attribute Values

Value Description
URL Specifies the address of the external file to embed.

Possible values:

  • An absolute URL - points to another web site (like href="http://www.example.com/hello.swf")
  • A relative URL - points to a file within a web site (like href="hello.swf")
index.html
Example: HTML
<embed src="https://horje.com/avatar.png">

Output should be:

How to add HTML <embed> src Attribute

How to add HTML <embed> type Attribute

A picture with a specified media type.

Definition and Usage

The type attribute specifies the Internet media type (formerly known as MIME type) of the embedded content.


Browser Support

Syntax

<embed type="media_type">

Attribute Values

Value Description
media_type The Internet media type of the embedded content.
Look at IANA Media Types for a complete list of standard media types.
index.html
Example: HTML
<embed type="image/jpg" src="https://horje.com/avatar.png">

Output should be:

How to add HTML <embed> type Attribute

How to add HTML <embed> width Attribute

A picture with a height and width of 200 pixels.

Definition and Usage

The width attribute specifies the width of the embedded content, in pixels.

Tip: Use the height attribute to specify the height of the embedded content.


Browser Support

Syntax

<embed width="pixels">

Attribute Values

Value Description
pixels The width of the embedded content, in pixels (i.e. width="100")
index.html
Example: HTML
<embed type="image/jpg" src="https://horje.com/avatar.png" width="200" height="200">

Output should be:

How to add HTML <embed> width Attribute

# Tips-43) What is HTML <fieldset> Tag

The <fieldset> tag is used to group related elements in a form.

The <fieldset> tag draws a box around the related elements.


Tips and Notes

Tip: The <legend> tag is used to define a caption for the <fieldset> element.

How to create HTML <fieldset> Tag

Group related elements in a form
index.html
Example: HTML
<form action="/action_page.php">
  <fieldset>
    <legend>Personalia:</legend>
    <label for="fname">First name:</label>
    <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>
    <input type="email" id="email" name="email"><br><br>
    <label for="birthday">Birthday:</label>
    <input type="date" id="birthday" name="birthday"><br><br>
    <input type="submit" value="Submit">
  </fieldset>
</form> 

Output should be:

How to create HTML <fieldset> Tag

Which browser will support for HTML <fieldset> Tag

The following browsers is supported.
Which browser will support for HTML <fieldset> Tag

Attributes for HTML <fieldset> Tag

Attribute Value Description
disabled disabled Specifies that a group of related form elements should be disabled
form form_id Specifies which form the fieldset belongs to
name text Specifies a name for the fieldset

How to Use CSS to style <fieldset> and <legend>

The fieldset element + CSS
index.html
Example: HTML
<form action="/action_page.php">
  <fieldset>
    <legend>Personalia:</legend>
    <label for="fname">First name:</label>
    <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>
    <input type="email" id="email" name="email"><br><br>
    <label for="birthday">Birthday:</label>
    <input type="date" id="birthday" name="birthday"><br><br>
    <input type="submit" value="Submit">
  </fieldset>
</form>

Output should be:

How to Use CSS to style <fieldset> and <legend>

How to set Default CSS Settings for HTML <fieldset> Tag

Most browsers will display the <fieldset> element with the following default values:
index.html
Example: HTML
<style>
fieldset {
  display: block;
  margin-left: 2px;
  margin-right: 2px;
  padding-top: 0.35em;
  padding-bottom: 0.625em;
  padding-left: 0.75em;
  padding-right: 0.75em;
  border: 2px groove (internal value);
}
</style>

Output should be:

How to set Default CSS Settings for HTML <fieldset> Tag

How to add HTML <fieldset> disabled Attribute

Disable a group of related form elements.

Definition and Usage

The disabled attribute is a boolean attribute.

When present, it specifies that a group of related form elements (a fieldset) should be disabled.

A disabled fieldset is unusable and un-clickable.

The disabled attribute can be set to keep a user from using the fields until some other condition has been met (like selecting a checkbox, etc.). Then, a JavaScript could remove the disabled value, and make the fieldset usable again.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<fieldset disabled>

index.html
Example: HTML
<form>
<form action="/action_page.php">
  <fieldset disabled>
    <legend>Personalia:</legend>
    <label for="fname">First name:</label>
    <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>
    <input type="email" id="email" name="email"><br><br>
    <label for="birthday">Birthday:</label>
    <input type="date" id="birthday" name="birthday"><br><br>
    <input type="submit" value="Submit">
  </fieldset>
</form>
</form>

Output should be:

How to add HTML <fieldset> disabled Attribute

How to add HTML <fieldset> form Attribute

A <fieldset> element located outside a form (but still a part of the form).

Definition and Usage

The form attribute specifies the form the fieldset belongs to.

The value of this attribute must be equal to the id attribute of a <form> element in the same document.

Browser Support

Syntax

<fieldset form="form_id">

Attribute Values

Value Description
form_id Specifies the form element the <fieldset> element belongs to. The value of this attribute must be the id attribute of a <form> element in the same document.
index.html
Example: HTML
<form action="/action_page.php" method="get" id="form1">
  <label for="favcolor">What is your favorite color?</label>
  <input type="text" id="favcolor" name="favcolor">
  <input type="submit">
</form>

<fieldset form="form1">
  <legend>Personalia:</legend>
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname" form="form1"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname" form="form1">
</fieldset> 

Output should be:

How to add HTML <fieldset> form Attribute

How to add HTML <fieldset> name Attribute

A <fieldset> with a name attribute.

Definition and Usage

The name attribute specifies a name for a fieldset.

The name attribute is used to reference elements in a JavaScript, or to reference form data after a form is submitted.


Browser Support

Syntax

<fieldset name="text">

Attribute Values

Value Description
name Specifies the name of the fieldset
index.html
Example: HTML
<form action="/action_page.php" method="get">
  <fieldset name="personalia">
    <label for="fname">First name:</label>
    <input type="text" id="fname" name="fname">
  </fieldset>
  <br>
  <button type="button"
  onclick="form.personalia.style.backgroundColor='yellow'">
  Change background color of fieldset</button>
  <input type="submit">
</form> 

Output should be:

How to add HTML <fieldset> name Attribute

# Tips-44) What is HTML <figcaption> Tag

The <figcaption> tag defines a caption for a <figure> element.

The <figcaption> element can be placed as the first or last child of the <figure> element.

How to create HTML <figcaption> Tag

Use a <figure> element to mark up a photo in a document, and a <figcaption> element to define a caption for the photo:
index.html
Example: HTML
<figure>
  <img src="https://horje.com/avatar.png" alt="Trulli" style="width:100%">
  <figcaption>Fig.1 - Trulli, Puglia, Italy.</figcaption>
</figure>

Output should be:

How to create HTML <figcaption> Tag

Which browser will support for HTML <figcaption> Tag

The numbers in the table specify the first browser version that fully supports the element.
Which browser will support for HTML <figcaption> Tag

How to Use CSS to style <figure> and <figcaption>

The figure and figcaption elements + CSS
index.html
Example: HTML
<style>
figure {
  border: 1px #cccccc solid;
  padding: 4px;
  margin: auto;
}

figcaption {
  background-color: black;
  color: white;
  font-style: italic;
  padding: 2px;
  text-align: center;
}
</style>

<figure>
  <img src="https://horje.com/avatar.png" alt="Trulli" style="width:100%">
  <figcaption>Fig.1 - Trulli, Puglia, Italy</figcaption>
</figure>

Output should be:

How to Use CSS to style <figure> and <figcaption>

How to set Default CSS Settings for HTML <figcaption> Tag

<style>
figcaption {
  display: block;
}
</style>

Output should be:

How to set Default CSS Settings for HTML <figcaption> Tag

# Tips-45) What is HTML <figure> Tag

The <figure> tag specifies self-contained content, like illustrations, diagrams, photos, code listings, etc.

While the content of the <figure> element is related to the main flow, its position is independent of the main flow, and if removed it should not affect the flow of the document.

Tip: The <figcaption> element is used to add a caption for the <figure> element.

How to create HTML <figure> Tag

Use a <figure> element to mark up a photo in a document, and a <figcaption> element to define a caption for the photo
index.html
Example: HTML
<figure>
  <img src="https://horje.com/avatar.png" alt="Trulli" style="width:100%">
  <figcaption>Fig.1 - Trulli, Puglia, Italy.</figcaption>
</figure>

Output should be:

How to create HTML <figure> Tag

Which browser will support for HTML <figure> Tag

The numbers in the table specify the first browser version that fully supports the element.
Which browser will support for HTML <figure> Tag

How to Use CSS to style <figure> and <figcaption>

The figure and figcaption elements + CSS
index.html
Example: HTML
<style>
figure {
  border: 1px #cccccc solid;
  padding: 4px;
  margin: auto;
}

figcaption {
  background-color: black;
  color: white;
  font-style: italic;
  padding: 2px;
  text-align: center;
}
</style>

<figure>
  <img src="https://horje.com/avatar.png" alt="Trulli" style="width:100%">
  <figcaption>Fig.1 - Trulli, Puglia, Italy</figcaption>
</figure>

Output should be:

How to Use CSS to style <figure> and <figcaption>

How to set Default CSS Settings

Most browsers will display the <figure> element with the following default values
index.html
Example: HTML
<style>
figure {
  display: block;
  margin-top: 1em;
  margin-bottom: 1em;
  margin-left: 40px;
  margin-right: 40px;
}
</style>

Output should be:

How to set Default CSS Settings

# Tips-46) What is HTML <font> Tag

Not Supported in HTML5.

The <font> tag was used in HTML 4 to specify the font face, font size, and color of text.

What should Use Instead of HTML <font> Tag

Set the color of text (with CSS)
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<p style="color:red">This is a paragraph.</p>
<p style="color:blue">This is another paragraph.</p>

</body>
</html>

Output should be:

What should Use Instead of HTML <font> Tag

How to Set the font of text (with CSS)

See the Example.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<p style="font-family:verdana">This is a paragraph.</p>
<p style="font-family:'Courier New'">This is another paragraph.</p>

</body>
</html>

Output should be:

How to Set the font of text (with CSS)

How to Set the size of text (with CSS)

See the Example
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<p style="font-size:30px">This is a paragraph.</p>
<p style="font-size:11px">This is another paragraph.</p>

</body>
</html>

Output should be:

How to Set the size of text (with CSS)

# Tips-47) What is HTML <footer> Tag

The <footer> tag defines a footer for a document or section.

A <footer> element typically contains:

  • authorship information
  • copyright information
  • contact information
  • sitemap
  • back to top links
  • related documents

You can have several <footer> elements in one document.

How to create HTML <footer> Tag

A footer section in a document
index.html
Example: HTML
<footer>
  <p>Author: Hege Refsnes<br>
  <a href="mailto:[email protected]">[email protected]</a></p>
</footer>

Output should be:

How to create HTML <footer> Tag

Which browser will support for HTML <footer> Tag

The numbers in the table specify the first browser version that fully supports the element.
Which browser will support for HTML <footer> Tag

How to Use CSS to style <footer>

See the Example
index.html
Example: HTML
<html>
<head>
<style>
footer {
  text-align: center;
  padding: 3px;
  background-color: DarkSalmon;
  color: white;
}
</style>
</head>
<body>

<footer>
  <p>Author: Hege Refsnes<br>
  <a href="mailto:[email protected]">[email protected]</a></p>
</footer>

</body>
</html>

Output should be:

How to Use CSS to style <footer>

How to set Default CSS Settings for HTML <footer> Tag

Most browsers will display the <footer> element with the following default values
index.html
Example: HTML
<style>
footer {
  display: block;
}
</style>

Output should be:

How to set Default CSS Settings for HTML <footer> Tag

# Tips-48) What is HTML <form> Tag

The <form> tag is used to create an HTML form for user input.

The <form> element can contain one or more of the following form elements:

  • <input>
  • <textarea>
  • <button>
  • <select>
  • <option>
  • <optgroup>
  • <fieldset>
  • <label>
  • <output>

How to create HTML <form> Tag

An HTML form with two input fields and one submit button
index.html
Example: HTML
<form action="/action_page.php">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="submit" value="Submit">
</form>

Output should be:

How to create HTML <form> Tag

Which browser will support for HTML <form> Tag

See the screen
Which browser will support for HTML <form> Tag

Attributes for HTML <form> Tag

Attribute Value Description
accept-charset character_set Specifies the character encodings that are to be used for the form submission
action URL Specifies where to send the form-data when a form is submitted
autocomplete on
off
Specifies whether a form should have autocomplete on or off
enctype application/x-www-form-urlencoded
multipart/form-data
text/plain
Specifies how the form-data should be encoded when submitting it to the server (only for method="post")
method get
post
Specifies the HTTP method to use when sending form-data
name text Specifies the name of a form
novalidate novalidate Specifies that the form should not be validated when submitted
rel external
help
license
next
nofollow
noopener
noreferrer
opener
prev
search
Specifies the relationship between a linked resource and the current document
target _blank
_self
_parent
_top
Specifies where to display the response that is received after submitting the form

How to use An HTML form with checkboxes

See the Example
index.html
Example: HTML
<form action="/action_page.php" method="get">
  <input type="checkbox" name="vehicle1" value="Bike">
  <label for="vehicle1"> I have a bike</label><br>
  <input type="checkbox" name="vehicle2" value="Car">
  <label for="vehicle2"> I have a car</label><br>
  <input type="checkbox" name="vehicle3" value="Boat" checked>
  <label for="vehicle3"> I have a boat</label><br><br>
  <input type="submit" value="Submit">
</form>

Output should be:

How to use An HTML form with checkboxes

How to use An HTML form with radiobuttons

See the Example
index.html
Example: HTML
<form action="/action_page.php" method="get">
  <input type="radio" id="html" name="fav_language" value="HTML">
  <label for="html">HTML</label><br>
  <input type="radio" id="css" name="fav_language" value="CSS" checked="checked">
  <label for="css">CSS</label><br>
  <input type="radio" id="javascript" name="fav_language" value="JavaScript">
  <label for="javascript">JavaScript</label><br><br>
  <input type="submit" value="Submit">
</form>

Output should be:

How to use An HTML form with radiobuttons

How to set Default CSS Settings for HTML <form> Tag

Most browsers will display the <form> element with the following default values
index.html
Example: HTML
<style>
form { 
  display: block;
  margin-top: 0em;
}
</style>

Output should be:

How to set Default CSS Settings for HTML <form> Tag

How to add HTML <form> accept-charset Attribute

A form with an accept-charset attribute.

Definition and Usage

The accept-charset attribute specifies the character encodings that are to be used for the form submission. 


Browser Support

Syntax

<form accept-charset="character_set">

Attribute Values

Value Description
character_set A space-separated list of one or more character encodings that are to be used for the form submission.

Common values:

  • UTF-8 - Character encoding for Unicode
  • ISO-8859-1 - Character encoding for the Latin alphabet

In theory, any character encoding can be used, but no browser understands all of them. The more widely a character encoding is used, the better the chance that a browser will understand it.

To view all available character encodings, go to our Character sets reference.

index.html
Example: HTML
<form action="/action_page.php" accept-charset="utf-8">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <input type="submit" value="Submit">
</form> 

Output should be:

How to add HTML <form> accept-charset Attribute

How to add HTML <form> action Attribute

On submit, send the form-data to a file named "action_page.php" (to process the input):

Definition and Usage

The action attribute specifies where to send the form-data when a form is submitted.


Browser Support

Syntax

<form action="URL">

Attribute Values

Value Description
URL Where to send the form-data when the form is submitted.

Possible values:

  • An absolute URL - points to another web site (like action="http://www.example.com/example.htm")
  • A relative URL - points to a file within a web site (like action="example.htm")
index.html
Example: HTML
<form action="/action_page.php" method="get">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="submit" value="Submit">
</form> 

Output should be:

How to add HTML <form> action Attribute

How to add HTML <form> autocomplete Attribute

A form with autocomplete on.

Definition and Usage

The autocomplete attribute specifies whether a form should have autocomplete on or off.

When autocomplete is on, the browser automatically complete values based on values that the user has entered before.

Tip: It is possible to have autocomplete "on" for the form, and "off" for specific input fields, or vice versa.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<form autocomplete="on|off">

Attribute Values

Value Description
on Default. The browser will automatically complete values based on values that the user has entered before
off The user must enter a value into each field for every use. The browser does not automatically complete entries
index.html
Example: HTML
<form action="/action_page.php" method="get" autocomplete="on">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="email">Email:</label>
  <input type="text" id="email" name="email"><br><br>
  <input type="submit">
</form> 

Output should be:

How to add HTML <form> autocomplete Attribute

How to add HTML <form> autocomplete on Attribute

on Default. The browser will automatically complete values based on values that the user has entered before
index.html
Example: HTML
<form action="/action_page.php" method="get" autocomplete="on">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="email">Email:</label>
  <input type="text" id="email" name="email"><br><br>
  <input type="submit">
</form>

Output should be:

How to add HTML <form> autocomplete on Attribute

How to add HTML <form> autocomplete off Attribute

off The user must enter a value into each field for every use. The browser does not automatically complete entries
index.html
Example: HTML
<form action="/action_page.php" method="get" autocomplete="off">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="email">Email:</label>
  <input type="text" id="email" name="email"><br><br>
  <input type="submit">
</form>

Output should be:

How to add HTML <form> autocomplete off Attribute

How to add HTML <form> enctype Attribute

Send form-data encoded as "multipart/form-data".

Definition and Usage

The enctype attribute specifies how the form-data should be encoded when submitting it to the server.

Note: The enctype attribute can be used only if method="post".


Browser Support

Syntax

<form enctype="value">

Attribute Values

Value Description
application/x-www-form-urlencoded Default. All characters are encoded before sent (spaces are converted to "+" symbols, and special characters are converted to ASCII HEX values)
multipart/form-data  This value is necessary if the user will upload a file through the form
text/plain Sends data without any encoding at all. Not recommended
index.html
Example: HTML
<form action="/action_page_binary.asp" method="post" enctype="multipart/form-data">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="submit" value="Submit">
</form>

Output should be:

How to add HTML <form> enctype Attribute

How to add HTML <form> enctype application/x-www-form-urlencoded Attribute

application/x-www-form-urlencoded Default. All characters are encoded before sent (spaces are converted to "+" symbols, and special characters are converted to ASCII HEX values)
index.html
Example: HTML
<form action="/action_page_binary.asp" method="post" enctype="application/x-www-form-urlencoded">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="submit" value="Submit">
</form>

Output should be:

How to add HTML <form> enctype application/x-www-form-urlencoded Attribute

How to add HTML <form> enctype multipart/form-data Attribute

multipart/form-data  This value is necessary if the user will upload a file through the form
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The form enctype attribute</h1>

<form action="/action_page_binary.asp" method="post" enctype="multipart/form-data">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="submit" value="Submit">
</form>

</body>
</html>

Output should be:

How to add HTML <form> enctype multipart/form-data Attribute

How to add HTML <form> enctype text/plain Attribute

text/plain Sends data without any encoding at all. Not recommended
index.html
Example: HTML
<form action="/action_page_binary.asp" method="post" enctype="multipart/form-data">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="submit" value="Submit">
</form>

Output should be:

How to add HTML <form> enctype text/plain Attribute

How to add HTML <form> method Attribute

Submit a form using the "get" method.


Definition and Usage

The method attribute specifies how to send form-data (the form-data is sent to the page specified in the action attribute).

The form-data can be sent as URL variables (with method="get") or as HTTP post transaction (with method="post").

Notes on GET:

  • Appends form-data into the URL in name/value pairs
  • The length of a URL is limited (about 3000 characters)
  • Never use GET to send sensitive data! (will be visible in the URL)
  • Useful for form submissions where a user wants to bookmark the result
  • GET is better for non-secure data, like query strings in Google

Notes on POST:

  • Appends form-data inside the body of the HTTP request (data is not shown in URL)
  • Has no size limitations
  • Form submissions with POST cannot be bookmarked

Browser Support

Syntax

<form method="get|post">

Attribute Values

Value Description
get Default. Appends the form-data to the URL in name/value pairs: URL?name=value&name=value
post Sends the form-data as an HTTP post transaction
index.html
Example: HTML
<form action="/action_page.php" method="get" target="_blank">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="submit" value="Submit">
</form>

Output should be:

How to add HTML <form> method Attribute

How to add HTML <form> method get Attribute

get Default. Appends the form-data to the URL in name/value pairs: URL?name=value&name=value
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The form method="get" attribute</h1>

<form action="/action_page.php" method="get" target="_blank">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="submit" value="Submit">
</form>

<p>Click on the submit button, and the input will be sent to a page on the server called "action_page.php".</p>

</body>
</html>

Output should be:

How to add HTML <form> method get Attribute

How to add HTML <form> method post Attribute

post Sends the form-data as an HTTP post transaction
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The form method="get" attribute</h1>

<form action="/action_page.php" method="post" target="_blank">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="submit" value="Submit">
</form>

<p>Click on the submit button, and the input will be sent to a page on the server called "action_page.php".</p>

</body>
</html>

Output should be:

 How to add HTML <form> method post Attribute

How to add HTML <form> name Attribute

An HTML form with a name attribute.

Definition and Usage

The name attribute specifies the name of a form.

The name attribute is used to reference elements in a JavaScript, or to reference form data after a form is submitted.


Browser Support

Syntax

<form name="text">

Attribute Values

Value Description
text Specifies the name of the form
index.html
Example: HTML
<form action="/action_page.php" method="get" name="myForm">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="button" onclick="formSubmit()" value="Send form data!">
</form> 

Output should be:

How to add HTML <form> name Attribute

How to add HTML <form> novalidate Attribute

Indicate that the form is not to be validated on submit.

Definition and Usage

The novalidate attribute is a boolean attribute.

When present, it specifies that the form-data (input) should not be validated when submitted.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<form novalidate>

index.html
Example: HTML
<form action="/action_page.php" novalidate>
  <label for="email">Enter your email:</label>
  <input type="email" id="email" name="email"><br><br>
  <input type="submit">
</form> 

Output should be:

How to add HTML <form> novalidate Attribute

How to add HTML <form> rel Attribute

Definition and Usage

The rel attribute specifies the relationship between the current document and the linked document.


Browser Support

Syntax

<form rel="value">

Attribute Values

Value Description
external Specifies that the referenced document is not a part of the current site
help Links to a help document
license Links to copyright information for the document
next The next document in a selection
nofollow Links to an unendorsed document, like a paid link.
("nofollow" is used by Google, to specify that the Google search spider should not follow that link)
noopener  
noreferrer Specifies that the browser should not send a HTTP referrer header if the user follows the hyperlink
opener  
prev The previous document in a selection
search Links to a search tool for the document
index.html
Example: HTML
<!DOCTYPE html> 
<html> 
  
<body> 
    <h2 style="color: green">Horje</h2> 
    <h2>HTML form Attribute</h2> 
  
    <b>This will avoid information passed to the post page </b> 
  
    <!-- It avoids passing the referrer information 
        to target website by removing the referral  
        info from the HTTP header. 
        It is safe to use -->
    <form rel="noreferrer" action="mypage.php"> 
        <input type="search" placeholder="search here" /> 
        <input type="button" value="search" /> 
    </form> 
</body> 
  
</html>

Output should be:

How to add HTML <form> rel Attribute

How to add HTML <form> rel external Attribute

external Specifies that the referenced document is not a part of the current site
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>
<h2 style="color: green">Horje</h2>
<h2>HTML form Attribute</h2>
<b>This will avoid information passed to the post page </b>
<!-- It avoids passing the referrer information
to target website by removing the referral
info from the HTTP header.
It is safe to use -->
<form rel="external" action="mypage.php">
<input type="search" placeholder="search here" />
<input type="button" value="search" />
</form>
</body>
</html>

Output should be:

How to add HTML <form> rel external Attribute

How to add HTML <form> rel help Attribute

help Links to a help document
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>
<h2 style="color: green">Horje</h2>
<h2>HTML form Attribute</h2>
<form rel="help" action="mypage.php">
<input type="search" placeholder="search here" />
<input type="button" value="search" />
</form>
</body>
</html>

Output should be:

How to add HTML <form> rel help Attribute

How to add HTML <form> rel license Attribute

license Links to copyright information for the document
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>
<h2 style="color: green">Horje</h2>
<h2>HTML form Attribute</h2>
<form rel="license" action="mypage.php">
<input type="search" placeholder="search here" />
<input type="button" value="search" />
</form>
</body>
</html>

Output should be:

How to add HTML <form> rel license Attribute

How to add HTML <form> rel next Attribute

next The next document in a selection
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>
<h2 style="color: green">Horje</h2>
<h2>HTML form Attribute</h2>
<form rel="next" action="mypage.php">
<input type="search" placeholder="search here" />
<input type="button" value="search" />
</form>
</body>
</html>

Output should be:

How to add HTML <form> rel next Attribute

How to add HTML <form> rel nofollow Attribute

nofollow Links to an unendorsed document, like a paid link.
("nofollow" is used by Google, to specify that the Google search spider should not follow that link)
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>
<h2 style="color: green">Horje</h2>
<h2>HTML form Attribute</h2>
<form rel="nofollow" action="mypage.php">
<input type="search" placeholder="search here" />
<input type="button" value="search" />
</form>
</body>
</html>

Output should be:

How to add HTML <form> rel nofollow Attribute

How to add HTML <form> rel noopener Attribute

noopener will avoid robots.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>
<h2 style="color: green">Horje</h2>
<h2>HTML form Attribute</h2>
<form rel="noopener" action="mypage.php">
<input type="search" placeholder="search here" />
<input type="button" value="search" />
</form>
</body>
</html>

Output should be:

How to add HTML <form> rel noopener Attribute

How to add HTML <form> rel noreferrer Attribute

noreferrer Specifies that the browser should not send a HTTP referrer header if the user follows the hyperlink
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>
<h2 style="color: green">Horje</h2>
<h2>HTML form Attribute</h2>
<form rel="noreferrer" action="mypage.php">
<input type="search" placeholder="search here" />
<input type="button" value="search" />
</form>
</body>
</html>

Output should be:

How to add HTML <form> rel noreferrer Attribute

How to add HTML <form> rel opener Attribute

opener will appear that robots won't open the page.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>
<h2 style="color: green">Horje</h2>
<h2>HTML form Attribute</h2>
<form rel="opener" action="mypage.php">
<input type="search" placeholder="search here" />
<input type="button" value="search" />
</form>
</body>
</html>

Output should be:

How to add HTML <form> rel opener Attribute

How to add HTML <form> rel prev Attribute

prev The previous document in a selection
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>
<h2 style="color: green">Horje</h2>
<h2>HTML form Attribute</h2>
<form rel="prev" action="mypage.php">
<input type="search" placeholder="search here" />
<input type="button" value="search" />
</form>
</body>
</html>

Output should be:

How to add HTML <form> rel prev Attribute

How to add HTML <form> rel search Attribute

search Links to a search tool for the document
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>
<h2 style="color: green">Horje</h2>
<h2>HTML form Attribute</h2>
<form rel="search" action="mypage.php">
<input type="search" placeholder="search here" />
<input type="button" value="search" />
</form>
</body>
</html>

Output should be:

How to add HTML <form> rel search Attribute

How to add HTML <form> target Attribute

Display the response received in a new window or tab.

Definition and Usage

The target attribute specifies a name or a keyword that indicates where to display the response that is received after submitting the form.

The target attribute defines a name of, or keyword for, a browsing context (e.g. tab, window, or inline frame).


Browser Support

Syntax

<form target="_blank|_self|_parent|_top|framename">

Attribute Values

Value Description
_blank The response is displayed in a new window or tab
_self The response is displayed in the same frame (this is default)
_parent The response is displayed in the parent frame
_top The response is displayed in the full body of the window
framename The response is displayed in a named iframe
index.html
Example: HTML
<form action="/action_page.php" method="get" target="_blank">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="submit" value="Submit">
</form> 

Output should be:

How to add HTML <form> target Attribute

How to add HTML <form> target _blank Attribute

_blank The response is displayed in a new window or tab
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The form target attribute</h1>

<form action="/action_page.php" method="get" target="_blank">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="submit" value="Submit">
</form>

</body>
</html>

Output should be:

How to add HTML <form> target _blank Attribute

How to add HTML <form> target _self Attribute

_self The response is displayed in the same frame (this is default)
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The form target attribute</h1>

<form action="/action_page.php" method="get" target="_self">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="submit" value="Submit">
</form>

</body>
</html>

Output should be:

How to add HTML <form> target _self Attribute

How to add HTML <form> target _parent Attribute

_parent The response is displayed in the parent frame
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The form target attribute</h1>

<form action="/action_page.php" method="get" target="_parent">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="submit" value="Submit">
</form>

</body>
</html>

Output should be:

How to add HTML <form> target _parent Attribute

How to add HTML <form> target _top Attribute

_top The response is displayed in the full body of the window
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The form target attribute</h1>

<form action="/action_page.php" method="get" target="_top">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="submit" value="Submit">
</form>

</body>
</html>

Output should be:

How to add HTML <form> target _top Attribute

How to add HTML <form> target framename Attribute

framename The response is displayed in a named iframe
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The form target attribute</h1>

<form action="/action_page.php" method="get" target="framename">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="submit" value="Submit">
</form>

</body>
</html>

Output should be:

How to add HTML <form> target framename Attribute

# Tips-49) What is HTML <frame> Tag

Not Supported in HTML5.

The <frame> tag was used in HTML 4 to define one particular window (frame) within a <frameset>.

What should Use Instead of HTML <frame> Tag

Use the <iframe> tag to embed another document within the current HTML document
index.html
Example: HTML
<iframe src="https://horje.com/learn/672/what-is-html-form-tag" title="Horje Free Online Web Tutorials">
</iframe>

Output should be:

What should Use Instead of HTML <frame> Tag

# Tips-50) What is HTML <frameset> Tag

Not Supported in HTML5.

The <frameset> tag was used in HTML 4 to define a frameset.

What should Use Instead of HTML <frameset> Tag

Use the <iframe> tag to embed another document within the current HTML document
index.html
Example: HTML
<iframe src="https://horje.com/learn/673/what-is-html-frame-tag" title="Horje Free Online Web Tutorials">
</iframe>

Output should be:

What should Use Instead of HTML <frameset> Tag

# Tips-51) What is HTML <h1> to <h6> Tags

The <h1> to <h6> tags are used to define HTML headings.

<h1> defines the most important heading. <h6> defines the least important heading.

Note: Only use one <h1> per page - this should represent the main heading/subject for the whole page. Also, do not skip heading levels - start with <h1>, then use <h2>, and so on.

How to create HTML <h1> to <h6> Tags

The six different HTML headings
index.html
Example: HTML
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
<h4>This is heading 4</h4>
<h5>This is heading 5</h5>
<h6>This is heading 6</h6> 

Output should be:

How to create HTML <h1> to <h6> Tags

Which browser will support for HTML <h1> to <h6> Tags

See the Screen
Which browser will support for HTML <h1> to <h6> Tags

How to Set the background color and text color of headings (with CSS)

See the Example
index.html
Example: HTML
<h1 style="background-color:DodgerBlue;">Hello World</h1>
<h2 style="color:Tomato;">Hello World</h2> 

Output should be:

How to Set the background color and text color of headings (with CSS)

How to set Default CSS Settings for HTML <h1> to <h6> Tags

Change the default CSS settings to see the effect.
index.html
Example: HTML
<style>
h1 { 
  display: block;
  font-size: 2em;
  margin-top: 0.67em;
  margin-bottom: 0.67em;
  margin-left: 0;
  margin-right: 0;
  font-weight: bold;
}
</style>

Output should be:

How to set Default CSS Settings for HTML <h1> to <h6> Tags

Most browsers will display the <h2> element with the following default values
index.html
Example: HTML
<style>
h2 { 
  display: block;
  font-size: 1.5em;
  margin-top: 0.83em;
  margin-bottom: 0.83em;
  margin-left: 0;
  margin-right: 0;
  font-weight: bold;
}
</style>

Output should be:

How to Set the alignment of headings (with CSS)

See the Example

index.html
Example: HTML
 <h1 style="text-align:center">This is heading 1</h1>
<h2 style="text-align:left">This is heading 2</h2>
<h3 style="text-align:right">This is heading 3</h3>
<h4 style="text-align:justify">This is heading 4</h4> 

Output should be:

How to Set the alignment of headings (with CSS)

Most browsers will display the <h2> element with the following default values

See the Example

index.html
Example: HTML
<style>
h2 { 
  display: block;
  font-size: 1.5em;
  margin-top: 0.83em;
  margin-bottom: 0.83em;
  margin-left: 0;
  margin-right: 0;
  font-weight: bold;
}
</style>

Output should be:

Most browsers will display the <h2> element with the following default values

Most browsers will display the <h3> element with the following default values

index.html
Example: HTML
<style>
h3 { 
  display: block;
  font-size: 1.17em;
  margin-top: 1em;
  margin-bottom: 1em;
  margin-left: 0;
  margin-right: 0;
  font-weight: bold;
}
</style>

Output should be:

Most browsers will display the <h3> element with the following default values

Most browsers will display the <h4> element with the following default values

See the Example

index.html
Example: HTML
<style>
h4 { 
  display: block;
  font-size: 1em;
  margin-top: 1.33em;
  margin-bottom: 1.33em;
  margin-left: 0;
  margin-right: 0;
  font-weight: bold;
}
</style>

Output should be:

Most browsers will display the <h4> element with the following default values

Most browsers will display the <h5> element with the following default values

See the Example

index.html
Example: HTML
<style>
h5 { 
  display: block;
  font-size: .83em;
  margin-top: 1.67em;
  margin-bottom: 1.67em;
  margin-left: 0;
  margin-right: 0;
  font-weight: bold;
}
</style>

Output should be:

Most browsers will display the <h5> element with the following default values

Most browsers will display the <h6> element with the following default values

See the Example

index.html
Example: HTML
<style>
h6 { 
  display: block;
  font-size: .67em;
  margin-top: 2.33em;
  margin-bottom: 2.33em;
  margin-left: 0;
  margin-right: 0;
  font-weight: bold;
}
</style>

Output should be:

Most browsers will display the <h6> element with the following default values

H1 to H6 Font-sizes with CSS

See the Example

<h1>Hello world</h1>
<h2>Hello world</h2>
<h3>Hello world</h3>
<h4>Hello world</h4>
<h5>Hello world</h5>
<h6>Hello world</h6>

Output should be:

H1 to H6 Font-sizes with CSS

# Tips-52) What is HTML <head> Tag

The <head> element is a container for metadata (data about data) and is placed between the <html> tag and the <body> tag.

Metadata is data about the HTML document. Metadata is not displayed.

Metadata typically define the document title, character set, styles, scripts, and other meta information.

The following elements can go inside the <head> element:

  • <title> (required in every HTML document)
  • <style>
  • <base>
  • <link>
  • <meta>
  • <script>
  • <noscript>

How to create HTML <head> Tag

A simple HTML document, with a <title> tag inside the head section:
index.html
Example: HTML
<!DOCTYPE html>
<html lang="en">
<head>
  <title>Title of the document</title>
</head>
<body>

<h1>This is a heading</h1>
<p>This is a paragraph.</p>

</body>
</html>

Output should be:

How to create HTML <head> Tag

Which browser will support for HTML <head> Tag

Browsers will support
Which browser will support for HTML <head> Tag

How to add The <base> tag inside <head>

(specifies a default URL and target for all links on a page) See the Example
index.html
Example: HTML
<html>
<head>
  <base href="https://horje.com/" target="_blank">
</head>
<body>

<img src="images/stickman.gif" width="24" height="39" alt="Stickman">
<a href="tags/tag_base.asp">HTML base Tag</a>

</body>
</html>

Output should be:

How to add The <base> tag inside <head>

How to add The <style> tag inside <head>

(adds style information to a page) See the Example.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
h1 {color:red;}
p {color:blue;}
</style>
</head>
<body>

<h1>This is a heading</h1>
<p>This is a paragraph.</p>

</body>
</html>

Output should be:

How to add The <style> tag inside <head>

How to add The <link> tag inside <head>

(links to an external style sheet) See the Example

index.html
Example: HTML
<html>
<head>
  <link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>

<h1>I am formatted with a linked style sheet</h1>
<p>Me too!</p>

</body>
</html>

Output should be:

How to add The <link> tag inside <head>

How to set Default CSS Settings for HTML <head> Tag

See the Example.
index.html
Example: HTML
<style>
head {
  display: none;
}
</style>


# Tips-53) What is HTML <header> Tag

The <header> Tag element represents a container for introductory content or a set of navigational links.

A <header> Tag element typically contains:

  • one or more heading elements (<h1> - <h6>)
  • logo or icon
  • authorship information

Note: You can have several <header> elements in one HTML document. However, <header> cannot be placed within a <footer>, <address> or another <header> element.

How to create HTML <header> Tag

A header for an <article>
index.html
Example: HTML
 <article>
  <header>
    <h1>A heading here</h1>
    <p>Posted by John Doe</p>
    <p>Some additional information here</p>
  </header>
  <p>Lorem Ipsum dolor set amet....</p>
</article> 

Output should be:

How to create HTML <header> Tag

Which browser will support for HTML <header> Tag

The numbers in the table specify the first browser version that fully supports the element.
Which browser will support for HTML <header> Tag

How should be HTML <header> Tag Page

A page header
index.html
Example: HTML
 <header>
  <h1>Main page heading here</h1>
  <p>Posted by John Doe</p>
</header> 

Output should be:

How should be HTML <header> Tag Page

How to set Default CSS Settings for HTML <header> Tag

Most browsers will display the <header> element with the following default values

index.html
Example: HTML
<style>
header {
  display: block;
}
</style>

Output should be:

How to set Default CSS Settings for HTML <header> Tag

# Tips-54) What is HTML <hgroup> Tag

The <hgroup> tag is used to surround a heading and one or more <p> elements.

The heading inside the <hgroup> element can be any of the <h1> to <h6> headings.

Note: The <hgroup> element does not render as anything special in a browser. However, you can use CSS to style the <hgroup> element and its content.

How to create HTML <hgroup> Tag

Use the hgroup element to mark that the heading and the paragraph are related
index.html
Example: HTML
<hgroup>
  <h2>Norway</h2>
  <p>The land with the midnight sun.</p>
</hgroup> 

Output should be:

How to create HTML <hgroup> Tag

Which browser will support for HTML <hgroup> Tag

See Browsers will support
Which browser will support for HTML <hgroup> Tag

How to set Default CSS Settings for HTML <hgroup> Tag

Most browsers will display the <hgroup> element with the following default values
index.html
Example: HTML
<style>
hgroup { 
  display: block;
}
</style>

Output should be:

How to set Default CSS Settings for HTML <hgroup> Tag

# Tips-55) What is HTML <hr> Tag

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.

How to create HTML <hr> Tag

Use the <hr> tag to define thematic changes in the content
index.html
Example: HTML
 <h1>The Main Languages of the Web</h1>

<p>HTML is the standard markup language for creating Web pages. HTML describes the structure of a Web page, and consists of a series of elements. HTML elements tell the browser how to display the content.</p>

<hr>

<p>CSS is a language that describes how HTML elements are to 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>

<p>JavaScript is the programming language of HTML and the Web. JavaScript can change HTML content and attribute values. JavaScript can change CSS. JavaScript can hide and show HTML elements, and more.</p> 

Output should be:

How to create HTML <hr> Tag

Which browser will support for HTML <hr> Tag

See the browsers will support
Which browser will support for HTML <hr> Tag

How to add Align a <hr> element (with CSS)

See the Example
index.html
Example: HTML
<hr style="width:50%;text-align:left;margin-left:0">

Output should be:

How to add Align a <hr> element (with CSS)

How to add A noshaded <hr> (with CSS)

See the Example
index.html
Example: HTML
<hr style="height:2px;border-width:0;color:gray;background-color:gray">

Output should be:

How to add A noshaded <hr> (with CSS)

How to Set the height of a <hr> element (with CSS)

See the Example
index.html
Example: HTML
<hr style="height:30px">

Output should be:

How to Set the height of a <hr> element (with CSS)

How to Set the width of a <hr> element (with CSS)

See the Example
index.html
Example: HTML
<hr style="width:50%">

Output should be:

How to Set the width of a <hr> element (with CSS)

How to set Default CSS Settings for HTML <hr> Tag

Most browsers will display the <hr> element with the following default values
index.html
Example: HTML
<style>
hr { 
  display: block;
  margin-top: 0.5em;
  margin-bottom: 0.5em;
  margin-left: auto;
  margin-right: auto;
  border-style: inset;
  border-width: 1px;
} 
</style>

Output should be:

How to set Default CSS Settings for HTML <hr> Tag

# Tips-56) What is HTML <html> Tag

The <html> tag represents the root of an HTML document.

The <html> tag is the container for all other HTML elements (except for the <!DOCTYPE> tag).

Note: You should always include the lang attribute inside the <html> tag, to declare the language of the Web page. This is meant to assist search engines and browsers.

How to create HTML <html> Tag

A simple HTML document
index.html
Example: HTML
<!DOCTYPE html>
<html lang="en">
<head>
  <title>Title of the document</title>
</head>
<body>

<h1>This is a heading</h1>
<p>This is a paragraph.</p>

</body>
</html>

Output should be:

How to create HTML <html> Tag

Which browser will support for HTML <html> Tag

See which browser will support
Which browser will support for HTML <html> Tag

Attributes for HTML <html> Tag

Attribute Value Description
xmlns http://www.w3.org/1999/xhtml Specifies the XML namespace attribute (If you need your content to conform to XHTML)

How to set Default CSS Settings for HTML <html> Tag

Most browsers will display the <html> element with the following default values
index.html
Example: HTML
<style>
html {
  display: block;
}

html:focus {
  outline: none;
}
</style>

Output should be:

How to set Default CSS Settings for HTML <html> Tag

# Tips-57) What is HTML <i> Tag

The <i> tag defines a part of text in an alternate voice or mood. The content inside is typically displayed in italic.

The <i> tag is often used to indicate a technical term, a phrase from another language, a thought, a ship name, etc.

Use the <i> element only when there is not a more appropriate semantic element, such as:

  • <em> (emphasized text)
  • <strong> (important text)
  • <mark> (marked/highlighted text)
  • <cite> (the title of a work)
  • <dfn> (a definition term)

How to create HTML <i> Tag

Mark up text that is set off from the normal prose in a document
index.html
Example: HTML
<p><i>Lorem ipsum</i> is the most popular filler text in history.</p>

<p>The <i>RMS Titanic</i>, a luxury steamship, sank on April 15, 1912 after striking an iceberg.</p>

Output should be:

How to create HTML <i> Tag

Which browser will support for HTML <i> Tag

See which browsers will support.
Which browser will support for HTML <i> Tag

How to set Default CSS Settings for HTML <i> Tag

Most browsers will display the <i> element with the following default values
index.html
Example: HTML
<style>
i { 
  font-style: italic;
}
</style>

Output should be:

How to set Default CSS Settings for HTML <i> Tag

# Tips-58) What is HTML <iframe> Tag

The <iframe> tag specifies an inline frame.

An inline frame is used to embed another document within the current HTML document.

Tip: Use CSS to style the <iframe> (see example below). 

Tip: It is a good practice to always include a title attribute for the <iframe>. This is used by screen readers to read out what the content of the <iframe> is.

How to create HTML <iframe> Tag

An inline frame is marked up as follows
index.html
Example: HTML
<iframe src="https://horje.com/learn/682/what-is-html-i-tag" title="Horje Free Online Web Tutorials">
</iframe>

Output should be:

How to create HTML <iframe> Tag

Which browser will support for HTML <iframe> Tag

See which browser will support for HTML iFrame
Which browser will support for HTML <iframe> Tag

Attributes for HTML <iframe> Tag

Attribute Value Description
allow   Specifies a feature policy for the <iframe>
allowfullscreen true
false
Set to true if the <iframe> can activate fullscreen mode by calling the requestFullscreen() method
allowpaymentrequest true
false
Set to true if a cross-origin <iframe> should be allowed to invoke the Payment Request API
height pixels Specifies the height of an <iframe>. Default height is 150 pixels
loading eager
lazy
Specifies whether a browser should load an iframe immediately or to defer loading of iframes until some conditions are met
name text Specifies the name of an <iframe>
referrerpolicy no-referrer
no-referrer-when-downgrade
origin
origin-when-cross-origin
same-origin
strict-origin-when-cross-origin
unsafe-url
Specifies which referrer information to send when fetching the iframe
sandbox allow-forms
allow-pointer-lock
allow-popups
allow-same-origin
allow-scripts
allow-top-navigation
Enables an extra set of restrictions for the content in an <iframe>
src URL Specifies the address of the document to embed in the <iframe>
srcdoc HTML_code Specifies the HTML content of the page to show in the <iframe>
width pixels Specifies the width of an <iframe>. Default width is 300 pixels

How to Add and remove iframe borders (with CSS)

See the Example
index.html
Example: HTML
 <iframe src="/default.asp" width="100%" height="300" style="border:1px solid black;">
</iframe>

<iframe src="/default.asp" width="100%" height="300" style="border:none;">
</iframe> 

Output should be:

How to Add and remove iframe borders (with CSS)

How to set Default CSS Settings for HTML <iframe> Tag

Most browsers will display the <iframe> element with the following default values
index.html
Example: HTML
<style>
iframe:focus {
  outline: none;
}

iframe[seamless] {
  display: block;
}
</style>

Output should be:

How to set Default CSS Settings for HTML <iframe> Tag

How to add HTML <iframe> allow attribute

The allow attribute specifies a feature policy to define what permissions are available to an <iframe>.

Applicable Elements

The allow Attribute can be used with the following elements:

  • <iframe>

HTML <iframe> allow Attribute

The <iframe> tag represents a nested browsing context and is used to embed an HTML document in your current HTML document.

The allow attribute can be used with the <iframe> attribute to specify a permissions policy to determine what features are available to it when it is initialized. I.e., permitting the <iframe> to access the computer’s camera or microphone.

index.html
Example: HTML
<iframe src="https://horje.com/learn/119/how-to-create-html-em-elements" allow="camera 'none'; microphone 'none'"></iframe>

Output should be:

How to add HTML <iframe> allow attribute

How to Add HTML <iframe> allowfullscreen attribute

iframe, short for "inline frame", is the most common way that the allowfullscreen attribute is used. Thanks mostly to video sites like YouTube and Vimeo, videos embedded by third-party websites using an iframe can use the allowfullscreen attribute to enable a "fullscreen" button within the iframe.

Here is sample code for a YouTube video embedded using an iframe along with the allowfullscreen attribute:

index.html
Example: HTML
<iframe width="560" height="315" src="//www.youtube.com/embed/jofNR_WkoCE" allowfullscreen></iframe>

Output should be:

How to Add HTML <iframe> allowfullscreen attribute

How to add HTML <iframe> allowpaymentrequest Attribute

Note: This attribute is Experimental.

The allowpaymentrequest set to true if a cross-origin <iframe> should be allowed to invoke the Payment Request API.

Note: This attribute is considered a legacy attribute and redefined as allow="payment".

Attribute Values

Value Description
allowpaymentrequest This is a boolean attribute, the presence of a boolean attribute on an element represents the true value, and the absence of the attribute represents the false value.
index.html
Example: HTML
<iframe src="https://www.paypal.com/" allowpaymentrequest>
  Your browser does not support iframe element.
</iframe>

How to add HTML <iframe> height Attribute

An <iframe> with a specified height and width of 200 pixels:

Definition and Usage

The height attribute specifies the height of an <iframe>, in pixels.

The default height is 150 pixels.

Browser Support

Syntax

<iframe height="pixels">

Attribute Values

Value Description
pixels The height of the inline frame in pixels (e.g. height="100")
index.html
Example: HTML
<iframe src="https://horje.com/learn/683/what-is-html-iframe-tag" width="200" height="200">

Output should be:

How to add HTML <iframe> height Attribute

How to Add HTML <iframe> loading attribute

The load event fires when the eagerly-loaded content has all been loaded. At that time, it's entirely possible (or even likely) that there may be lazily-loaded images or iframes within the visual viewport that haven't yet loaded.

index.html
Example: HTML
<iframe loading="lazy" src="https://horje.com/learn/683/what-is-html-iframe-tag" title="..."></iframe>

Output should be:

How to Add HTML <iframe> loading attribute

How to add HTML <iframe> name Attribute

An <iframe> that act as a target for a link:

Definition and Usage

The name attribute specifies a name for an iframe.

This name attribute can be used to reference the element in a JavaScript, or as the value of the target attribute of an <a> or <form> element, or the formtarget attribute of an <input> or <button> element.

Browser Support

Syntax

<iframe name="name">

Attribute Values

Value Description
name Specifies a name for the <iframe>
index.html
Example: HTML
<iframe src="https://horje.com/learn/683/what-is-html-iframe-tag" name="iframe_a">
<p>Your browser does not support iframes.</p>
</iframe>

Output should be:

How to add HTML <iframe> name Attribute

How to add HTML <iframe> referrerpolicy Attribute

Specifies that no referrer information will be sent along with the request:

Definition and Usage

The referrerpolicy attribute specifies which referrer information to send when fetching an iframe.

Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<iframe referrerpolicy="no-referrer|no-referrer-when-downgrade|origin|origin-when-cross-origin|same-origin|strict-origin-when-cross-origin|unsafe-url">

Attribute Values

Value Description
no-referrer No referrer information will be sent along with a request
no-referrer-when-downgrade Default. The referrer header will not be sent to origins without HTTPS
origin Send only scheme, host, and port to the request client
origin-when-cross-origin For cross-origin requests: Send only scheme, host, and port. For same-origin requests: Also include the path
same-origin For same-origin requests: Referrer info will be sent. For cross-origin requests: No referrer info will be sent
strict-origin Only send referrer info if the security level is the same (e.g. HTTPS to HTTPS). Do not send to a less secure destination (e.g. HTTPS to HTTP)
strict-origin-when-cross-origin Send full path when performing a same-origin request. Send only origin when the security level stays the same (e.g. HTTPS to HTTPS). Send no header to a less secure destination (HTTPS to HTTP)
unsafe-url Send origin, path and query string (but not fragment, password, or username). This value is considered unsafe
index.html
Example: HTML
<iframe src="https://horje.com/view/1332/how-to-add-html-iframe-referrerpolicy-attribute" referrerpolicy="no-referrer"></iframe>

Output should be:

How to add HTML <iframe> referrerpolicy Attribute

How to add HTML <iframe> referrerpolicy with no-referrer Attribute

No referrer information will be sent along with a request.

index.html
Example: HTML
<iframe src="https://horje.com/view/1333/how-to-add-html-iframe-referrerpolicy-attribute" referrerpolicy="no-referrer"></iframe> 

Output should be:

How to add HTML <iframe> referrerpolicy with no-referrer Attribute

How to add HTML <iframe> referrerpolicy with no-referrer-when-downgrade Attribute

Default. The referrer header will not be sent to origins without HTTPS.

index.html
Example: HTML
<iframe src="https://horje.com/view/1333/how-to-add-html-iframe-referrerpolicy-attribute" referrerpolicy="no-referrer-when-downgrade"></iframe> 

Output should be:

How to add HTML <iframe> referrerpolicy with no-referrer-when-downgrade Attribute

How to add HTML <iframe> referrerpolicy with origin Attribute

Send only scheme, host, and port to the request client.

index.html
Example: HTML
<iframe src="https://horje.com/view/1333/how-to-add-html-iframe-referrerpolicy-attribute" referrerpolicy="origin"></iframe> 

Output should be:

How to add HTML <iframe> referrerpolicy with origin Attribute

How to add HTML <iframe> referrerpolicy with origin-when-cross-origin Attribute

For cross-origin requests: Send only scheme, host, and port. For same-origin requests: Also include the path.

index.html
Example: HTML
<iframe src="https://horje.com/view/1333/how-to-add-html-iframe-referrerpolicy-attribute" referrerpolicy="origin-when-cross-origin"></iframe> 

Output should be:

How to add HTML <iframe> referrerpolicy with origin-when-cross-origin Attribute

How to add HTML <iframe> referrerpolicy with same-origin Attribute

For same-origin requests: Referrer info will be sent. For cross-origin requests: No referrer info will be sent.

index.html
Example: HTML
<iframe src="https://horje.com/view/1333/how-to-add-html-iframe-referrerpolicy-attribute" referrerpolicy="same-origin"></iframe>

Output should be:

How to add HTML <iframe> referrerpolicy with same-origin Attribute

How to add HTML <iframe> referrerpolicy with strict-origin Attribute

Only send referrer info if the security level is the same (e.g. HTTPS to HTTPS). Do not send to a less secure destination (e.g. HTTPS to HTTP)

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The iframe referrerpolicy attribute</h1>

<iframe src="https://w3schools.com/" referrerpolicy="strict-origin">
  <p>Your browser does not support iframes.</p>
</iframe>

</body>
</html>

Output should be:

How to add HTML <iframe> referrerpolicy with strict-origin Attribute

How to add HTML <iframe> referrerpolicy with strict-origin-when-cross-origin Attribute

Send full path when performing a same-origin request. Send only origin when the security level stays the same (e.g. HTTPS to HTTPS). Send no header to a less secure destination (HTTPS to HTTP)

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The iframe referrerpolicy strict-origin-when-cross-origin attribute</h1>

<iframe src="https://horje.com/" referrerpolicy="strict-origin-when-cross-origin">
  <p>Your browser does not support iframes.</p>
</iframe>

</body>
</html>

Output should be:

How to add HTML <iframe> referrerpolicy with strict-origin-when-cross-origin Attribute

How to add HTML <iframe> referrerpolicy with unsafe-url Attribute

Send origin, path and query string (but not fragment, password, or username). This value is considered unsafe

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The iframe referrerpolicy unsafe-url attribute</h1>

<iframe src="https://horje.com/" referrerpolicy="unsafe-url">
  <p>Your browser does not support iframes.</p>
</iframe>

</body>
</html>

Output should be:

How to add HTML <iframe> referrerpolicy with unsafe-url Attribute

What is HTML <iframe> sandbox Attribute

An <iframe> with extra restrictions.

Definition and Usage

The sandbox attribute enables an extra set of restrictions for the content in the iframe.

When the sandbox attribute is present, and it will:

  • treat the content as being from a unique origin
  • block form submission
  • block script execution
  • disable APIs
  • prevent links from targeting other browsing contexts
  • prevent content from using plugins (through <embed>, <object>, <applet>, or other)
  • prevent the content to navigate its top-level browsing context
  • block automatically triggered features (such as automatically playing a video or automatically focusing a form control)

The value of the sandbox attribute can either be empty (then all restrictions are applied), or a space-separated list of pre-defined values that will REMOVE the particular restrictions.

Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<iframe sandbox="value">

Attribute Values

Value Description
(no value) Applies all restrictions
allow-forms Allows form submission
allow-modals Allows to open modal windows
allow-orientation-lock Allows to lock the screen orientation
allow-pointer-lock Allows to use the Pointer Lock API
allow-popups Allows popups
allow-popups-to-escape-sandbox Allows popups to open new windows without inheriting the sandboxing
allow-presentation Allows to start a presentation session
allow-same-origin Allows the iframe content to be treated as being from the same origin
allow-scripts Allows to run scripts
allow-top-navigation Allows the iframe content to navigate its top-level browsing context
allow-top-navigation-by-user-activation Allows the iframe content to navigate its top-level browsing context
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The iframe sandbox attribute</h1>

<iframe src="https://horje.com/" sandbox>
  <p>Your browser does not support iframes.</p>
</iframe>

<p>The "Get date and time" button will run a script in the inline frame.</p>
<p>Since the sandbox attribute is set, the content of the inline frame is not allowed to run scripts.</p>
<p>You can add "allow-scripts" to the sandbox attribute, to allow the JavaScript to run.</p>

</body>
</html>

Output should be:

What is HTML <iframe> sandbox Attribute

How to add HTML <iframe> sandbox allow-forms Attribute

Allows form submission.

The "Submit" button will submit the form in the inline frame.

Since the sandbox attribute is set to an empty string (""), the submission of the form in the inline frame will be blocked.

Add "allow-forms" to the sandbox attribute, to allow form submission.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The iframe sandbox attribute</h1>

<iframe src="https://horje.com" sandbox="allow-forms">
  <p>Your browser does not support iframes.</p>
</iframe>

<p>The "Submit" button will submit the form in the inline frame.</p>
<p>Since the sandbox attribute is set to an empty string (""), the submission of the form in the inline frame will be blocked.</p>
<p>Add "allow-forms" to the sandbox attribute, to allow form submission.</p>

</body>
</html>

Output should be:

How to add HTML <iframe> sandbox allow-forms Attribute

How to add HTML <iframe> sandbox allow-modals Attribute

Allows to open modal windows

index.html
Example: HTML
<iframe src="https://horje.com" sandbox="allow-modals">
  <p>Your browser does not support iframes.</p>
</iframe>

Output should be:

How to add HTML <iframe> sandbox allow-modals Attribute

How to add HTML <iframe> sandbox allow-orientation-lock Attribute

Allows to lock the screen orientation

index.html
Example: HTML
<iframe src="https://horje.com/" sandbox="allow-orientation-lock">
</iframe>

Output should be:

How to add HTML <iframe> sandbox allow-orientation-lock Attribute

How to add HTML <iframe> sandbox allow-pointer-lock Attribute

Allows to use the Pointer Lock API.

index.html
Example: HTML
<iframe src="https://horje.com/" sandbox="allow-pointer-lock">
</iframe>

Output should be:

How to add HTML <iframe> sandbox allow-pointer-lock Attribute

How to add HTML <iframe> sandbox allow-popups Attribute

Allows popups

index.html
Example: HTML
<iframe src="https://horje.com/" sandbox="allow-popups">
</iframe>

Output should be:

How to add HTML <iframe> sandbox allow-popups Attribute

How to add HTML <iframe> sandbox allow-popups-to-escape-sandbox Attribute

Allows popups to open new windows without inheriting the sandboxing.

index.html
Example: HTML
<iframe src="https://horje.com/" sandbox="allow-popups-to-escape-sandbox">
</iframe>

Output should be:

How to add HTML <iframe> sandbox allow-popups-to-escape-sandbox Attribute

How to add HTML <iframe> sandbox allow-presentation Attribute

Allows to start a presentation session.

index.html
Example: HTML
<iframe src="https://horje.com/" sandbox="allow-presentation">
</iframe>

Output should be:

How to add HTML <iframe> sandbox allow-presentation Attribute

How to add HTML <iframe> sandbox allow-same-origin Attribute

Allows the iframe content to be treated as being from the same origin

index.html
Example: HTML
<iframe src="https://horje.com/" sandbox="allow-same-origin">
</iframe>

Output should be:

How to add HTML <iframe> sandbox allow-same-origin Attribute

How to add HTML <iframe> sandbox allow-scripts Attribute

Allows to run scripts

index.html
Example: HTML
<iframe src="https://horje.com/" sandbox="allow-scripts">
</iframe>

Output should be:

How to add HTML <iframe> sandbox allow-scripts Attribute

How to add HTML <iframe> sandbox allow-top-navigation Attribute

Allows the iframe content to navigate its top-level browsing context

index.html
Example: HTML
<iframe src="https://horje.com/" sandbox="allow-top-navigation">
</iframe>

Output should be:

How to add HTML <iframe> sandbox allow-top-navigation Attribute

How to add HTML <iframe> sandbox allow-top-navigation-by-user-activation Attribute

Allows the iframe content to navigate its top-level browsing context, but only if initiated by user.

index.html
Example: HTML
<iframe src="https://horje.com/" sandbox="allow-top-navigation-by-user-activation">
</iframe>

Output should be:

How to add HTML <iframe> sandbox allow-top-navigation-by-user-activation Attribute

How to add HTML <iframe> src Attribute

An <iframe> in its simplest use:

Definition and Usage

The src attribute specifies the address of the document to embed in an iframe.

Browser Support

Syntax

<iframe src="URL">

Attribute Values

Value Description
URL Specifies the URL of the document to embed in the iframe.

Possible values:

  • An absolute URL - points to another web site (like src="http://www.example.com/default.htm")
  • A relative URL - points to a file within a web site (like src="default.htm")
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The iframe src attribute</h1>

<iframe src="https://horje.com/view/1353/how-to-add-html-iframe-sandbox-allow-top-navigation-by-user-activation-attribute">
</iframe>

</body>
</html>

Output should be:

How to add HTML <iframe> src Attribute

How to add HTML <iframe> srcdoc Attribute

An <iframe> with a srcdoc attribute.

This is a way to add HTML Code to Iframe

Definition and Usage

The srcdoc attribute specifies the HTML content of the page to show in the inline frame.

Tip: This attribute is expected to be used together with the sandbox and seamless attributes.

If a browser supports the srcdoc attribute, it will override the content specified in the src attribute (if present).

If a browser does NOT support the srcdoc attribute, it will show the file specified in the src attribute instead (if present).

Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<iframe srcdoc="HTML_code">

Attribute Values

Value Description
HTML_code The HTML content to show in the iframe. Must be valid HTML syntax

index.html
Example: HTML
<iframe srcdoc="<p>Hello world!</p>" src="https://horje.com/view/1354/how-to-add-html-iframe-src-attribute">

Output should be:

How to add HTML <iframe> srcdoc Attribute

How to add HTML <iframe> width Attribute

An <iframe> with a specified height and width of 200 pixels:

Definition and Usage

The width attribute specifies the width of an iframe, in pixels.

The default width is 300 pixels.

Browser Support

Syntax

<iframe width="pixels">

Attribute Values

Value Description
pixels The width in pixels (like "100px" or just "100")
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The iframe height attribute</h1>

<iframe src="https://horje.com/" width="200" height="200">
</iframe>

</body>
</html>

Output should be:

How to add HTML <iframe> width Attribute

How to Make iframe automatically adjust height

This iframe will run according to your web browser fit.

index.html
Example: HTML
<script>
  function resizeIframe(obj) {
    obj.style.height = obj.contentWindow.document.documentElement.scrollHeight + 'px';
  }
</script>
<iframe src="https://horje.com" width="100%" frameborder="0" scrolling="no" onload="resizeIframe(this)" />

Output should be:

How to Make iframe automatically adjust height

# Tips-59) What is HTML <img> Tag

The tag is used to embed an image in an HTML page.

Images are not technically inserted into a web page; images are linked to web pages. The tag creates a holding space for the referenced image.

The tag has two required attributes:

  • src - Specifies the path to the image
  • alt - Specifies an alternate text for the image, if the image for some reason cannot be displayed

Note: Also, always specify the width and height of an image. If width and height are not specified, the page might flicker while the image loads.

Tip: To link an image to another document, simply nest the tag inside an tag (see example below).

 

How to create HTML <img> Tag

How to insert an image
index.html
Example: HTML
<img src="https://horje.com/avatar.png" alt="Girl in a jacket" width="500" height="600">

Output should be:

How to create HTML <img> Tag

Which browser will support for HTML <img> Tag

See Which Browser will support
Which browser will support for HTML <img> Tag

Attributes for HTML <img> Tag

Attribute Value Description
alt text Specifies an alternate text for an image
crossorigin anonymous
use-credentials
Allow images from third-party sites that allow cross-origin access to be used with canvas
height pixels Specifies the height of an image
ismap ismap Specifies an image as a server-side image map
loading eager
lazy
Specifies whether a browser should load an image immediately or to defer loading of images until some conditions are met
longdesc URL Specifies a URL to a detailed description of an image
referrerpolicy no-referrer
no-referrer-when-downgrade
origin
origin-when-cross-origin
unsafe-url
Specifies which referrer information to use when fetching an image
sizes sizes Specifies image sizes for different page layouts
src URL Specifies the path to the image
srcset URL-list Specifies a list of image files to use in different situations
usemap #mapname Specifies an image as a client-side image map
width pixels Specifies the width of an image

How to add Align image (with CSS)

index.html
Example: HTML
<img src="https://horje.com/avatar.png" alt="Smiley face" width="42" height="42" style="vertical-align:bottom">
<img src="https://horje.com/avatar.png" alt="Smiley face" width="42" height="42" style="vertical-align:middle">
<img src="https://horje.com/avatar.png" alt="Smiley face" width="42" height="42" style="vertical-align:top">
<img src="https://horje.com/avatar.png" alt="Smiley face" width="42" height="42" style="float:right">
<img src="https://horje.com/avatar.png" alt="Smiley face" width="42" height="42" style="float:left"> 

Output should be:

How to add Align image (with CSS)

How to Add image border (with CSS):

index.html
Example: HTML
<img src="https://horje.com/avatar.png" alt="Smiley face" width="42" height="42" style="border:5px solid black"> 

Output should be:

How to Add image border (with CSS):

How to Add left and right margins to image (with CSS)

See the Example

index.html
Example: HTML
<p><img src="https://horje.com/avatar.png" alt="Smiley face" width="42" height="42"> This is some text. This is some text. This is some text.</p>

<h2>Image with left and right margins</h2>
<p><img src="https://horje.com/avatar.png" alt="Smiley face" width="42" height="42" style="vertical-align:middle;margin:0px 50px">This is some text. This is some text. This is some text.</p>

Output should be:

How to Add left and right margins to image (with CSS)

How to Add top and bottom margins to image (with CSS)

See the Example

index.html
Example: HTML
<p><img src="https://horje.com/avatar.png" alt="Smiley face" width="42" height="42"> This is some text. This is some text. This is some text.</p>

<h2>Image with top and bottom margins</h2>
<p><img src="https://horje.com/avatar.png" alt="Smiley face" width="42" height="42" style="vertical-align:middle;margin:50px 0px">This is some text. This is some text. This is some text.</p>

Output should be:

How to Add top and bottom margins to image (with CSS)

How to insert images from another folder or from another web site

See the Example

index.html
Example: HTML
<img src="https://horje.com/avatar.png" alt="Stickman" width="24" height="39">

<p>Insert an image from a web site:</p>
<img src="https://horje.com/avatar.png" alt="Lamp" width="32" height="32">

Output should be:

How to insert images from another folder or from another web site

How to add a hyperlink to an image

See The Example

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>Add a hyperlink to an image</h1>

<p><a href="https://horje.com">
<img src="https://horje.com/avatar.png" alt="Horje.com" width="100" height="132">
</a></p>

</body>
</html>

Output should be:

How to add a hyperlink to an image

How to create an image map, with clickable regions. Each region is a hyperlink

See the example

index.html
Example: HTML
<img src="https://horje.com/uploads/demo/2024-02-03-15-39-40-screenshot_2024-02-03_at_21-36-38_workplace.jpg_(jpeg_image_400_%C3%97_379_pixels).png" alt="Workplace" usemap="#workmap" width="400" height="379">

<map name="workmap">
  <area shape="rect" coords="34,44,270,350" alt="Computer" href="https://horje.com/learn/684/what-is-html-img-tag">
  <area shape="rect" coords="290,172,333,250" alt="Phone" href="https://horje.com/learn/684/what-is-html-img-tag">
  <area shape="circle" coords="337,300,44" alt="Cup of coffee" href="coffee.htm">
</map>

Output should be:

How to create an image map, with clickable regions. Each region is a hyperlink

How to set Default CSS Settings for HTML <img> Tag

See the Example

index.html
Example: HTML
<style>
img {
  display: inline-block;
}
</style>
<p>Some text <img src="https://horje.com/avatar.png" alt="Smiley face" width="42" height="42"> some text.</p>

Output should be:

How to set Default CSS Settings for HTML <img> Tag

How to add HTML <img> alt Attribute

The required alt attribute specifies an alternate text for an image, if the image cannot be displayed.

The alt attribute provides alternative information for an image if a user for some reason cannot view it (because of slow connection, an error in the src attribute, or if the user uses a screen reader).

Tip: To create a tooltip for an image, use the title attribute!

Browsers Support

Syntax

<img alt="text">

Attribute Values

Value Description
text Specifies an alternate text for an image.

Guidelines for the alt text:

  • The text should describe the image if the image contains information
  • The text should explain where the link goes if the image is inside an <a> element
  • Use alt="" if the image is only for decoration

An image with an alternate text specified.

index.html
Example: HTML
<img src="https://horje.com/avatar.png" alt="Girl in a jacket" width="500" height="600">

Output should be:

How to add HTML <img> alt Attribute

How to add HTML <img> height Attribute

The height attribute specifies the height of an image, in pixels.

Tip: Always specify both the height and width attributes for images. If height and width are set, the space required for the image is reserved when the page is loaded. However, without these attributes, the browser does not know the size of the image, and cannot reserve the appropriate space to it. The effect will be that the page layout will change during loading (while the images load).

Tip: Downsizing a large image with the height and width attributes forces a user to download the large image (even if it looks small on the page). To avoid this, rescale the image with a program before using it on a page.


Browser Support

Syntax

<img height="pixels">

Attribute Values

Value Description
pixels The height in pixels (e.g. height="100")
index.html
Example: HTML
<img src="https://horje.com/avatar.png" alt="Girl in a jacket" width="500" height="600">

Output should be:

How to add HTML <img> height Attribute

How to HTML <img> ismap Attribute

The ismap attribute is a boolean attribute.

When present, it specifies that the image is part of a server-side image map (an image map is an image with clickable areas).

When clicking on a server-side image map, the click coordinates are sent to the server as a URL query string.

Note: The ismap attribute is allowed only if the <img> element is a descendant of an <a> element with a valid href attribute.

Browser Support

Syntax

<img ismap>

index.html
Example: HTML
<a href="/action_page.php">
  <img src="https://horje.com/avatar.png" alt="Horje.com" width="100" height="132" ismap>
</a>

Output should be:

How to HTML <img> ismap Attribute

How to add HTML <img> loading Attribute

Add lazy loading to images below the fold:

he loading attribute specifies whether a browser should load an image immediately or to defer loading of off-screen images until for example the user scrolls near them.

Tip: Add loading="lazy" only to images which are positioned below the fold.

Browser Support

Attribute Values

Value Description
eager Default. Loads an image immediately
lazy Defer loading of images until some conditions are met
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The img loading attribute</h1>

<!-- visible in viewport -->
<img src="https://horje.com/avatar.png" alt="Wedding" style="width:100%">
<img src="https://horje.com/avatar.png" alt="Rocks" style="width:100%">
 
<!-- off-screen images -->
<img src="https://horje.com/avatar.png" alt="Paris" style="width:100%" loading="lazy">
<img src="https://horje.com/avatar.png" alt="Nature" style="width:100%" loading="lazy">
<img src="https://horje.com/avatar.png" alt="Underwater" style="width:100%" loading="lazy">
<img src="https://horje.com/avatar.png" alt="Ocean" style="width:100%" loading="lazy">
<img src="https://horje.com/avatar.png" alt="Mountains" style="width:100%" loading="lazy">

</body>
</html>

Output should be:

How to add HTML <img> loading Attribute

How to add HTML <img> longdesc Attribute

The longdesc attribute specifies a hyperlink to a detailed description of an image.

Several examples of how to use the longdesc attribute.

Browser Support

Syntax

<img longdesc="string">

Attribute Values

Value Description
string

A hyperlink to a detailed description of an image.

Possible values:

  • An id to another element
  • An absolute URL - points to another web site (like longdesc="http://www.example.com/description.txt")
  • A relative URL - points to a file within a web site (like longdesc="description.txt")
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The img longdesc attribute</h1>

<!-- The description is on the same page as the image -->
<img src="https://horje.com/avatar.png" alt="Horje.com" width="100" height="132" longdesc="#w3htmlExplained">

<!-- The description is in an external page -->
<img src="https://horje.com/avatar.png" alt="Horje.com" width="100" height="132" longdesc="w3html.txt">

<!-- The description is one of several within an external page -->
<img src="https://horje.com/avatar.png" alt="Horje.com" width="100" height="132" longdesc="http://example.com/desc#item3">

<!-- The description is included in a data:URI -->
<img src="https://horje.com/avatar.png" alt="Horje.com" width="100" height="132" longdesc="data:text/html;charset=utf-8;,%3C!DOCTYPE%20html%3E%3Chtml%3E%3Chead%3E%3Ctitle%3EDescription%20of%20the%20Logo%3C/title%3E%3C/head%3E%3Cbody%3E%3Cp%3ESome%20description%20goes%20here%3C/body%3E%3C/html%3E">


<div id="w3htmlExplained">
  <h2>Image https://horje.com/avatar.png</h2>
  <p>Description of the image...</p>
</div>

</body>
</html>

Output should be:

How to add HTML <img> longdesc Attribute

How to add HTML <img> referrerpolicy Attribute

Set the referrerpolicy for an image:

The referrerpolicy attribute specifies which referrer information to use when fetching an image.

Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<img referrerpolicy="no-referrer|no-referrer-when-downgrade|origin|origin-when-cross-origin|unsafe-url">

Attribute Values

Value Description
no-referrer No referrer information is sent
no-referrer-when-downgrade Default. The referrer header will not be sent to origins without HTTPS
origin Sends the origin (scheme, host, and port) of the document
origin-when-cross-origin For cross-origin requests: Send only scheme, host, and port. For same-origin requests: Also include the path
unsafe-url Send origin, path and query string (but not fragment, password, or username). This value is considered unsafe
index.html
Example: HTML
<img src="https://horje.com/avatar.png" alt="Some image" referrerpolicy="no-referrer">

How to add HTML <img> Size Attribute

An image with a height of 600 pixels and a width of 500 pixels:

The width attribute specifies the width of an image, in pixels.

Tip: Always specify both the height and width attributes for images. If height and width are set, the space required for the image is reserved when the page is loaded. However, without these attributes, the browser does not know the size of the image, and cannot reserve the appropriate space to it. The effect will be that the page layout will change during loading (while the images load).

Tip: Downsizing a large image with the height and width attributes forces a user to download the large image (even if it looks small on the page). To avoid this, rescale the image with a program before using it on a page.

Browser Support

Syntax

<img width="pixels">

Attribute Values

Value Description
pixels The width in pixels (e.g. width="100")
index.html
Example: HTML
<img src="https://horje.com/avatar.png" alt="Girl in a jacket" width="500" height="600">

Output should be:

How to add HTML <img> Size Attribute

How to add HTML <img> crossorigin Attribute

The crossorigin attribute on an <img> tag specifies that CORS is supported when loading an image from a third party server or domain.

CORS is a standard mechanism used to retrieve files from other domains.

index.html
Example: HTML
<img crossorigin="anonymous" src="https://horje.com/avatar.png" alt="Van Gogh, self-portrait">

Output should be:

How to add HTML <img> crossorigin Attribute

How to add HTML <img> src Attribute

An image is marked up as follows.

The required src attribute specifies the URL of the image.

There are two ways to specify the URL in the src attribute:

1. Absolute URL - Links to an external image that is hosted on another website. Example: src="https://horje.com/avatar.png".

Notes: External images might be under copyright. If you do not get permission to use it, you may be in violation of copyright laws. In addition, you cannot control external images; it can suddenly be removed or changed.

2. Relative URL - Links to an image that is hosted within the website. Here, the URL does not include the domain name. If the URL begins without a slash, it will be relative to the current page. Example: src="img_girl.jpg". If the URL begins with a slash, it will be relative to the domain. Example: src="/images/img_girl.jpg".

Tip: It is almost always best to use relative URLs. They will not break if you change domain.

Note: A broken link icon and the alt text are shown if the browser cannot find the image. 

Browser Support

Syntax

<img src="URL">

Attribute Values

Value Description
URL The URL of the image.

Possible values:

  • An absolute URL - points to another web site (like src="http://www.example.com/image.gif")
  • A relative URL - points to a file within a web site (like src="image.gif")
index.html
Example: HTML
<img src="https://horje.com/avatar.png" alt="Girl in a jacket" width="500" height="600">

Output should be:

How to add HTML <img> src Attribute

How to add HTML <img> srcset Attribute

The srcset attribute on an <img> tag specifies multiple image resources (URLs) for the img element.

Together with the sizes attribute they create responsive images that adjust according to browser conditions.

A srcset attribute on an <img> element.
Resizing the browser will adjust the image file used.

index.html
Example: HTML
<img srcset="https://horje.com/avatar.png 120w,
             https://horje.com/avatar.png 193w,
             https://horje.com/avatar.png 278w"
     sizes="(max-width: 710px) 120px,
            (max-width: 991px) 193px,
            278px">

Output should be:

How to add HTML <img> srcset Attribute

How to add HTML <img> usemap Attribute

An image map, with clickable areas.

The usemap attribute specifies an image as a client-side image map (an image map is an image with clickable areas).

The usemap attribute is associated with a <map> element's name attribute, and creates a relationship between the <img> and the <map>.

Note: The usemap attribute cannot be used if the <img> element is a descendant of an <a> or <button> element.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The map and area elements</h1>

<p>Click on the computer, the phone, or the cup of coffee to go to a new page and read more about the topic:</p>

<img src="https://horje.com/avatar.png" alt="Workplace" usemap="#workmap" width="400" height="379">

<map name="workmap">
  <area shape="rect" coords="34,44,270,350" alt="Computer" href="computer.htm">
  <area shape="rect" coords="290,172,333,250" alt="Phone" href="phone.htm">
  <area shape="circle" coords="337,300,44" alt="Cup of coffee" href="coffee.htm">
</map>

</body>
</html>

Output should be:

How to add HTML <img> usemap Attribute

How to add HTML <img> width Attribute

An image with a height of 600 pixels and a width of 500 pixels:

The width attribute specifies the width of an image, in pixels.

Tip: Always specify both the height and width attributes for images. If height and width are set, the space required for the image is reserved when the page is loaded. However, without these attributes, the browser does not know the size of the image, and cannot reserve the appropriate space to it. The effect will be that the page layout will change during loading (while the images load).

Tip: Downsizing a large image with the height and width attributes forces a user to download the large image (even if it looks small on the page). To avoid this, rescale the image with a program before using it on a page.

Browser Support

Syntax

<img width="pixels">

Attribute Values

Value Description
pixels The width in pixels (e.g. width="100")
index.html
Example: HTML
<img src="https://horje.com/avatar.png" alt="Girl in a jacket" width="200" height="300">

Output should be:

How to add HTML <img> width Attribute

# Tips-60) What is HTML <input> Tag

An HTML form with three input fields; two text fields and one submit button.

Definition and Usage

The <input> tag specifies an input field where the user can enter data.

The <input> element is the most important form element.

The <input> element can be displayed in several ways, depending on the type attribute.

The different input types are as follows:

  • <input type="button">
  • <input type="checkbox">
  • <input type="color">
  • <input type="date">
  • <input type="datetime-local">
  • <input type="email">
  • <input type="file">
  • <input type="hidden">
  • <input type="image">
  • <input type="month">
  • <input type="number">
  • <input type="password">
  • <input type="radio">
  • <input type="range">
  • <input type="reset">
  • <input type="search">
  • <input type="submit">
  • <input type="tel">
  • <input type="text"> (default value)
  • <input type="time">
  • <input type="url">
  • <input type="week">

Look at the type attribute to see examples for each input type!


Tips and Notes

Tip: Always use the <label> tag to define labels for <input type="text">, <input type="checkbox">, <input type="radio">, <input type="file">, and <input type="password">.


Browser Support

 

Attributes

Attribute Value Description
accept file_extension
audio/*
video/*
image/*
media_type
Specifies a filter for what file types the user can pick from the file input dialog box (only for type="file")
alt text Specifies an alternate text for images (only for type="image")
autocomplete on
off
Specifies whether an <input> element should have autocomplete enabled
autofocus autofocus Specifies that an <input> element should automatically get focus when the page loads
checked checked Specifies that an <input> element should be pre-selected when the page loads (for type="checkbox" or type="radio")
dirname inputname.dir Specifies that the text direction will be submitted
disabled disabled Specifies that an <input> element should be disabled
form form_id Specifies the form the <input> element belongs to
formaction URL Specifies the URL of the file that will process the input control when the form is submitted (for type="submit" and type="image")
formenctype application/x-www-form-urlencoded
multipart/form-data
text/plain
Specifies how the form-data should be encoded when submitting it to the server (for type="submit" and type="image")
formmethod get
post
Defines the HTTP method for sending data to the action URL (for type="submit" and type="image")
formnovalidate formnovalidate Defines that form elements should not be validated when submitted
formtarget _blank
_self
_parent
_top
framename
Specifies where to display the response that is received after submitting the form (for type="submit" and type="image")
height pixels Specifies the height of an <input> element (only for type="image")
list datalist_id Refers to a <datalist> element that contains pre-defined options for an <input> element
max number
date
Specifies the maximum value for an <input> element
maxlength number Specifies the maximum number of characters allowed in an <input> element
min number
date
Specifies a minimum value for an <input> element
minlength number Specifies the minimum number of characters required in an <input> element
multiple multiple Specifies that a user can enter more than one value in an <input> element
name text Specifies the name of an <input> element
pattern regexp Specifies a regular expression that an <input> element's value is checked against
placeholder text Specifies a short hint that describes the expected value of an <input> element
popovertarget element_id Specifies which popover element to invoke (only for type="button")
popovertargetaction hide
show
toggle
Specifies what happens to the popover element when you click the button (only for type="button")
readonly readonly Specifies that an input field is read-only
required required Specifies that an input field must be filled out before submitting the form
size number Specifies the width, in characters, of an <input> element
src URL Specifies the URL of the image to use as a submit button (only for type="image")
step number
any
Specifies the interval between legal numbers in an input field
type button
checkbox
color
date
datetime-local
email
file
hidden
image
month
number
password
radio
range
reset
search
submit
tel
text
time
url
week
Specifies the type <input> element to display
value text Specifies the value of an <input> element
 
width pixels Specifies the width of an <input> element (only for type="image")

How to add HTML <input> Tag

An HTML form with three input fields; two text fields and one submit button
index.html
Example: HTML
<form action="/action_page.php">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="submit" value="Submit">
</form> 

Output should be:

How to add HTML <input> Tag

How to add HTML <input> accept Attribute

Specify what file types the user can pick from the file input dialog box.

Definition and Usage

The accept attribute specifies a filter for what file types the user can pick from the file input dialog box.

Note: The accept attribute can only be used with <input type="file">.

Tip: Do not use this attribute as a validation tool. File uploads should be validated on the server.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<input accept="file_extension|audio/*|video/*|image/*|media_type">

Tip: To specify more than one value, separate the values with a comma (e.g. <input accept="audio/*,video/*,image/*" />.

Attribute Values

Value Description
file_extension Specify the file extension(s) (e.g: .gif, .jpg, .png, .doc) the user can pick from
audio/* The user can pick all sound files
video/* The user can pick all video files
image/* The user can pick all image files
media_type A valid media type, with no parameters. Look at IANA Media Types for a complete list of standard media types
index.html
Example: HTML
<form action="/action_page.php">
  <label for="img">Select image:</label>
  <input type="file" id="img" name="img" accept="image/*">
  <input type="submit">
</form>

Output should be:

How to add HTML <input> accept Attribute

How to add HTML <input> accept file_extension Attribute

file_extension Specify the file extension(s) (e.g: .gif, .jpg, .png, .doc) the user can pick from
index.html
Example: HTML
<form action="/action_page.php">
  <label for="img">Select image:</label>
  <input type="file" id="img" name="img" accept="file_extension">
  <input type="submit">
</form>

Output should be:

How to add HTML <input> accept file_extension Attribute

How to add HTML <input> accept audio/* Attribute

audio/* The user can pick all sound files
index.html
Example: HTML
<form action="/action_page.php">
  <label for="img">Select image:</label>
  <input type="file" id="img" name="img" accept="audio/*">
  <input type="submit">
</form>

Output should be:

How to add HTML <input> accept audio/* Attribute

How to add HTML <input> accept video/* Attribute

video/* The user can pick all video files
index.html
Example: HTML
<form action="/action_page.php">
  <label for="img">Select image:</label>
  <input type="file" id="img" name="img" accept="video/*">
  <input type="submit">
</form>

Output should be:

How to add HTML <input> accept video/* Attribute

How to add HTML <input> accept image/* Attribute

image/* The user can pick all image files
index.html
Example: HTML
<form action="/action_page.php">
  <label for="img">Select image:</label>
  <input type="file" id="img" name="img" accept="image/*">
  <input type="submit">
</form>

Output should be:

How to add HTML <input> accept image/* Attribute

How to add HTML <input> accept media_type Attribute

media_type A valid media type, with no parameters. Look at IANA Media Types for a complete list of standard media types
index.html
Example: HTML
<form action="/action_page.php">
  <label for="img">Select image:</label>
  <input type="file" id="img" name="img" accept="media_type">
  <input type="submit">
</form>

Output should be:

How to add HTML <input> accept media_type Attribute

How to add HTML <input> alt Attribute

An HTML form with an image that represents the submit button.

alt text Specifies an alternate text for images (only for type="image")

Definition and Usage

The alt attribute provides an alternate text for the user, if he/she for some reason cannot view the image (because of slow connection, an error in the src attribute, or if the user uses a screen reader).

Note: The alt attribute can only be used with <input type="image">.


Browser Support

Syntax

<input alt="text">

Attribute Values

Value Description
text Specifies an alternate text for the image
index.html
Example: HTML
<form action="/action_page.php">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname">
  <input type="image" src="https://horje.com/uploads/demo/2024-03-05-10-50-41-submit.gif" alt="Submit" width="48" height="48">
</form> 

Output should be:

How to add HTML <input> alt Attribute

How to add HTML <input> autocomplete Attribute

An HTML form where the username and password does NOT get autocompleted.

Definition and Usage

The autocomplete attribute specifies if browsers should try to predict the value of an input field or not. You can also specify which type of value you expect in the input field.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Tip: In some browsers you may need to activate an autocomplete function for this to work (Look under "Preferences" in the browser's menu).


Syntax

<input autocomplete="on|off|type-of-value">

Attribute Values

Value Description
on Default. Autocomplete is on (enabled)
off Autocomplete is off (disabled)
address-line1 Expects the first line of the street address
address-line2 Expects the second line of the street address
address-line3 Expects the third line of the street address
address-level1 Expects the first level of the address, e.g. the county
address-level2 Expects the second level of the address, e.g. the city
address-level3 Expects the third level of the address
address-level4 Expects the fourth level of the address
street-address Expects the full street address
country Expects the country code
country-name Expects the country name
postal-code Expects the post code
name Expects the full name
additional-name Expects the middle name
family-name Expects the last name
give-name Expects the first name
honoric-prefix Expects the title, like "Mr", "Ms" etc.
honoric-suffix Expects the suffix, like "5", "Jr." etc.
nickname Expects the nickname
organization-title Expects the job title
username Expects the username
new-password Expects a new password
current-password Expects the current password
bday Expects the full birthday date
bday-day Expects the day of the birthday date
bday-month Expects the month of the birthday date
bday-year Expects the year of the birthday date
sex Expects the gender
one-time-code Expects a one time code for verification etc.
organization Expects the company name
cc-name Expects the credit card owner's full name
cc-given-name Expects the credit card owner's first name
cc-additional-name Expects the credit card owner's middle name
cc-family-name Expects the credit card owner's full name
cc-number Expects the credit card's number
cc-exp Expects the credit card's expiration date
cc-exp-month Expects the credit card's expiration month
cc-exp-year Expects the credit card's expiration year
cc-csc Expects the CVC code
cc-type Expects the credit card's type of payment
transaction-currency Expects the currency
transaction-amount Expects a number, the amount
language Expects the preferred language
url Expects a we address
email Expects the email address
photo Expects an image
tel Expects the full phone number
tel-country-code Expects the country code of the phone number
tel-national Expects the phone number with no country code
tel-area-code Expects the area code of the phone number
tel-local Expects the phone number with no country code and no area code
tel-local-prefix Expects the local prefix of the phone number
tel-local-suffix Expects the local suffix of the phone number
tel-extension Expects the extension code of the phone number
impp Expects the url of an instant messaging protocol endpoint
index.html
Example: HTML
<form action="/action_page.php">
  <label for="username">Username:</label>
  <input type="text" id="username" name="username"><br><br>
  <label for="password">Password:</label>
  <input type="password" id="password" name="password" autocomplete="new-password"><br><br>
  <input type="submit">
</form> 

Output should be:

How to add HTML <input> autocomplete Attribute

How to add HTML <input> autocomplete on Attribute

on Default. Autocomplete is on (enabled)
index.html
Example: HTML
<form action="/action_page.php">
  <label for="username">Username:</label>
  <input type="text" id="username" name="username"><br><br>
  <label for="password">Password:</label>
  <input type="password" id="password" name="password" autocomplete="on"><br><br>
  <input type="submit">

Output should be:

How to add HTML <input> autocomplete on Attribute

How to add HTML <input> autocomplete off Attribute

off Autocomplete is off (disabled)
index.html
Example: HTML
<form action="/action_page.php">
  <label for="username">Username:</label>
  <input type="text" id="username" name="username"><br><br>
  <label for="password">Password:</label>
  <input type="password" id="password" name="password" autocomplete="off"><br><br>
  <input type="submit">
</form>

Output should be:

How to add HTML <input> autocomplete off Attribute

How to add HTML <input> autocomplete address-line1 Attribute

address-line1 Expects the first line of the street address
index.html
Example: HTML
<form action="/action_page.php">
  <label for="address-line1">Address:</label>
  <input type="text" id="address-line1" name="address-line1"  autocomplete="address-line1"><br><br>
  <input type="submit">
</form>

Output should be:

How to add HTML <input> autocomplete address-line1 Attribute

How to add HTML <input> autocomplete address-line2 Attribute

address-line2 Expects the second line of the street address
index.html
Example: HTML
<form action="/action_page.php">
  <label for="address-line2">Address:</label>
  <input type="text" id="address-line2" name="address-line1"  autocomplete="address-line2"><br><br>
  <input type="submit">
</form>

Output should be:

How to add HTML <input> autocomplete address-line2 Attribute

How to add HTML <input> autocomplete address-line3 Attribute

address-line3 Expects the third line of the street address
index.html
Example: HTML
<form action="/action_page.php">
  <label for="address-line3">Address:</label>
  <input type="text" id="address-line3" name="address-line3"  autocomplete="address-line3"><br><br>
  <input type="submit">
</form>

Output should be:

How to add HTML <input> autocomplete address-line3 Attribute

How to add HTML <input> autocomplete address-level1 Attribute

address-level1 Expects the first level of the address, e.g. the county
index.html
Example: HTML
<form action="/action_page.php">
  <label for="address-line">Address:</label>
  <input type="text" id="address-line" name="address-line"  autocomplete="address-level1"><br><br>
  <input type="submit">
</form>

Output should be:

How to add HTML <input> autocomplete address-level1 Attribute

How to add HTML <input> autocomplete address-level2 Attribute

address-level2 Expects the second level of the address, e.g. the city
index.html
Example: HTML
<form action="/action_page.php">
  <label for="address-line">Address:</label>
  <input type="text" id="address-line" name="address-line"  autocomplete="address-level2"><br><br>
  <input type="submit">
</form>

Output should be:

How to add HTML <input> autocomplete address-level2 Attribute

How to add HTML <input> autocomplete address-level3 Attribute

address-level3 Expects the third level of the address
index.html
Example: HTML
<form action="/action_page.php">
  <label for="address-line">Address:</label>
  <input type="text" id="address-line" name="address-line"  autocomplete="address-level3"><br><br>
  <input type="submit">
</form>

Output should be:

How to add HTML <input> autocomplete address-level3 Attribute

How to add HTML <input> autocomplete address-line4 Attribute

address-level4 Expects the fourth level of the address
index.html
Example: HTML
<form action="/action_page.php">
  <label for="address-line">Address:</label>
  <input type="text" id="address-line" name="address-line"  autocomplete="address-level4"><br><br>
  <input type="submit">
</form>

Output should be:

How to add HTML <input> autocomplete address-line4 Attribute

How to add HTML <input> autocomplete street-address Attribute

street-address Expects the full street address
index.html
Example: HTML
<form action="/action_page.php">
  <label for="address-line">Address:</label>
  <input type="text" id="address-line" name="address-line"  autocomplete="street-address"><br><br>
  <input type="submit">
</form>

Output should be:

How to add HTML <input> autocomplete street-address Attribute

How to add HTML <input> autocomplete country Attribute

country Expects the country code
index.html
Example: HTML
<form action="/action_page.php">
  <label for="address-line">Address:</label>
  <input type="text" id="address-line" name="address-line"  autocomplete="country"><br><br>
  <input type="submit">
</form>

Output should be:

How to add HTML <input> autocomplete country Attribute

How to add HTML <input> autocomplete country-name Attribute

country-name Expects the country name
index.html
Example: HTML
<form action="/action_page.php">
  <label for="address-line">Address:</label>
  <input type="text" id="address-line" name="address-line"  autocomplete="country-name"><br><br>
  <input type="submit">
</form>

Output should be:

How to add HTML <input> autocomplete country-name Attribute

How to add HTML <input> autocomplete postal-code Attribute

postal-code Expects the post code
index.html
Example: HTML
<form action="/action_page.php">
  <label for="address-line">Address:</label>
  <input type="text" id="address-line" name="address-line"  autocomplete="postal-code"><br><br>
  <input type="submit">
</form>

Output should be:

How to add HTML <input> autocomplete postal-code Attribute

How to add HTML <input> autocomplete name Attribute

name Expects the full name
index.html
Example: HTML
<form action="/action_page.php">
  <label for="address-line">Name:</label>
  <input type="text" id="address-line" name="address-line"  autocomplete="name"><br><br>
  <input type="submit">
</form>

Output should be:

How to add HTML <input> autocomplete name Attribute

How to add HTML <input> autocomplete additional-name Attribute

additional-name Expects the middle name
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
  <label for="address-line">Name:</label>
  <input type="text" id="address-line" name="address-line"  autocomplete="additional-name"><br><br>
  <input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete additional-name Attribute

How to add HTML <input> autocomplete family-name Attribute

family-name Expects the last name
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
  <label for="address-line">Name:</label>
  <input type="text" id="address-line" name="address-line"  autocomplete="family-name"><br><br>
  <input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete family-name Attribute

How to add HTML <input> autocomplete give-name Attribute

give-name Expects the first name
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
  <label for="address-line">Name:</label>
  <input type="text" id="address-line" name="address-line"  autocomplete="give-name"><br><br>
  <input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete give-name Attribute

How to add HTML <input> autocomplete honoric-prefix Attribute

honoric-prefix Expects the title, like "Mr", "Ms" etc.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
  <label for="address-line">Name:</label>
  <input type="text" id="address-line" name="address-line"  autocomplete="honoric-prefix"><br><br>
  <input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete honoric-prefix Attribute

How to add HTML <input> autocomplete name Attribute

honoric-suffix Expects the suffix, like "5", "Jr." etc.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
  <label for="address-line">Name:</label>
  <input type="text" id="address-line" name="address-line"  autocomplete="honoric-suffix"><br><br>
  <input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete name Attribute

How to add HTML <input> autocomplete nickname Attribute

nickname Expects the nickname
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
  <label for="address-line">Name:</label>
  <input type="text" id="address-line" name="address-line"  autocomplete="nickname"><br><br>
  <input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete nickname Attribute

How to add HTML <input> autocomplete organization-title Attribute

organization-title Expects the job title
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
  <label for="address-line">Name:</label>
  <input type="text" id="address-line" name="address-line"  autocomplete="organization-title"><br><br>
  <input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete organization-title Attribute

How to add HTML <input> autocomplete username Attribute

username Expects the username
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
  <label for="address-line">Name:</label>
  <input type="text" id="address-line" name="address-line"  autocomplete="username"><br><br>
  <input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete username Attribute

How to add HTML <input> autocomplete new-password Attribute

new-password Expects a new password
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
  <label for="address-line">Name:</label>
  <input type="text" id="address-line" name="address-line"  autocomplete="new-password"><br><br>
  <input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete new-password Attribute

How to add HTML <input> autocomplete new-password Attribute

new-password Expects a new password
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
  <label for="address-line">Name:</label>
  <input type="text" id="address-line" name="address-line"  autocomplete="new-password"><br><br>
  <input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete new-password Attribute

How to add HTML <input> autocomplete current-password Attribute

current-password Expects the current password
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
  <label for="address-line">Name:</label>
  <input type="text" id="address-line" name="address-line"  autocomplete="current-password"><br><br>
  <input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete current-password Attribute

How to add HTML <input> autocomplete bday Attribute

bday Expects the full birthday date
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
  <label for="address-line">Name:</label>
  <input type="text" id="address-line" name="address-line"  autocomplete="bday"><br><br>
  <input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete bday Attribute

How to add HTML <input> autocomplete bday-day Attribute

bday-day Expects the day of the birthday date
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
  <label for="address-line">Name:</label>
  <input type="text" id="address-line" name="address-line"  autocomplete="bday-day"><br><br>
  <input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete bday-day Attribute

How to add HTML <input> autocomplete bday-month Attribute

bday-month Expects the month of the birthday date
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
  <label for="address-line">Name:</label>
  <input type="text" id="address-line" name="address-line"  autocomplete="bday-month"><br><br>
  <input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete bday-month Attribute

How to add HTML <input> autocomplete bday-year Attribute

bday-year Expects the year of the birthday date
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
  <label for="address-line">Name:</label>
  <input type="text" id="address-line" name="address-line"  autocomplete="bday-year"><br><br>
  <input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete bday-year Attribute

How to add HTML <input> autocomplete sex Attribute

sex Expects the gender
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
  <label for="address-line">Name:</label>
  <input type="text" id="address-line" name="address-line"  autocomplete="sex"><br><br>
  <input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete sex Attribute

How to add HTML <input> autocomplete one-time-code Attribute

one-time-code Expects a one time code for verification etc.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
  <label for="address-line">Name:</label>
  <input type="text" id="address-line" name="address-line"  autocomplete="one-time-code"><br><br>
  <input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete one-time-code Attribute

How to add HTML <input> autocomplete organization Attribute

organization Expects the company name
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
  <label for="address-line">Name:</label>
  <input type="text" id="address-line" name="address-line"  autocomplete="organization"><br><br>
  <input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete organization Attribute

How to add HTML <input> autocomplete cc-name Attribute

cc-name Expects the credit card owner's full name
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
  <label for="address-line">Name:</label>
  <input type="text" id="address-line" name="address-line"  autocomplete="cc-name"><br><br>
  <input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete cc-name Attribute

How to add HTML <input> autocomplete cc-given-name Attribute

cc-given-name Expects the credit card owner's first name
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
  <label for="address-line">Name:</label>
  <input type="text" id="address-line" name="address-line"  autocomplete="cc-given-name"><br><br>
  <input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete cc-given-name Attribute

How to add HTML <input> autocomplete cc-additional-name Attribute

cc-additional-name Expects the credit card owner's middle name
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
  <label for="address-line">Name:</label>
  <input type="text" id="address-line" name="address-line"  autocomplete="cc-additional-name"><br><br>
  <input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete cc-additional-name Attribute

How to add HTML <input> autocomplete cc-family-name Attribute

cc-family-name Expects the credit card owner's full name
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
  <label for="address-line">Name:</label>
  <input type="text" id="address-line" name="address-line"  autocomplete="cc-family-name"><br><br>
  <input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete cc-family-name Attribute

How to add HTML <input> autocomplete cc-number Attribute

cc-number Expects the credit card's number
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
  <label for="address-line">Name:</label>
  <input type="text" id="address-line" name="address-line"  autocomplete="cc-number"><br><br>
  <input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete cc-number Attribute

How to add HTML <input> autocomplete cc-exp Attribute

cc-exp Expects the credit card's expiration date
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
  <label for="address-line">Name:</label>
  <input type="text" id="address-line" name="address-line"  autocomplete="cc-exp"><br><br>
  <input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete cc-exp Attribute

How to add HTML <input> autocomplete cc-exp-month Attribute

cc-exp-month Expects the credit card's expiration month
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
<label for="address-line">Name:</label>
<input type="text" id="address-line" name="address-line"  autocomplete="cc-exp-month"><br><br>
<input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete cc-exp-month Attribute

How to add HTML <input> autocomplete cc-exp-year Attribute

cc-exp-year Expects the credit card's expiration year
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
<label for="address-line">Name:</label>
<input type="text" id="address-line" name="address-line"  autocomplete="cc-exp-year"><br><br>
<input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete cc-exp-year Attribute

How to add HTML <input> autocomplete cc-csc Attribute

cc-csc Expects the CVC code
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
<label for="address-line">Name:</label>
<input type="text" id="address-line" name="address-line"  autocomplete="cc-csc"><br><br>
<input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete cc-csc Attribute

How to add HTML <input> autocomplete cc-type Attribute

cc-type Expects the credit card's type of payment
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
<label for="address-line">Name:</label>
<input type="text" id="address-line" name="address-line"  autocomplete="cc-type"><br><br>
<input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete cc-type Attribute

How to add HTML <input> autocomplete transaction-currency Attribute

transaction-currency Expects the currency
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
<label for="address-line">Name:</label>
<input type="text" id="address-line" name="address-line"  autocomplete="transaction-currency"><br><br>
<input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete transaction-currency Attribute

How to add HTML <input> autocomplete transaction-amount Attribute

transaction-amount Expects a number, the amount
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
<label for="address-line">Name:</label>
<input type="text" id="address-line" name="address-line"  autocomplete="transaction-amount"><br><br>
<input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete transaction-amount Attribute

How to add HTML <input> autocomplete language Attribute

language Expects the preferred language
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
<label for="address-line">Name:</label>
<input type="text" id="address-line" name="address-line"  autocomplete="language"><br><br>
<input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete language Attribute

How to add HTML <input> autocomplete url Attribute

url Expects a we address
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
<label for="address-line">Name:</label>
<input type="text" id="address-line" name="address-line"  autocomplete="url"><br><br>
<input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete url Attribute

How to add HTML <input> autocomplete email Attribute

email Expects the email address
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
<label for="address-line">Name:</label>
<input type="text" id="address-line" name="address-line"  autocomplete="email"><br><br>
<input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete email Attribute

How to add HTML <input> autocomplete photo Attribute

photo Expects an image
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
<label for="address-line">Name:</label>
<input type="text" id="address-line" name="address-line"  autocomplete="photo"><br><br>
<input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete photo Attribute

How to add HTML <input> autocomplete tel Attribute

tel Expects the full phone number
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
<label for="address-line">Name:</label>
<input type="text" id="address-line" name="address-line"  autocomplete="tel"><br><br>
<input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete tel Attribute

How to add HTML <input> autocomplete tel-country-code Attribute

tel-country-code Expects the country code of the phone number
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
<label for="address-line">Name:</label>
<input type="text" id="address-line" name="address-line"  autocomplete="tel-country-code"><br><br>
<input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete tel-country-code Attribute

How to add HTML <input> autocomplete tel-national Attribute

tel-national Expects the phone number with no country code
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
<label for="address-line">Name:</label>
<input type="text" id="address-line" name="address-line"  autocomplete="tel-national"><br><br>
<input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete tel-national Attribute

How to add HTML <input> autocomplete tel-area-code Attribute

tel-area-code Expects the area code of the phone number
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
<label for="address-line">Name:</label>
<input type="text" id="address-line" name="address-line"  autocomplete="tel-area-code"><br><br>
<input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete tel-area-code Attribute

How to add HTML <input> autocomplete tel-local Attribute

tel-local Expects the phone number with no country code and no area code
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
<label for="address-line">Name:</label>
<input type="text" id="address-line" name="address-line"  autocomplete="tel-local"><br><br>
<input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete tel-local Attribute

How to add HTML <input> autocomplete tel-local-prefix Attribute

tel-local-prefix Expects the local prefix of the phone number
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
<label for="address-line">Name:</label>
<input type="text" id="address-line" name="address-line"  autocomplete="tel-local-prefix"><br><br>
<input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete tel-local-prefix Attribute

How to add HTML <input> autocomplete tel-local-suffix Attribute

tel-local-suffix Expects the local suffix of the phone number
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
<label for="address-line">Name:</label>
<input type="text" id="address-line" name="address-line"  autocomplete="tel-local-suffix"><br><br>
<input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete tel-local-suffix Attribute

How to add HTML <input> autocomplete tel-extension Attribute

tel-extension Expects the extension code of the phone number
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
<label for="address-line">Name:</label>
<input type="text" id="address-line" name="address-line"  autocomplete="tel-extension"><br><br>
<input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete tel-extension Attribute

How to add HTML <input> autocomplete impp Attribute

impp Expects the url of an instant messaging protocol endpoint
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autocomplete attribute</h1>

<form action="/action_page.php">
<label for="address-line">Name:</label>
<input type="text" id="address-line" name="address-line"  autocomplete="impp"><br><br>
<input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autocomplete impp Attribute

How to add HTML <input> autofocus Attribute

Let the "First name" input field automatically get focus when the page loads:

Definition and Usage

The autofocus attribute is a boolean attribute.

When present, it specifies that an <input> element should automatically get focus when the page loads.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<input autofocus>

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The autofocus attribute</h1>

<form action="/action_page.php">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname" autofocus><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> autofocus Attribute

How to add HTML <input> checked Attribute

Definition and Usage

The checked attribute is a boolean attribute.

When present, it specifies that an <input> element should be pre-selected (checked) when the page loads.

The checked attribute can be used with <input type="checkbox"> and <input type="radio">.

The checked attribute can also be set after the page load, with a JavaScript.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<input checked>

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The input checked attribute</h1>

<form action="/action_page.php" method="get">
  <input type="checkbox" name="vehicle1" value="Bike">
  <label for="vehicle1"> I have a bike</label><br>
  <input type="checkbox" name="vehicle2" value="Car">
  <label for="vehicle2"> I have a car</label><br>
  <input type="checkbox" name="vehicle3" value="Boat" checked>
  <label for="vehicle3"> I have a boat</label><br><br>
  <input type="submit" value="Submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> checked Attribute

How to add HTML <input> dirname Attribute

An HTML form where the field's text direction will be submitted:

Definition and Usage

The dirname attribute enables the submission of the text direction of the input field

The dirname attribute's value is always the name of the input field, followed by ".dir".


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The dirname attribute</h1>

<form action="/action_page.php">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname" dirname="fname.dir">
  <input type="submit" value="Submit">
</form>

<p>When the form is being submitted, the text direction of the input field will also be submitted.</p>

</body>
</html>

Output should be:

How to add HTML <input> dirname Attribute

How to add HTML <input> disabled Attribute

An HTML form with a disabled input field:

Definition and Usage

The disabled attribute is a boolean attribute.

When present, it specifies that the <input> element should be disabled.

A disabled input element is unusable and un-clickable.

The disabled attribute can be set to keep a user from using the <input> element until some other condition has been met (like selecting a checkbox, etc.). Then, a JavaScript could remove the disabled value, and make the <input> element usable.

Tip: Disabled <input> elements in a form will not be submitted!


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<input disabled>

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The input disabled attribute</h1>

<form action="/action_page.php">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname" disabled><br><br>
  <input type="submit" value="Submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> disabled Attribute

How to add HTML <input> form Attribute

An input field located outside the HTML form (but still a part of the form):

Definition and Usage

The form attribute specifies the form the <input> element belongs to.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<input form="form_id">

Attribute Values

Value Description
form_id Specifies the form element the <input> element belongs to. The value of this attribute must be the id attribute of a <form> element in the same document.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The form attribute</h1>

<form action="/action_page.php" id="form1">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <input type="submit" value="Submit">
</form>

<p>The "Last name" field below is outside the form element, but still part of the form.</p>

<label for="lname">Last name:</label>
<input type="text" id="lname" name="lname" form="form1">

</body>
</html>

Output should be:

How to add HTML <input> form Attribute

How to add HTML <input> formaction Attribute

An HTML form with two submit buttons, with different actions:

Definition and Usage

The formaction attribute specifies the URL of the file that will process the input control when the form is submitted.

The formaction attribute overrides the action attribute of the <form> element.

Note: The formaction attribute is used with type="submit" and type="image".


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<input formaction="URL">

Attribute Values

Value Description
URL Specifies the URL of the file that will process the input control when the form is submitted.

Possible values:

  • An absolute URL - the full address of a page (like href="http://www.example.com/formresult.asp")
  • A relative URL - points to a file within the current site (like href="formresult.asp")
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The formaction attribute</h1>

<form action="/action_page.php">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="submit" value="Submit">
  <input type="submit" formaction="/action_page2.php" value="Submit to another page">
</form>

</body>
</html>

Output should be:

How to add HTML <input> formaction Attribute

How to add HTML <input> formenctype Attribute

Send form-data that is default encoded (the first submit button), and encoded as "multipart/form-data" (the second submit button):

Definition and Usage

The formenctype attribute specifies how the form-data should be encoded when submitting it to the server (only for forms with method="post")

The formenctype attribute overrides the enctype attribute of the <form> element.

Note: The formenctype attribute is used with type="submit" and type="image".


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<input formenctype="value">

Attribute Values

Value Description
application/x-www-form-urlencoded Default. All characters are encoded before sent (spaces are converted to "+" symbols, and special characters are converted to ASCII HEX values)
multipart/form-data  This value is necessary if the user will upload a file through the form
text/plain Sends data without any encoding at all. Not recommended
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The formenctype attribute</h1>

<form action="/action_page_binary.asp" method="post">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <input type="submit" value="Submit">
  <input type="submit" formenctype="multipart/form-data" value="Submit as Multipart/form-data">
</form>

</body>
</html>

Output should be:

How to add HTML <input> formenctype Attribute

How to add HTML <input> formmethod Attribute

The second submit button overrides the HTTP method of the form:

Definition and Usage

The formmethod attribute defines the HTTP method for sending form-data to the action URL.

The formmethod attribute overrides the method attribute of the <form> element.

Note: The formmethod attribute can be used with type="submit" and type="image".

The form-data can be sent as URL variables (method="get") or as an HTTP post transaction (method="post").

Notes on the "get" method:

  • This method appends the form-data to the URL in name/value pairs
  • This method is useful for form submissions where a user want to bookmark the result
  • There is a limit to how much data you can place in a URL (varies between browsers), therefore, you cannot be sure that all of the form-data will be correctly transferred
  • Never use the "get" method to pass sensitive information! (password or other sensitive information will be visible in the browser's address bar)

Notes on the "post" method:

  • This method sends the form-data as an HTTP post transaction
  • Form submissions with the "post" method cannot be bookmarked
  • The "post" method is more robust and secure than "get", and "post" does not have size limitations

Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<input formmethod="get|post">

Attribute Values

Value Description
get Default. Appends the form-data to the URL in name/value pairs: URL?name=value&name=value
post Sends the form-data as an HTTP post transaction
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The formmethod attribute</h1>

<form action="/action_page.php" method="get" target="_blank">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="submit" value="Submit">
  <input type="submit" formmethod="post" value="Submit using POST">
</form>

</body>
</html>

Output should be:

How to add HTML <input> formmethod Attribute

How to add HTML <input> formmethod get Attribute

get Default. Appends the form-data to the URL in name/value pairs: URL?name=value&name=value
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The formmethod attribute</h1>

<form action="/action_page.php" method="get" target="_blank">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="submit" value="Submit">
  <input type="submit" formmethod="post" value="Submit using POST">
</form>

</body>
</html>

Output should be:

How to add HTML <input> formmethod get Attribute

How to add HTML <input> formmethod post Attribute

post Sends the form-data as an HTTP post transaction
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The formmethod attribute</h1>

<form action="/action_page.php" method="post" target="_blank">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="submit" value="Submit">
  <input type="submit" formmethod="post" value="Submit using POST">
</form>

</body>
</html>

Output should be:

How to add HTML <input> formmethod post Attribute

How to add HTML <input> formnovalidate Attribute

A form with two submit buttons (with and without validation):

Definition and Usage

The formnovalidate attribute is a boolean attribute.

When present, it specifies that the <input> element should not be validated when submitted.

The formnovalidate attribute overrides the novalidate attribute of the <form> element.

Note: The formnovalidate attribute can be used with type="submit".


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<input formnovalidate="formnovalidate">

Note: The formnovalidate attribute is a boolean attribute, and can be set in the following ways:

  • <input formnovalidate>
  • <input formnovalidate="formnovalidate">
  • <input formnovalidate="">
index.html
Example: HTML
<form action="/action_page.php">
  <label for="email">Enter your email:</label>
  <input type="email" id="email" name="email"><br><br>
  <input type="submit" value="Submit">
  <input type="submit" formnovalidate="formnovalidate" value="Submit without validation">
</form> 

Output should be:

How to add HTML <input> formnovalidate Attribute

How to add HTML <input> formtarget Attribute

A form with two submit buttons, with different target windows.

Definition and Usage

The formtarget attribute specifies a name or a keyword that indicates where to display the response that is received after submitting the form.

The formtarget attribute overrides the target attribute of the <form> element.

Note: The formtarget attribute can be used with type="submit" and type="image".


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<input formtarget="_blank|_self|_parent|_top|framename">

Attribute Values

Value Description
_blank The response is displayed in a new window or tab
_self The response is displayed in the same frame (this is default)
_parent The response is displayed in the parent frame
_top The response is displayed in the full body of the window
framename The response is displayed in a named iframe
index.html
Example: HTML
<form action="/action_page.php">
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="submit" value="Submit as normal">
  <input type="submit" formtarget="_blank" value="Submit to a new window">
</form> 

Output should be:

How to add HTML <input> formtarget Attribute

How to add HTML <input> formtarget _blank Attribute

_blank The response is displayed in a new window or tab
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The formtarget attribute</h1>

<form action="/action_page.php">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="submit" value="Submit as normal">
  <input type="submit" formtarget="_blank" value="Submit to a new window/tab">
</form>

</body>
</html>

Output should be:

How to add HTML <input> formtarget _blank Attribute

How to add HTML <input> formtarget _self Attribute

_self The response is displayed in the same frame (this is default)
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The formtarget attribute</h1>

<form action="/action_page.php">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="submit" value="Submit as normal">
  <input type="submit" formtarget="_self" value="Submit to a new window/tab">
</form>

</body>
</html>

Output should be:

How to add HTML <input> formtarget _self Attribute

How to add HTML <input> formtarget _parent Attribute

_parent The response is displayed in the parent frame
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The formtarget attribute</h1>

<form action="/action_page.php">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="submit" value="Submit as normal">
  <input type="submit" formtarget="_parent" value="Submit to a new window/tab">
</form>

</body>
</html>

Output should be:

How to add HTML <input> formtarget _parent Attribute

How to add HTML <input> formtarget _top Attribute

_top The response is displayed in the full body of the window
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The formtarget attribute</h1>

<form action="/action_page.php">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="submit" value="Submit as normal">
  <input type="submit" formtarget="_top" value="Submit to a new window/tab">
</form>

</body>
</html>

Output should be:

How to add HTML <input> formtarget _top Attribute

How to add HTML <input> formtarget framename Attribute

framename The response is displayed in a named iframe
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The formtarget attribute</h1>

<form action="/action_page.php">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="submit" value="Submit as normal">
  <input type="submit" formtarget="framename" value="Submit to a new window/tab">
</form>

</body>
</html>

Output should be:

How to add HTML <input> formtarget framename Attribute

How to set HTML <input> height Attribute

Define an image as the submit button, with height and width attributes:

Definition and Usage

The height attribute specifies the height of the <input> element.

Note: The height attribute is used only with <input type="image">.

Tip: Always specify both the height and width attributes for images. If height and width are set, the space required for the image is reserved when the page is loaded. However, without these attributes, the browser does not know the size of the image, and cannot reserve the appropriate space to it. The effect will be that the page layout will change during loading (while the images load).


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<input height="pixels">

Attribute Values

Value Description
pixels The height in pixels (e.g. height="100")
index.html
Example: HTML
<input type="image" src="https://horje.com/uploads/demo/2024-03-13-15-04-45-img_submit.gif" alt="Submit" width="48" height="48">

Output should be:

How to set HTML <input> height Attribute

How to set HTML <input> list Attribute

An <input> element with pre-defined values in a <datalist>:

Definition and Usage

The list attribute refers to a <datalist> element that contains pre-defined options for an <input> element.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<input list="datalist_id">

Attribute Values

Value Description
datalist_id Specifies the id of the datalist to bind the <input> element to
index.html
Example: HTML
<input list="browsers">

<datalist id="browsers">
  <option value="Internet Explorer">
  <option value="Firefox">
  <option value="Google Chrome">
  <option value="Opera">
  <option value="Safari">
</datalist> 

Output should be:

How to set HTML <input> list Attribute

How to add HTML <input> max Attribute

Use of the min and max attributes.

Definition and Usage

The max attribute specifies the maximum value for an <input> element.

Tip: Use the max attribute together with the min attribute to create a range of legal values.

Note: The max and min attributes works with the following input types: number, range, date, datetime-local, month, time and week.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<input max="number|date">

Attribute Values

Value Description
number Specifies the maximum value allowed
date Specifies the maximum date allowed
index.html
Example: HTML
<form action="/action_page.php">
  <label for="datemax">Enter a date before 1980-01-01:</label>
  <input type="date" id="datemax" name="datemax" max="1979-12-31"><br><br>

  <label for="datemin">Enter a date after 2000-01-01:</label>
  <input type="date" id="datemin" name="datemin" min="2000-01-02"><br><br>

  <label for="quantity">Quantity (between 1 and 5):</label>
  <input type="number" id="quantity" name="quantity" min="1" max="5"><br><br>

  <input type="submit">
</form>

Output should be:

How to add HTML <input> max Attribute

How to add HTML <input> max number Attribute

number Specifies the maximum value allowed
index.html
Example: HTML
<input type="number" id="quantity" name="quantity" min="1" max="5">

Output should be:

How to add HTML <input> max number Attribute

How to add HTML <input> max date Attribute

date Specifies the maximum date allowed
index.html
Example: HTML
<input type="date" id="quantity" name="quantity" min="1" max="5">

Output should be:

How to add HTML <input> max date Attribute

How to add HTML <input> maxlength Attribute

An <input> element with a maximum length of 10 characters:

Definition and Usage

The maxlength attribute specifies the maximum number of characters allowed in the <input> element.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<input maxlength="number">

Attribute Values

Value Description
number The maximum number of characters allowed in the <input> element. Default value is 524288
index.html
Example: HTML
<form action="/action_page.php">
  <label for="username">Username:</label>
  <input type="text" id="username" name="username" maxlength="10"><br><br>
  <input type="submit" value="Submit">
</form> 

Output should be:

How to add HTML <input> maxlength Attribute

How to add HTML <input> min Attribute

Use of the min and max attributes.

Definition and Usage

The min attribute specifies the minimum value for an <input> element.

Tip: Use the min attribute together with the max attribute to create a range of legal values.

Note: The max and min attributes works with the following input types: number, range, date, datetime-local, month, time and week.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<input min="number|date">

Attribute Values

Value Description
number Specifies the minimum value allowed
date Specifies the minimum date allowed
index.html
Example: HTML
<form action="/action_page.php">

  <label for="datemax">Enter a date before 1980-01-01:</label>
  <input type="date" id="datemax" name="datemax" max="1979-12-31"><br><br>

  <label for="datemin">Enter a date after 2000-01-01:</label>
  <input type="date" id="datemin" name="datemin" min="2000-01-02"><br><br>

  <label for="quantity">Quantity (between 1 and 5):</label>
  <input type="number" id="quantity" name="quantity" min="1" max="5"><br><br>

  <input type="submit">

</form> 

Output should be:

How to add HTML <input> min Attribute

How to add HTML <input> min number Attribute

number Specifies the minimum value allowed
index.html
Example: HTML
<input type="number" id="quantity" name="quantity" min="1" max="5">

Output should be:

How to add HTML <input> min number Attribute

How to add HTML <input> min date Attribute

date Specifies the minimum date allowed
index.html
Example: HTML
<input type="date" id="quantity" name="quantity" min="1" max="5">

Output should be:

How to add HTML <input> min date Attribute

How to add HTML <input> minlength Attribute

An <input> element with a minimum length of 8 characters:

Definition and Usage

The minlength attribute specifies the minimum number of characters required in an input field.

Note: The minlength attribute can be used with input type: text, search, url, tel, email, and password.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<input minlength="number">

Attribute Values

Value Description
number The minimum number of characters required in an <input> element
index.html
Example: HTML
<input type="password" id="password" name="password" minlength="8">

Output should be:

How to add HTML <input> minlength Attribute

How to add HTML <input> multiple Attribute

A file upload field that accepts multiple values.

Definition and Usage

The multiple attribute is a boolean attribute.

When present, it specifies that the user is allowed to enter more than one value in the <input> element.

Note: The multiple attribute works with the following input types: email, and file.

Tip: For <input type="file">: To select multiple files, hold down the CTRL or SHIFT key while selecting.

Tip: For <input type="email">: Separate each email with a comma, like: [email protected], [email protected], [email protected] in the email field.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<input multiple>

index.html
Example: HTML
<input type="file" id="files" name="files" multiple>

Output should be:

How to add HTML <input> multiple Attribute

How to add HTML <input> name Attribute

An HTML form with three input fields; two text fields and one submit button.

Definition and Usage

The name attribute specifies the name of an <input> element.

The name attribute is used to reference elements in a JavaScript, or to reference form data after a form is submitted.

Note: Only form elements with a name attribute will have their values passed when submitting a form.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<input name="text">

Attribute Values

Value Description
text Specifies the name of the <input> element
index.html
Example: HTML
<form action="/action_page.php">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="submit" value="Submit">
</form> 

Output should be:

How to add HTML <input> name Attribute

How to add HTML <input> pattern Attribute

An HTML form with an input field that can contain only three letters (no numbers or special characters).

Definition and Usage

The pattern attribute specifies a regular expression that the <input> element's value is checked against on form submission.

Note: The pattern attribute works with the following input types: text, date, search, url, tel, email, and password.

Tip: Use the global title attribute to describe the pattern to help the user.

Tip: Learn more about regular expressions in our JavaScript tutorial.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<input pattern="regexp">

Attribute Values

Value Description
regexp Specifies a regular expression that the <input> element's value is checked against

 

index.html
Example: HTML
<form action="/action_page.php">
  <label for="country_code">Country code:</label>
  <input type="text" id="country_code" name="country_code"
  pattern="[A-Za-z]{3}" title="Three letter country code"><br><br>
  <input type="submit">
</form> 

Output should be:

How to add HTML <input> pattern Attribute

How to add HTML <input> pattern Specific characters Attribute

An <input> element with type="password" that must contain 8 or more characters:

index.html
Example: HTML
<form action="/action_page.php">
  <label for="pwd">Password:</label>
  <input type="password" id="pwd" name="pwd"
  pattern=".{8,}" title="Eight or more characters">
  <input type="submit">
</form>

Output should be:

How to add HTML <input> pattern Specific characters Attribute

How to add HTML <input> pattern uppercase and lowercase letter Attribute

An <input> element with type="password" that must contain 8 or more characters that are of at least one number, and one uppercase and lowercase letter.

index.html
Example: HTML
<form action="/action_page.php">
  <label for="pwd">Password:</label>
  <input type="password" id="pwd" name="pwd"
  pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}"
  title="Must contain at least one  number and one uppercase and lowercase letter, and at least 8 or more characters">
  <input type="submit">
</form>

Output should be:

How to add HTML <input> pattern uppercase and lowercase letter Attribute

How to add HTML <input> pattern characters @,.;''#$%^&8 Attribute

An <input> element with type="email" that must be in the following order: characters@characters.domain (characters followed by an @ sign, followed by more characters, and then a "."

After the "." sign, add at least 2 letters from a to z

index.html
Example: HTML
<form action="/action_page.php">
  <label for="email">Email:</label>
  <input type="email" id="email" name="email"
  pattern="[a-z0-9._%+\-]+@[a-z0-9.\-]+\.[a-z]{2,}$">
  <input type="submit">
</form>

Output should be:

How to add HTML <input> pattern characters @,.;''#$%^&8 Attribute

How to add HTML <input> pattern characters [^'\x22]+

An <input> element with type="search" that CANNOT contain the following characters: ' or "

index.html
Example: HTML
<form action="/action_page.php">
  <label for="search">Search:</label>
  <input type="search" id="search" name="search"
  pattern="[^'\x22]+" title="Invalid input">
  <input type="submit">
</form>

Output should be:

How to add HTML <input> pattern characters [^'\x22]+

How to add HTML <input> pattern characters http:// or https://

An <input> element with type="url" that must start with http:// or https:// followed by at least one character.

If you enter the characters: jahddd then you will get warning: characters Please Enter a URL.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The input pattern attribute</h1>

<p>A form with a URL field that must start with http:// or https:// followed by at least one character:</p>

<form action="/action_page.php">
  <label for="website">Homepage:</label>
  <input type="url" id="website" name="website" pattern="https?://.+" title="Include http://">
  <input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> pattern characters http:// or https://

How to add HTML <input> placeholder Attribute

A telephone input field with a placeholder text.

Definition and Usage

The placeholder attribute specifies a short hint that describes the expected value of an input field (e.g. a sample value or a short description of the expected format).

The short hint is displayed in the input field before the user enters a value.

Note: The placeholder attribute works with the following input types: text, search, url, tel, email, and password.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<input placeholder="text">

Attribute Values

Value Description
text Specifies a short hint that describes the expected value of the input field
index.html
Example: HTML
<input type="tel" id="phone" name="phone" placeholder="123-45-678"
  pattern="[0-9]{3}-[0-9]{2}-[0-9]{3}">

Output should be:

How to add HTML <input> placeholder Attribute

How to add HTML <input> popovertarget Attribute

Refer to a popover element with the popovertarget attribute to show/hide the specified popover element:

Definition and Usage

With the popovertarget attribute you can refer to the popover element with the specified id, and toggle between showing and hiding it:

The popovertarget only works when type="button".

Browser Support

Syntax

<input type="button" popovertarget="element_id">


Attribute Values

Value Description
element_id The id of the popover element related to this button
index.html
Example: HTML
<h1 popover id="myheader">Hello</h1>
<input type="button" popovertarget="myheader" value="Click me!"> 

Output should be:

How to add HTML <input> popovertarget Attribute

How to add HTML <input> popovertargetaction Attribute

When the input button is clicked, the popover element will show.

Definition and Usage

The popovertargetaction attribute allows you to define what happens when you click the button.

You can choose between the values "show", "hide", and "toggle".

The popovertargetaction only works when type="button".

If the popovertargetaction attribute is not specified, the default "toggle" value will be used.


Browser Support

Syntax

<input type="button" popovertarget="element_id popovertargetaction="hide|show|toggle"">


Attribute Values

Value Description  
hide The popover element is hidden when you click the button  
show The popover element is showed when you click the button  
toggle Default value. The popover element is toggled between hidding and showing when you click the button  
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The input popovertargetaction Attribute</h1>

<h1 popover id="myheader">Hello</h1>

<input type="button" popovertarget="myheader" popovertargetaction="show" value="Show popover">

<p>Click the button and it will show the popover element.</p>

</body>
</html>

Output should be:

How to add HTML <input> popovertargetaction Attribute

How to add HTML <input> popovertargetaction hide Attribute

hide The popover element is hidden when you click the button
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The input popovertargetaction Attribute</h1>

<h1 popover id="myheader">Hello</h1>

<input type="button" popovertarget="myheader" popovertargetaction="show" value="Show">
<input type="button" popovertarget="myheader" popovertargetaction="hide" value="Hide">
<input type="button" popovertarget="myheader" popovertargetaction="toggle" value="Toggle">

<p>Click the buttons to show/hide the popover element.</p>

</body>
</html>

Output should be:

How to add HTML <input> popovertargetaction hide Attribute

How to add HTML <input> popovertargetaction show Attribute

show The popover element is showed when you click the button
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The input popovertargetaction Attribute</h1>

<h1 popover id="myheader">Hello</h1>

<input type="button" popovertarget="myheader" popovertargetaction="show" value="Show">
<input type="button" popovertarget="myheader" popovertargetaction="hide" value="Hide">
<input type="button" popovertarget="myheader" popovertargetaction="toggle" value="Toggle">

<p>Click the buttons to show/hide the popover element.</p>

</body>
</html>

Output should be:

How to add HTML <input> popovertargetaction show Attribute

How to add HTML <input> popovertargetaction toggle Attribute

toggle Default value. The popover element is toggled between hidding and showing when you click the button
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The input popovertargetaction Attribute</h1>

<h1 popover id="myheader">Hello</h1>

<input type="button" popovertarget="myheader" popovertargetaction="show" value="Show">
<input type="button" popovertarget="myheader" popovertargetaction="hide" value="Hide">
<input type="button" popovertarget="myheader" popovertargetaction="toggle" value="Toggle">

<p>Click the buttons to show/hide the popover element.</p>

</body>
</html>

Output should be:

How to add HTML <input> popovertargetaction toggle Attribute

How to add HTML <input> readonly Attribute

An HTML form with a read-only input field.

Definition and Usage

The readonly attribute is a boolean attribute.

When present, it specifies that an input field is read-only.

A read-only input field cannot be modified (however, a user can tab to it, highlight it, and copy the text from it).

The readonly attribute can be set to keep a user from changing the value until some other conditions have been met (like selecting a checkbox, etc.). Then, a JavaScript can remove the readonly value, and make the input field editable.

Note: A form will still submit an input field that is readonly, but will not submit an input field that is disabled!


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<input readonly>

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The input readonly attribute</h1>

<form action="/action_page.php">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="country">Country:</label>  
  <input type="text" id="country" name="country" value="Norway" readonly><br><br>
  <input type="submit" value="Submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> readonly Attribute

How to add HTML <input> required Attribute

An HTML form with a required input field.

Definition and Usage

The required attribute is a boolean attribute.

When present, it specifies that an input field must be filled out before submitting the form.

Note: The required attribute works with the following input types: text, search, url, tel, email, password, date pickers, number, checkbox, radio, and file.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<input required>

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The input required attribute</h1>

<form action="/action_page.php">
  <label for="username">Username:</label>
  <input type="text" id="username" name="username" required>
  <input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input> required Attribute

How to add HTML <input> size Attribute

An HTML form with two input fields with a width of 50 and 4 characters.

Definition and Usage

The size attribute specifies the visible width, in characters, of an <input> element.

Note: The size attribute works with the following input types: text, search, tel, url, email, and password.

Tip: To specify the maximum number of characters allowed in the <input> element, use the maxlength attribute.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<input size="number">

Attribute Values

Value Description
number Specifies the width of an <input> element, in characters. Default value is 20
index.html
Example: HTML
<label for="fname">First name:</label>
  <input type="text" id="fname" name="fname" size="50"><br><br>
  <label for="pin">PIN:</label>
  <input type="text" id="pin" name="pin" maxlength="4" size="4">

Output should be:

How to add HTML <input> size Attribute

How to add HTML <input> src Attribute

An HTML form with an image that represents the submit button.

Definition and Usage

The src attribute specifies the URL of the image to use as a submit button.

Note: The src attribute can only be used with (and is required for) <input type="image">.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<input src="URL">

Attribute Values

Value Description
URL Specifies the URL of the image to use as a submit button.

Possible values:

  • An absolute URL - points to another web site (like src="http://www.example.com/submit.gif")
  • A relative URL - points to a file within a web site (like src="submit.gif")
index.html
Example: HTML
<form action="/action_page.php">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <input type="image" src="submit.gif" alt="Submit" width="48" height="48">
</form>

Output should be:

How to add HTML <input> src Attribute

How to add HTML <input> step Attribute

An HTML form with an input field with a specified legal number intervals:

Definition and Usage

The step attribute specifies the interval between legal numbers in an <input> element.

Example: if step="3", legal numbers could be -3, 0, 3, 6, etc.

Tip: The step attribute can be used together with the max and min attributes to create a range of legal values.

Note: The step attribute works with the following input types: number, range, date, datetime-local, month, time and week.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<input step="number">

Attribute Values

Value Description
number Specifies the interval between legal numbers in the input field. Default is 1
any  
index.html
Example: HTML
<form action="/action_page.php">
  <label for="points">Points:</label>
  <input type="number" id="points" name="points" step="3">
  <input type="submit">
</form> 

Output should be:

How to add HTML <input> step Attribute

How to add HTML <input> type Attribute

An HTML form with two input fields; one text field and one submit button.

Definition and Usage

The type attribute specifies the type of <input> element to display.

If the type attribute is not specified, the default type is "text".


Browser Support

Syntax

<input type="value">

Attribute Values

Value Description
button Defines a clickable button (mostly used with a JavaScript to activate a script)
checkbox Defines a checkbox
color Defines a color picker
date Defines a date control (year, month, day (no time))
datetime-local Defines a date and time control (year, month, day, time (no timezone)
email Defines a field for an e-mail address
file Defines a file-select field and a "Browse" button (for file uploads)
hidden Defines a hidden input field
image Defines an image as the submit button
month Defines a month and year control (no timezone)
number Defines a field for entering a number
password Defines a password field
radio Defines a radio button
range Defines a range control (like a slider control)
reset Defines a reset button
search Defines a text field for entering a search string
submit Defines a submit button
tel Defines a field for entering a telephone number
text Default. Defines a single-line text field
time Defines a control for entering a time (no timezone)
url Defines a field for entering a URL
week Defines a week and year control (no timezone)
index.html
Example: HTML
<input type="text" id="username" name="username">

Output should be:

How to add HTML <input> type Attribute

How to add HTML <input> type button Attribute

A push button that activates a JavaScript when it is clicked.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>Show a Push Button</h1>

<p>The button below activates a JavaScript function when it is clicked.</p>
<form>
  <input type="button" value="Click me" onclick="msg()">
</form>

<script>
function msg() {
  alert("Hello world!");
}
</script>

</body>
</html>

Output should be:

How to add HTML <input> type button Attribute

How to add HTML <input> type checkbox Attribute

Input type: checkbox

Checkboxes let a user select one or more options of a limited number of choices.

index.html
Example: HTML
<input type="checkbox" id="vehicle1" name="vehicle1" value="Bike">
<label for="vehicle1"> I have a bike</label><br>
<input type="checkbox" id="vehicle2" name="vehicle2" value="Car">
<label for="vehicle2"> I have a car</label><br>
<input type="checkbox" id="vehicle3" name="vehicle3" value="Boat">
<label for="vehicle3"> I have a boat</label><br> 

Output should be:

How to add HTML <input> type checkbox Attribute

How to add HTML <input> type color Attribute

Input type: color

Select a color from a color picker.

index.html
Example: HTML
<label for="favcolor">Select your favorite color:</label>
<input type="color" id="favcolor" name="favcolor"> 

Output should be:

How to add HTML <input> type color Attribute

How to add HTML <input> type date Attribute

Input type: date

Define a date control:

index.html
Example: HTML
<label for="birthday">Birthday:</label>
<input type="date" id="birthday" name="birthday"> 

Output should be:

How to add HTML <input> type date Attribute

How to add HTML <input> type datetime-local Attribute

Input type: datetime-local

Define a date and time control (no time zone):

index.html
Example: HTML
<label for="birthdaytime">Birthday (date and time):</label>
<input type="datetime-local" id="birthdaytime" name="birthdaytime"> 

Output should be:

How to add HTML <input> type datetime-local Attribute

How to add HTML <input> type email Attribute

Input type: email

Define a field for an e-mail address (will be automatically validated when submitted).

index.html
Example: HTML
<label for="email">Enter your email:</label>
<input type="email" id="email" name="email"> 

Output should be:

How to add HTML <input> type email Attribute

How to add HTML <input> type file Attribute

Define a file-select field and a "Browse..." button (for file uploads).

index.html
Example: HTML
<label for="myfile">Select a file:</label>
<input type="file" id="myfile" name="myfile"> 

Output should be:

How to add HTML <input> type file Attribute

How to add HTML <input> type hidden Attribute

Define a hidden field (not visible to a user).

A hidden field often stores what database record that needs to be updated when the form is submitted.

index.html
Example: HTML
<input type="hidden" id="custId" name="custId" value="3487"> 

Output should be:

How to add HTML <input> type hidden Attribute

How to add HTML <input> type image Attribute

Input type: image

Define an image as a submit button:

index.html
Example: HTML
<input type="image" src="img_submit.gif" alt="Submit">

Output should be:

How to add HTML <input> type image Attribute

How to add HTML <input> type month Attribute

Input type: month

Define a month and year control (no time zone).

index.html
Example: HTML
<label for="bdaymonth">Birthday (month and year):</label>
<input type="month" id="bdaymonth" name="bdaymonth"> 

Output should be:

How to add HTML <input> type month Attribute

How to add HTML <input> type number Attribute

Input type: number

Define a field for entering a number (You can also set restrictions on what numbers are accepted).

index.html
Example: HTML
<label for="quantity">Quantity (between 1 and 5):</label>
<input type="number" id="quantity" name="quantity" min="1" max="5"> 

Output should be:

How to add HTML <input> type number Attribute

How to add HTML <input> type password Attribute

Input type: password

Define a password field (characters are masked).

index.html
Example: HTML
<label for="pwd">Password:</label>
<input type="password" id="pwd" name="pwd"> 

Output should be:

How to add HTML <input> type password Attribute

How to add HTML <input> type radio Attribute

Input type: radio

Radio buttons let a user select only one of a limited number of choices.

index.html
Example: HTML
<input type="radio" id="html" name="fav_language" value="HTML">
<label for="html">HTML</label><br>
<input type="radio" id="css" name="fav_language" value="CSS">
<label for="css">CSS</label><br>
<input type="radio" id="javascript" name="fav_language" value="JavaScript">
<label for="javascript">JavaScript</label> 

Output should be:

How to add HTML <input> type radio Attribute

How to add HTML <input> type range Attribute

Input type: range

Define a control for entering a number whose exact value is not important (like a slider control). Default range is 0 to 100. However, you can set restrictions on what numbers are accepted with the min, max, and step attributes.

index.html
Example: HTML
<label for="vol">Volume (between 0 and 50):</label>
<input type="range" id="vol" name="vol" min="0" max="50"> 

Output should be:

How to add HTML <input> type range Attribute

How to add HTML <input> type reset Attribute

Input type: reset

Define a reset button (resets all form values to default values).

Tip: Use the reset button carefully! It can be annoying for users who accidentally activate the reset button.

index.html
Example: HTML
<input type="reset"> 

Output should be:

How to add HTML <input> type reset Attribute

How to add HTML <input> type search Attribute

Input type: search

Define a search field (like a site search, or Google search).

index.html
Example: HTML
<label for="gsearch">Search Google:</label>
<input type="search" id="gsearch" name="gsearch"> 

Output should be:

How to add HTML <input> type search Attribute

How to add HTML <input> type submit Attribute

Input type: submit

Define a submit button:

index.html
Example: HTML
<input type="submit"> 

Output should be:

How to add HTML <input> type submit Attribute

How to add HTML <input> type tel Attribute

Input type: tel

Define a field for entering a telephone number.

index.html
Example: HTML
<label for="phone">Enter your phone number:</label>
<input type="tel" id="phone" name="phone" pattern="[0-9]{3}-[0-9]{2}-[0-9]{3}"> 

Output should be:

How to add HTML <input> type tel Attribute

How to add HTML <input> type text Attribute

Input type: text

Define two single-line text fields that a user can enter text into.

index.html
Example: HTML
<label for="fname">First name:</label>
<input type="text" id="fname" name="fname"><br>
<label for="lname">Last name:</label>
<input type="text" id="lname" name="lname"><br>

Output should be:

How to add HTML <input> type text  Attribute

How to add HTML <input> type time Attribute

Input type: time

Define a control for entering a time (no time zone).

index.html
Example: HTML
<label for="appt">Select a time:</label>
<input type="time" id="appt" name="appt"> 

Output should be:

How to add HTML <input> type time Attribute

How to add HTML <input> type url Attribute

Input type: url

Define a field for entering a URL.

Tip: Safari on iPhone recognizes the url input type, and changes the on-screen keyboard to match it (adds .com option).

index.html
Example: HTML
<label for="homepage">Add your homepage:</label>
<input type="url" id="homepage" name="homepage"> 

Output should be:

How to add HTML <input> type url Attribute

How to add HTML <input> type week Attribute

Input type: week

Define a week and year control (no time zone).

index.html
Example: HTML
<label for="week">Select a week:</label>
<input type="week" id="week" name="week"> 

Output should be:

How to add HTML <input> type week Attribute

How to add HTML <input type="button">

button Defines a clickable button (mostly used with a JavaScript to activate a script)

A push button that activates a JavaScript function when it is clicked.

Definition and Usage

The <input type="button"> defines a clickable button (mostly used with a JavaScript to activate a script).


Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Syntax

<input type="button">

index.html
Example: HTML
<input type="button" value="Click me" onclick="msg()">

Output should be:

How to add HTML <input type=">

How to add HTML <input type="checkbox">

checkbox Defines a checkbox

Let the user select one or more options of a limited number of choices.

Definition and Usage

The <input type="checkbox"> defines a checkbox.

The checkbox is shown as a square box that is ticked (checked) when activated.

Checkboxes are used to let a user select one or more options of a limited number of choices.

Tip: Always add the <label> tag for best accessibility practices!


Browser Support

Syntax

<input type="checkbox">

index.html
Example: HTML
<input type="checkbox" id="vehicle1" name="vehicle1" value="Bike">
<label for="vehicle1"> I have a bike</label><br>
<input type="checkbox" id="vehicle2" name="vehicle2" value="Car">
<label for="vehicle2"> I have a car</label><br>
<input type="checkbox" id="vehicle3" name="vehicle3" value="Boat">
<label for="vehicle3"> I have a boat</label><br> 

Output should be:

How to add HTML <input type=">

How to add HTML <input type="color">

Show a color picker (with a predefined red value).

color Defines a color picker

Definition and Usage

The <input type="color"> defines a color picker.

The default value is #000000 (black). The value must be in seven-character hexadecimal notation.

Tip: Always add the <label> tag for best accessibility practices!


Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Syntax

<input type="color">

index.html
Example: HTML
<label for="favcolor">Select your favorite color:</label>
<input type="color" id="favcolor" name="favcolor" value="#ff0000">

Output should be:

How to add HTML <input type=">

How to add HTML <input type="date">

Show a date control.

Definition and Usage

The <input type="date"> defines a date picker.

The resulting value includes the year, month, and day.

Tip: Always add the <label> tag for best accessibility practices!


Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Syntax

<input type="date">

index.html
Example: HTML
<label for="birthday">Birthday:</label>
<input type="date" id="birthday" name="birthday"> 

Output should be:

How to add HTML <input type=">

How to add HTML <input type="datetime-local">

Show a date and time control (no timezone).

Definition and Usage

The <input type="datetime-local"> defines a date picker.

The resulting value includes the year, month, day, and time.

Tip: Always add the <label> tag for best accessibility practices! 


Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Syntax

<input type="datetime-local">

index.html
Example: HTML
<label for="birthdaytime">Birthday (date and time):</label>
<input type="datetime-local" id="birthdaytime" name="birthdaytime"> 

Output should be:

How to add HTML <input type=">

How to add HTML <input type="email">

Define a field for an e-mail address (validates automatically when submitted).

email Defines a field for an e-mail address

Definition and Usage

The <input type="email"> defines a field for an e-mail address.

The input value is automatically validated to ensure it is a properly formatted e-mail address.

To define an e-mail field that allows multiple e-mail addresses, add the "multiple" attribute.

Tip: Always add the <label> tag for best accessibility practices!


Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Syntax

<input type="email">

index.html
Example: HTML
<input type="email" id="email" name="email">

Output should be:

How to add HTML <input type=">

How to add HTML <input type="file">

Define a file-select field.

Definition and Usage

The <input type="file"> defines a file-select field and a "Browse" button for file uploads.

To define a file-select field that allows multiple files to be selected, add the multiple attribute.

Tip: Always add the <label> tag for best accessibility practices!


Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Syntax

<input type="file">

index.html
Example: HTML
<input type="file" id="myfile" name="myfile"> 

Output should be:

How to add HTML <input type=">

How to add HTML <input type="hidden">

Define a hidden field.

Definition and Usage

The <input type="hidden"> defines a hidden input field.

A hidden field lets web developers include data that cannot be seen or modified by users when a form is submitted.

A hidden field often stores what database record that needs to be updated when the form is submitted.

Note: While the value is not displayed to the user in the page's content, it is visible (and can be edited) using any browser's developer tools or "View Source" functionality. Do not use hidden inputs as a form of security!


Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Syntax

<input type="hidden">

index.html
Example: HTML
<input type="hidden" id="custId" name="custId" value="3487">

Output should be:

How to add HTML <input type=">

How to add HTML <input type="image">

Define an image as a submit button.

Definition and Usage

The <input type="image"> defines an image as a submit button.

The path to the image is specified in the src attribute.


Browser Support

Syntax

<input type="image">

index.html
Example: HTML
<input type="image" src="https://horje.com/uploads/demo/2024-03-20-15-18-38-img_submit.gif" alt="Submit" width="48" height="48">

Output should be:

How to add HTML <input type=">

How to add Align input image (with CSS) on Submit Button

See the Example.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<form action="/action_page.php">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname">
  <input type="image" src="https://horje.com/uploads/demo/2024-03-20-15-18-38-img_submit.gif" alt="Submit" style="float:right" width="48" height="48">
</form>

<p>Click on the image, and the input will be sent to a page on the server called "/action_page.php".</p>

</body>
</html>

Output should be:

How to add Align input image (with CSS) on Submit Button

How to add HTML <input type="month">

Define a month and year control (no time zone).

Definition and Usage

The <input type="month"> defines a month and year control.

The format is "YYYY-MM".

Tip: Always add the <label> tag for best accessibility practices!


Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Syntax

<input type="month">

index.html
Example: HTML
<label for="bdaymonth">Birthday (month and year):</label>
<input type="month" id="bdaymonth" name="bdaymonth"> 

Output should be:

How to add HTML <input type=">

How to add HTML <input type="number">

Define a field for entering a number (You can also set restrictions on what numbers are accepted).

Definition and Usage

The <input type="number"> defines a field for entering a number.

Use the following attributes to specify restrictions:

  • max - specifies the maximum value allowed
  • min - specifies the minimum value allowed
  • step - specifies the legal number intervals
  • value - Specifies the default value

Tip: Always add the <label> tag for best accessibility practices!


Browser Support

Syntax

<input type="number">

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>Display a Number Field</h1>

<form action="/action_page.php">
  <label for="quantity">Quantity (between 1 and 5):</label>
  <input type="number" id="quantity" name="quantity" min="1" max="5">
  <input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input type=">

How to add HTML <input type="password">

Define a password field (characters are masked).

Definition and Usage

The <input type="password"> defines a password field (characters are masked).

Note: Any forms involving sensitive information like passwords should be served over HTTPS.

Tip: Always add the <label> tag for best accessibility practices!


Browser Support

Syntax

<input type="password">

index.html
Example: HTML
<label for="pwd">Password:</label>
<input type="password" id="pwd" name="pwd"> 

Output should be:

How to add HTML <input type=">

How to add HTML <input type="radio">

Radio buttons let a user select only one of a limited number of choices.

Definition and Usage

The <input type="radio"> defines a radio button.

Radio buttons are normally presented in radio groups (a collection of radio buttons describing a set of related options). Only one radio button in a group can be selected at the same time.

Note: The radio group must share the same name (the value of the name attribute) to be treated as a group. Once the radio group is created, selecting any radio button in that group automatically deselects any other selected radio button in the same group. You can have as many radio groups on a page as you want, as long as each group has its own name.

Note: The value attribute defines the unique value associated with each radio button. The value is not shown to the user, but is the value that is sent to the server on "submit" to identify which radio button that was selected.

Tip: Always add the <label> tag for best accessibility practices!


Browser Support

Syntax

<input type="radio">

index.html
Example: HTML
<input type="radio" id="html" name="fav_language" value="HTML">
<label for="html">HTML</label><br>
<input type="radio" id="css" name="fav_language" value="CSS">
<label for="css">CSS</label><br>
<input type="radio" id="javascript" name="fav_language" value="JavaScript">
<label for="javascript">JavaScript</label> 

Output should be:

How to add HTML <input type=">

How to add HTML <input type="range">

Define a range control (like a slider control).

Definition and Usage

The <input type="range"> defines a control for entering a number whose exact value is not important (like a slider control).

Default range is 0 to 100. However, you can set restrictions on what numbers are accepted with the attributes below.

  • max - specifies the maximum value allowed
  • min - specifies the minimum value allowed
  • step - specifies the legal number intervals
  • value - Specifies the default value

Tip: Always add the <label> tag for best accessibility practices!


Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Syntax

<input type="range">

index.html
Example: HTML
<input type="range" id="points" name="points" min="0" max="10">

Output should be:

How to add HTML <input type=">

How to add HTML <input type="reset">

Define a reset button.

Definition and Usage

The <input type="reset"> defines a reset button which resets all form values to its initial values.

Tip: Avoid reset buttons in your forms! It is frustrating for users if they click them by mistake.


Browser Support

Syntax

<input type="reset">

index.html
Example: HTML
<input type="reset">

Output should be:

How to add HTML <input type=">

How to add HTML <input type="search">

Define a search field (like a site search, or Google search).

Definition and Usage

The <input type="search"> defines a text field for entering a search string.

Note: Remember to set a name for the search field, otherwise nothing will be submitted. The most common name for search inputs is q.

Tip: Always add the <label> tag for best accessibility practices!


Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Syntax

<input type="search">

index.html
Example: HTML
<label for="gsearch">Search Google:</label>
<input type="search" id="gsearch" name="gsearch"> 

Output should be:

How to add HTML <input type=">

How to add HTML <input type="submit">

Define a submit button.

Definition and Usage

The <input type="submit"> defines a submit button which submits all form values to a form-handler.

The form-handler is typically a server page with a script for processing the input data.

The form-handler is specified in the form's action attribute.


Browser Support

Syntax

<input type="submit">

index.html
Example: HTML
<input type="submit"> 

Output should be:

How to add HTML <input type=">

How to add HTML <input type="tel">

Define a field for entering a telephone number.

Definition and Usage

The <input type="tel"> defines a field for entering a telephone number.

Note: Browsers that do not support "tel" fall back to being a standard "text" input.

Tip: Always add the <label> tag for best accessibility practices!


Browser Support

Syntax

<input type="tel">

index.html
Example: HTML
<label for="phone">Enter your phone number:</label>
<input type="tel" id="phone" name="phone" pattern="[0-9]{3}-[0-9]{2}-[0-9]{3}"> 

Output should be:

How to add HTML <input type=">

How to add HTML <input type="text">

Define a single-line text field that a user can enter text into.

Definition and Usage

The <input type="text"> defines a single-line text field.

The default width of the text field is 20 characters.

Tip: Always add the <label> tag for best accessibility practices!


Browser Support

Syntax

<input type="text">

index.html
Example: HTML
<label for="fname">First name:</label>
<input type="text" id="fname" name="fname"> 

Output should be:

How to add HTML <input type=">

How to add HTML <input type="time">

Define a control for entering a time (no time zone).

Definition and Usage

The <input type="time"> defines a control for entering a time (no time zone).

Tip: Always add the <label> tag for best accessibility practices!


Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Syntax

<input type="time">

index.html
Example: HTML
<label for="appt">Select a time:</label>
<input type="time" id="appt" name="appt"> 

Output should be:

How to add HTML <input type=">

How to add HTML <input type="url">

Define a field for entering a URL.

Definition and Usage

The <input type="url"> defines a field for entering a URL.

The input value is automatically validated before the form can be submitted.

Tip: Always add the <label> tag for best accessibility practices!


Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Syntax

<input type="url">

index.html
Example: HTML
<label for="homepage">Add your homepage:</label>
<input type="url" id="homepage" name="homepage"> 

Output should be:

How to add HTML <input type=">

How to add HTML <input type="week">

Define a week and year control (no time zone).

Definition and Usage

The <input type="week"> defines a week and year control (no time zone).

Tip: Always add the <label> tag for best accessibility practices!


Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Syntax

<input type="week">

index.html
Example: HTML
<label for="week">Select a week:</label>
<input type="week" id="week" name="week"> 

Output should be:

How to add HTML <input type=">

How to add HTML <input> value Attribute

An HTML form with initial (default) values.

Definition and Usage

The value attribute specifies the value of an <input> element.

The value attribute is used differently for different input types:

  • For "button", "reset", and "submit" - it defines the text on the button
  • For "text", "password", and "hidden" - it defines the initial (default) value of the input field
  • For "checkbox", "radio", "image" - it defines the value associated with the input (this is also the value that is sent on submit)

Note: The value attribute cannot be used with <input type="file">.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<input value="text">

Attribute Values

Value Description
text Specifies the value of the <input> element
index.html
Example: HTML
<form action="/action_page.php">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname" value="John"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname" value="Doe"><br><br>
  <input type="submit" value="Submit">
</form> 

Output should be:

How to add HTML <input> value Attribute

How to add HTML <input> width Attribute

Define an image as the submit button, with height and width attributes.

Definition and Usage

The width attribute specifies the width of the <input> element.

Note: The width attribute is used only with <input type="image">.

Tip: Always specify both the height and width attributes for images. If height and width are set, the space required for the image is reserved when the page is loaded. However, without these attributes, the browser does not know the size of the image, and cannot reserve the appropriate space to it. The effect will be that the page layout will change during loading (while the images load).


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The input height and width attributes</h1>

<form action="/action_page.php">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="image" src="https://horje.com/uploads/demo/2024-03-26-04-36-33-img_submit.gif" alt="Submit" width="48" height="48">
</form>

<p><b>Note:</b> The input type="image" sends the X and Y coordinates of the click that activated the image button.</p>

</body>
</html>

Output should be:

How to add HTML <input> width Attribute

# Tips-61) What is HTML <ins> Tag

A text with a deleted part, and a new, inserted part.

Definition and Usage

The <ins> tag defines a text that has been inserted into a document. Browsers will usually underline inserted text.

Tip: Also look at the <del> tag to markup deleted text.


Browser Support

Attributes

Attribute Value Description
cite URL Specifies a URL to a document that explains the reason why the text was inserted/changed
datetime YYYY-MM-DDThh:mm:ssTZD Specifies the date and time when the text was inserted/changed

Create a HTML ins Tag

Follow the Example.
index.html
Example: HTML
<p>My favorite color is <del>blue</del> <ins>red</ins>!</p>

Output should be:

How to Use CSS to style <del> and <ins>

See the Example.

index.html
Example: HTML
 <html>
<head>
<style>
del {background-color: tomato;}
ins {background-color: yellow;}
</style>
</head>
<body>

<p>My favorite color is <del>blue</del> <ins>red</ins>!</p>

</body>
</html> 

Output should be:

How to Use CSS to style <del> and <ins>

How to set Default CSS Settings for HTML <ins> Tag

Most browsers will display the <ins> element with the following default values.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
ins { 
  text-decoration: underline;
}
</style>
</head>
<body>

<p>An ins element is displayed like this:</p>

<p><ins>Some inserted text.</ins></p>

<p>Change the default CSS settings to see the effect.</p>

</body>
</html>

Output should be:

How to set Default CSS Settings for HTML <ins> Tag

How to add HTML <ins> cite Attribute

An inserted text, with a URL to a document that explains why the text was inserted.

Definition and Usage

The cite attribute specifies a URL to a document that explains the reason why the text was inserted/changed.


Browser Support

Note: The cite attribute has no visual effect in ordinary web browsers, but can be used by screen readers.


Syntax

<ins cite="URL">

Attribute Values

Value Description
URL Specifies the address to the document that explains why the text was inserted/changed.

Possible values:

  • An absolute URL - Points to another web site (like cite="http://www.example.com")
  • A relative URL - Points to a page within a web site (like cite="example.html")
index.html
Example: HTML
<p>This is a text.
<ins cite="why_inserted.htm">This is an inserted text.</ins></p> 

Output should be:

How to add HTML <ins> cite Attribute

How to add HTML <ins> datetime Attribute

An inserted text, with a date and time of when the text was inserted.

Definition and Usage

The datetime attribute specifies the date and time of when the text was inserted/changed.


Browser Support

Note: The datetime attribute has no visual effect in ordinary web browsers, but can be used by screen readers.


Syntax

<ins datetime="YYYY-MM-DDThh:mm:ssTZD">

Attribute Values

Value Description
YYYY-MM-DDThh:mm:ssTZD Specifies the date and time of when the text was inserted/changed.

Explanation of components:

  • YYYY - year (e.g. 2009)
  • MM - month (e.g. 01 for January)
  • DD - day of the month (e.g. 08)
  • T or a space - a separator (required if time is also specified)
  • hh - hour (e.g. 22 for 10.00pm)
  • mm - minutes (e.g. 55)
  • ss - seconds (e.g. 03)
  • TZD - Time Zone Designator (Z denotes Zulu, also known as Greenwich Mean Time)
index.html
Example: HTML
<p>This is a text.
<ins datetime="2015-09-15T22:55:03Z">This is an inserted text.</ins></p>

Output should be:

How to add HTML <ins> datetime Attribute

# Tips-62) What is HTML <kbd> Tag

Define some text as keyboard input in a document.

Definition and Usage

The <kbd> tag is used to define keyboard input. The content inside is displayed in the browser's default monospace font.

Tip: This tag is not deprecated. However, it is possible to achieve richer effect by using CSS (see example below).

Also look at:

Tag Description
<code> Defines a piece of computer code
<samp> Defines sample output from a computer program
<var> Defines a variable
<pre> Defines preformatted text

Browser Support

 

Create a HTML <kbd> Tag

Define some text as keyboard input in a document.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The kbd element</h1>

<p>Press <kbd>Ctrl</kbd> + <kbd>C</kbd> to copy text (Windows).</p>

<p>Press <kbd>Cmd</kbd> + <kbd>C</kbd> to copy text (Mac OS).</p>

</body>
</html>

Output should be:

How to Use CSS to style the <kbd> element

Define some text as computer code in a document.

Definition and Usage

The <code> tag is used to define a piece of computer code. The content inside is displayed in the browser's default monospace font.

Tip: This tag is not deprecated. However, it is possible to achieve richer effect by using CSS (see example below).

Browser Support

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
kbd {
  border-radius: 2px;
  padding: 2px;
  border: 1px solid black;
}
</style>
</head>
<body>

<h1>The kbd element + CSS</h1>

<p>Press <kbd>Ctrl</kbd> + <kbd>C</kbd> to copy text (Windows).</p>

<p>Press <kbd>Cmd</kbd> + <kbd>C</kbd> to copy text (Mac OS).</p>

</body>
</html>

Output should be:

How to Use CSS to style the <kbd> element

How to set Default CSS Settings for HTML <kbd> Tag

Most browsers will display the <kbd> element with the following default values.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
kbd { 
  font-family: monospace;
}
</style>
</head>
<body>

<p>A kbd element is displayed like this:</p>

<kbd>Keyboard input</kbd>

<p>Change the default CSS settings to see the effect.</p>

</body>
</html>

Output should be:

How to set Default CSS Settings for HTML <kbd> Tag

# Tips-63) What is HTML <label> Tag

The <label> tag defines a label for several elements:

  • <input type="checkbox">
  • <input type="color">
  • <input type="date">
  • <input type="datetime-local">
  • <input type="email">
  • <input type="file">
  • <input type="month">
  • <input type="number">
  • <input type="password">
  • <input type="radio">
  • <input type="range">
  • <input type="search">
  • <input type="tel">
  • <input type="text">
  • <input type="time">
  • <input type="url">
  • <input type="week">
  • <meter>
  • <progress>
  • <select>
  • <textarea>

Proper use of labels with the elements above will benefit:

  • Screen reader users (will read out loud the label, when the user is focused on the element)
  • Users who have difficulty clicking on very small regions (such as checkboxes) - because when a user clicks the text within the <label> element, it toggles the input (this increases the hit area). 

Tips and Notes

Tip: The for attribute of <label> must be equal to the id attribute of the related element to bind them together. A label can also be bound to an element by placing the element inside the <label> element. 


Browser Support

Create a HTML <label> Tag

Three radio buttons with labels.
index.html
Example: HTML
<form action="/action_page.php">
  <input type="radio" id="html" name="fav_language" value="HTML">
  <label for="html">HTML</label><br>
  <input type="radio" id="css" name="fav_language" value="CSS">
  <label for="css">CSS</label><br>
  <input type="radio" id="javascript" name="fav_language" value="JavaScript">
  <label for="javascript">JavaScript</label><br><br>
  <input type="submit" value="Submit">
</form>

Output should be:

How to add HTML <label> for Attribute

Three radio buttons with labels:

Definition and Usage

The for attribute specifies which form element a label is bound to.


Browser Support

Syntax

<label for="element_id">

Attribute Values

Value Description
element_id The id of the element the label is bound to

 

index.html
Example: HTML
 <form action="/action_page.php">
  <input type="radio" id="html" name="fav_language" value="HTML">
  <label for="html">HTML</label><br>
  <input type="radio" id="css" name="fav_language" value="CSS">
  <label for="css">CSS</label><br>
  <input type="radio" id="javascript" name="fav_language" value="JavaScript">
  <label for="javascript">JavaScript</label><br><br>
  <input type="submit" value="Submit">
</form> 

Output should be:

How to add HTML <label> for Attribute

How to add HTML <label> form Attribute

A <label> element located outside a form (but still a part of the form):

Definition and Usage

The form attribute specifies the form the label belongs to.

The value of this attribute must be equal to the id attribute of a <form> element in the same document. 


Browser Support

Syntax

<label form="form_id">

Attribute Values

Value Description
form_id Specifies the form element the <label> element belongs to. The value of this attribute must be the id attribute of a <form> element in the same document.
index.html
Example: HTML
 <form action="/action_page.php" id="form1">
  <input type="radio" id="html" name="fav_language" value="HTML"><br>
  <input type="radio" id="css" name="fav_language" value="CSS">
  <label for="css">CSS</label><br>
  <input type="radio" id="javascript" name="fav_language" value="JavaScript">
  <label for="javascript">JavaScript</label><br><br>
  <input type="submit" value="Submit">
</form>

<label form="form1" for="html">HTML</label> 

Output should be:

How to add HTML <label> form Attribute

How to add HTML <input type="checkbox"> label Tag

Let the user select one or more options of a limited number of choices:

Definition and Usage

The <input type="checkbox"> defines a checkbox.

The checkbox is shown as a square box that is ticked (checked) when activated.

Checkboxes are used to let a user select one or more options of a limited number of choices.

Tip: Always add the <label> tag for best accessibility practices!


Browser Support

Syntax

<input type="checkbox">

index.html
Example: HTML
 <input type="checkbox" id="vehicle1" name="vehicle1" value="Bike">
<label for="vehicle1"> I have a bike</label><br>
<input type="checkbox" id="vehicle2" name="vehicle2" value="Car">
<label for="vehicle2"> I have a car</label><br>
<input type="checkbox" id="vehicle3" name="vehicle3" value="Boat">
<label for="vehicle3"> I have a boat</label><br> 

Output should be:

How to add HTML <input type= label Tag">

How to add HTML <input type="color"> label Tag

Show a color picker (with a predefined red value):

Definition and Usage

The <input type="color"> defines a color picker.

The default value is #000000 (black). The value must be in seven-character hexadecimal notation.

Tip: Always add the <label> tag for best accessibility practices!


Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Syntax

<input type="color">

index.html
Example: HTML
 <label for="favcolor">Select your favorite color:</label>
<input type="color" id="favcolor" name="favcolor" value="#ff0000"> 

Output should be:

How to add HTML <input type= label Tag">

How to add HTML <input type="date"> label Tag

Show a date control:

Definition and Usage

The <input type="date"> defines a date picker.

The resulting value includes the year, month, and day.

Tip: Always add the <label> tag for best accessibility practices!


Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Syntax

<input type="date">

index.html
Example: HTML
<label for="birthday">Birthday:</label>
<input type="date" id="birthday" name="birthday"> 

Output should be:

How to add HTML <input type= label Tag">

How to add HTML <input type="datetime-local"> label Tag

Show a date and time control (no timezone) :

Definition and Usage

The <input type="datetime-local"> defines a date picker.

The resulting value includes the year, month, day, and time.

Tip: Always add the <label> tag for best accessibility practices! 


Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Syntax

<input type="datetime-local">

index.html
Example: HTML
<label for="birthdaytime">Birthday (date and time):</label>
<input type="datetime-local" id="birthdaytime" name="birthdaytime">

Output should be:

How to add HTML <input type= label Tag">

How to add HTML <input type="email"> label Tag

Define a field for an e-mail address (validates automatically when submitted):

Definition and Usage

The <input type="email"> defines a field for an e-mail address.

The input value is automatically validated to ensure it is a properly formatted e-mail address.

To define an e-mail field that allows multiple e-mail addresses, add the "multiple" attribute.

Tip: Always add the <label> tag for best accessibility practices!


Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Syntax

<input type="email">

index.html
Example: HTML
<label for="email">Enter your email:</label>
<input type="email" id="email" name="email"> 

Output should be:

How to add HTML <input type= label Tag">

How to add HTML <input type="file"> label Tag

Define a file-select field:

Definition and Usage

The <input type="file"> defines a file-select field and a "Browse" button for file uploads.

To define a file-select field that allows multiple files to be selected, add the multiple attribute.

Tip: Always add the <label> tag for best accessibility practices!


Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Syntax

<input type="file">

index.html
Example: HTML
<label for="myfile">Select a file:</label>
<input type="file" id="myfile" name="myfile"> 

Output should be:

How to add HTML <input type= label Tag">

How to add HTML <input type="month"> label Tag

Define a month and year control (no time zone):

Definition and Usage

The <input type="month"> defines a month and year control.

The format is "YYYY-MM".

Tip: Always add the <label> tag for best accessibility practices!


Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Syntax

<input type="month">

index.html
Example: HTML
<label for="bdaymonth">Birthday (month and year):</label>
<input type="month" id="bdaymonth" name="bdaymonth"> 

Output should be:

How to add HTML <input type= label Tag">

How to add HTML <input type="number"> label Tag

Define a field for entering a number (You can also set restrictions on what numbers are accepted):

Definition and Usage

The <input type="number"> defines a field for entering a number.

Use the following attributes to specify restrictions:

  • max - specifies the maximum value allowed
  • min - specifies the minimum value allowed
  • step - specifies the legal number intervals
  • value - Specifies the default value

Tip: Always add the <label> tag for best accessibility practices!


Browser Support

Syntax

<input type="number">

index.html
Example: HTML
<label for="quantity">Quantity (between 1 and 5):</label>
<input type="number" id="quantity" name="quantity" min="1" max="5"> 

Output should be:

How to add HTML <input type= label Tag">

How to add HTML <input> max Attribute label Tag

Use of the min and max attributes.

Definition and Usage

The max attribute specifies the maximum value for an <input> element.

Tip: Use the max attribute together with the min attribute to create a range of legal values.

Note: The max and min attributes works with the following input types: number, range, date, datetime-local, month, time and week.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<input max="number|date">

Attribute Values

Value Description
number Specifies the maximum value allowed
date Specifies the maximum date allowed
index.html
Example: HTML
<form action="/action_page.php">

  <label for="datemax">Enter a date before 1980-01-01:</label>
  <input type="date" id="datemax" name="datemax" max="1979-12-31"><br><br>

  <label for="datemin">Enter a date after 2000-01-01:</label>
  <input type="date" id="datemin" name="datemin" min="2000-01-02"><br><br>

  <label for="quantity">Quantity (between 1 and 5):</label>
  <input type="number" id="quantity" name="quantity" min="1" max="5"><br><br>

  <input type="submit">

</form>

Output should be:

How to add HTML <input> max Attribute label Tag

How to add HTML <input> max Number Attribute label Tag

number Specifies the maximum value allowed
index.html
Example: HTML
<label for="quantity">Quantity (between 1 and 5):</label>
 <input type="number" id="quantity" name="quantity" min="1" max="5">

Output should be:

How to add HTML <input> max Number Attribute label Tag

How to add HTML <input> max Date Attribute label Tag

Use of the min and max attributes.

index.html
Example: HTML
<label for="datemax">Enter a date before 1980-01-01:</label>
<input type="date" id="datemax" name="datemax" max="1979-12-31"><br><br>

<label for="datemin">Enter a date after 2000-01-01:</label>
<input type="date" id="datemin" name="datemin" min="2000-01-02"><br><br>

Output should be:

How to add HTML <input> max Date Attribute label Tag

How to add HTML <input> min Attribute on label Tag

Use of the min and max attributes.

Definition and Usage

The min attribute specifies the minimum value for an <input> element.

Tip: Use the min attribute together with the max attribute to create a range of legal values.

Note: The max and min attributes works with the following input types: number, range, date, datetime-local, month, time and week.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<input min="number|date">

Attribute Values

Value Description
number Specifies the minimum value allowed
date Specifies the minimum date allowed
index.html
Example: HTML
<label for="quantity">Quantity (between 1 and 5):</label>
<input type="number" id="quantity" name="quantity" min="1" max="5">

Output should be:

How to add HTML <input> min Attribute on label Tag

How to add HTML <input> min number Attribute on label Tag

number Specifies the minimum value allowed
index.html
Example: HTML
<label for="quantity">Quantity (between 1 and 5):</label>
<input type="number" id="quantity" name="quantity" min="1" max="5">

Output should be:

How to add HTML <input> min number Attribute on label Tag

How to add HTML <input> min date Attribute on label Tag

date Specifies the minimum date allowed
index.html
Example: HTML
  <label for="datemax">Enter a date before 1980-01-01:</label>
  <input type="date" id="datemax" name="datemax" max="1979-12-31"><br><br>

  <label for="datemin">Enter a date after 2000-01-01:</label>
  <input type="date" id="datemin" name="datemin" min="2000-01-02"><br><br>

Output should be:

How to add HTML <input> min date Attribute on label Tag

How to add HTML <input> step Attribute label Tag

An HTML form with an input field with a specified legal number intervals.

Definition and Usage

The step attribute specifies the interval between legal numbers in an <input> element.

Example: if step="3", legal numbers could be -3, 0, 3, 6, etc.

Tip: The step attribute can be used together with the max and min attributes to create a range of legal values.

Note: The step attribute works with the following input types: number, range, date, datetime-local, month, time and week.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<input step="number">

Attribute Values

Value Description
number Specifies the interval between legal numbers in the input field. Default is 1
any  
index.html
Example: HTML
<form action="/action_page.php">
  <label for="points">Points:</label>
  <input type="number" id="points" name="points" step="3">
  <input type="submit">
</form>

Output should be:

How to add HTML <input> step Attribute label Tag

How to add HTML <input> value Attribute label Tag

An HTML form with initial (default) values.

Definition and Usage

The value attribute specifies the value of an <input> element.

The value attribute is used differently for different input types:

  • For "button", "reset", and "submit" - it defines the text on the button
  • For "text", "password", and "hidden" - it defines the initial (default) value of the input field
  • For "checkbox", "radio", "image" - it defines the value associated with the input (this is also the value that is sent on submit)

Note: The value attribute cannot be used with <input type="file">.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<input value="text">

Attribute Values

Value Description
text Specifies the value of the <input> element
index.html
Example: HTML
<form action="/action_page.php">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname" value="John"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname" value="Doe"><br><br>
  <input type="submit" value="Submit">
</form>

Output should be:

How to add HTML <input> value Attribute label Tag

How to add HTML <input type="password"> on label Tag

Define a password field (characters are masked).

Definition and Usage

The <input type="password"> defines a password field (characters are masked).

Note: Any forms involving sensitive information like passwords should be served over HTTPS.

Tip: Always add the <label> tag for best accessibility practices!


Browser Support

Syntax

<input type="password">


index.html
Example: HTML
<form action="/action_page.php">
  <label for="email">Email:</label>
  <input type="email" id="email" name="email"><br><br>
  <label for="pwd">Password:</label>
  <input type="password" id="pwd" name="pwd" minlength="8"><br><br>
  <input type="submit">
</form>

Output should be:

How to add HTML <input type= on label Tag">

How to add HTML <input type="radio"> on label Tag

Radio buttons let a user select only one of a limited number of choices.

Definition and Usage

The <input type="radio"> defines a radio button.

Radio buttons are normally presented in radio groups (a collection of radio buttons describing a set of related options). Only one radio button in a group can be selected at the same time.

Note: The radio group must share the same name (the value of the name attribute) to be treated as a group. Once the radio group is created, selecting any radio button in that group automatically deselects any other selected radio button in the same group. You can have as many radio groups on a page as you want, as long as each group has its own name.

Note: The value attribute defines the unique value associated with each radio button. The value is not shown to the user, but is the value that is sent to the server on "submit" to identify which radio button that was selected.

Browser Support

Syntax

<input type="radio">

index.html
Example: HTML
<form action="/action_page.php">
  <p>Please select your favorite Web language:</p>
  <input type="radio" id="html" name="fav_language" value="HTML">
  <label for="html">HTML</label><br>
  <input type="radio" id="css" name="fav_language" value="CSS">
  <label for="css">CSS</label><br>
  <input type="radio" id="javascript" name="fav_language" value="JavaScript">
  <label for="javascript">JavaScript</label>

  <br>  

  <p>Please select your age:</p>
  <input type="radio" id="age1" name="age" value="30">
  <label for="age1">0 - 30</label><br>
  <input type="radio" id="age2" name="age" value="60">
  <label for="age2">31 - 60</label><br>  
  <input type="radio" id="age3" name="age" value="100">
  <label for="age3">61 - 100</label><br><br>
  <input type="submit" value="Submit">
</form>

Output should be:

How to add HTML <input type= on label Tag">

How to add HTML <input type="range"> on label Tag

Define a range control (like a slider control).

Definition and Usage

The <input type="range"> defines a control for entering a number whose exact value is not important (like a slider control).

Default range is 0 to 100. However, you can set restrictions on what numbers are accepted with the attributes below.

  • max - specifies the maximum value allowed
  • min - specifies the minimum value allowed
  • step - specifies the legal number intervals
  • value - Specifies the default value

Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Syntax

<input type="range">

index.html
Example: HTML
<form action="/action_page.php">
  <label for="vol">Volume (between 0 and 50):</label>
  <input type="range" id="vol" name="vol" min="0" max="50">
  <input type="submit">
</form>

Output should be:

How to add HTML <input type= on label Tag">

How to add HTML <input type="range"> Max Attribute on label Tag

Use of the min and max attributes.

index.html
Example: HTML
<form action="/action_page.php">
  <label for="vol">Volume (between 0 and 50):</label>
  <input type="range" id="vol" name="vol" min="0" max="50">
  <input type="submit">
</form>

Output should be:

How to add HTML <input type= Max Attribute on label Tag">

How to add HTML <input type="range"> Min Attribute on label Tag

Use of the min and max attributes.

index.html
Example: HTML
<form action="/action_page.php">
  <label for="vol">Volume (between 0 and 50):</label>
  <input type="range" id="vol" name="vol" min="0" max="50">
  <input type="submit">
</form>

Output should be:

How to add HTML <input type= Min Attribute on label Tag">

How to add HTML <input type="search"> on label Tag

Define a search field (like a site search, or Google search).

Definition and Usage

The <input type="search"> defines a text field for entering a search string.

Note: Remember to set a name for the search field, otherwise nothing will be submitted. The most common name for search inputs is q.

Tip: Always add the <label> tag for best accessibility practices!


Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Syntax

<input type="search">

index.html
Example: HTML
<label for="gsearch">Search Google:</label>
<input type="search" id="gsearch" name="gsearch"> 

Output should be:

How to add HTML <input type= on label Tag">

How to add HTML <input type="tel"> on label Tag

Define a field for entering a telephone number.

Definition and Usage

The <input type="tel"> defines a field for entering a telephone number.

Note: Browsers that do not support "tel" fall back to being a standard "text" input.

Tip: Always add the <label> tag for best accessibility practices!


Browser Support

Syntax

<input type="tel">

index.html
Example: HTML
<label for="phone">Enter your phone number:</label>
<input type="tel" id="phone" name="phone" pattern="[0-9]{3}-[0-9]{2}-[0-9]{3}"> 

Output should be:

How to add HTML <input type= on label Tag">

How to add HTML <input type="text"> on label Tag

Define a single-line text field that a user can enter text into.

Definition and Usage

The <input type="text"> defines a single-line text field.

The default width of the text field is 20 characters.

Browser Support

Syntax

<input type="text">

index.html
Example: HTML
<label for="fname">First name:</label>
<input type="text" id="fname" name="fname"> 

Output should be:

How to add HTML <input type= on label Tag">

How to add HTML <input type="time"> on label Tag

Definition and Usage

The <input type="time"> defines a control for entering a time (no time zone).

Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Syntax

<input type="time">

index.html
Example: HTML
<label for="appt">Select a time:</label>
<input type="time" id="appt" name="appt"> 

Output should be:

How to add HTML <input type= on label Tag">

How to add HTML <input type="url"> on label Tag

Define a field for entering a URL.

Definition and Usage

The <input type="url"> defines a field for entering a URL.

The input value is automatically validated before the form can be submitted.


Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Syntax

<input type="url">

index.html
Example: HTML
<label for="homepage">Add your homepage:</label>
<input type="url" id="homepage" name="homepage"> 

Output should be:

How to add HTML <input type= on label Tag">

How to add HTML <input type="week"> on label Tag

Define a week and year control (no time zone).

Definition and Usage

The <input type="week"> defines a week and year control (no time zone).

Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Syntax

<input type="week">

index.html
Example: HTML
<label for="week">Select a week:</label>
<input type="week" id="week" name="week"> 

Output should be:

How to add HTML <input type= on label Tag">

How to add HTML <meter> with label Tag

Use the meter element to display a scalar value within a given range (a gauge).

Definition and Usage

The <meter> tag defines a scalar measurement within a known range, or a fractional value. This is also known as a gauge.

Examples: Disk usage, the relevance of a query result, etc.

Note: The <meter> tag should not be used to indicate progress (as in a progress bar). For progress bars, use the <progress> tag.

Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Attributes

Attribute Value Description
form form_id Specifies which form the <meter> element belongs to
high number Specifies the range that is considered to be a high value
low number Specifies the range that is considered to be a low value
max number Specifies the maximum value of the range
min number Specifies the minimum value of the range. Default value is 0
optimum number Specifies what value is the optimal value for the gauge
value number Required. Specifies the current value of the gauge
index.html
Example: HTML
<label for="disk_c">Disk usage C:</label>
<meter id="disk_c" value="2" min="0" max="10">2 out of 10</meter><br>

<label for="disk_d">Disk usage D:</label>
<meter id="disk_d" value="0.6">60%</meter> 

Output should be:

How to add HTML <meter> with label Tag

How to add HTML <meter> form Attribute with label Tag

A <meter> element located outside a form (but still a part of the form).

Definition and Usage

The form attribute specifies the form the <meter> tag belongs to.

The value of this attribute must be equal to the id attribute of a <meter> element in the same document. 


Browser Support

Syntax

<meter form="form_id">

Attribute Values

Value Description
form_id Specifies the form element the <meter> element belongs to. The value of this attribute must be the id attribute of a <form> element in the same document.
index.html
Example: HTML
<form action="/action_page.php" method="get" id="form1">
  First name: <input type="text" name="fname"><br>
  <input type="submit" value="Submit">
</form>

<p><label for="anna">Anna's score:</label>
<meter id="anna" form="form1" name="anna" min="0" low="40" high="90" max="100" value="95"></meter></p> 

Output should be:

How to add HTML <meter> form Attribute with label Tag

How to add HTML <meter> high Attribute with label Tag

A gauge with a current value and min, max, high, and low segments.

Definition and Usage

The high attribute specifies the range where the gauge's value is considered to be a high value.

The high attribute value must be less than the max attribute value, and it also must be greater than the low and min attribute values.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<meter high="number">

Attribute Values

Value Description
number Specifies a floating point number that is considered to be a high value
index.html
Example: HTML
<p><label for="anna">Anna's score:</label>
<meter id="anna" min="0" low="40" high="90" max="100" value="95"></meter></p>

<p><label for="peter">Peter's score:</label>
<meter id="peter" min="0" low="40" high="90" max="100" value="65"></meter></p>

<p><label for="linda">Linda's score:</label>
<meter id="linda" min="0" low="40" high="90" max="100" value="35"></meter></p> 

Output should be:

How to add HTML <meter> high Attribute with label Tag

How to add HTML <meter> low Attribute with label Tag

A gauge with a current value and min, max, high, and low segments.

Definition and Usage

The low attribute specifies the range where the gauge's value is considered to be a low value.

The low attribute value must be greater than the min attribute value, and it also must be less than the high and max attribute values.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<meter low="number">

Attribute Values

Value Description
number Specifies a floating point number that is considered to be a low value
index.html
Example: HTML
<p><label for="anna">Anna's score:</label>
<meter id="anna" min="0" low="40" high="90" max="100" value="95"></meter></p>

<p><label for="peter">Peter's score:</label>
<meter id="peter" min="0" low="40" high="90" max="100" value="65"></meter></p>

<p><label for="linda">Linda's score:</label>
<meter id="linda" min="0" low="40" high="90" max="100" value="35"></meter></p>

Output should be:

How to add HTML <meter> low Attribute with label Tag

How to add HTML <meter> max Attribute with label Tag

A gauge with a current value and min, max, high, and low segments.

Definition and Usage

The max attribute specifies the upper bound of the gauge.

The max attribute value must be greater than the min attribute value.

If unspecified, the default value is 1.

Tip: The max attribute, together with the min attribute, specifies the full range of the gauge.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<meter max="number">

Attribute Values

Value Description
number Specifies a floating point number that is the maximum value of the gauge. Default value is "1"
index.html
Example: HTML
<p><label for="anna">Anna's score:</label>
<meter id="anna" min="0" low="40" high="90" max="100" value="95"></meter></p>

<p><label for="peter">Peter's score:</label>
<meter id="peter" min="0" low="40" high="90" max="100" value="65"></meter></p>

<p><label for="linda">Linda's score:</label>
<meter id="linda" min="0" low="40" high="90" max="100" value="35"></meter></p> 

Output should be:

How to add HTML <meter> max Attribute with label Tag

How to add HTML <meter> min Attribute with label Tag

A gauge with a current value and min, max, high, and low segments.

Definition and Usage

The min attribute specifies the lower bound of the gauge.

The min attribute value must be less than the max attribute value.

If unspecified, the default value is 0.

Tip: The min attribute, together with the max attribute, specifies the full range of the gauge.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<meter min="number">

Attribute Values

Value Description
number Specifies a floating point number that is the minimum value of the gauge. Default value is 0
index.html
Example: HTML
<p><label for="anna">Anna's score:</label>
<meter id="anna" min="0" low="40" high="90" max="100" value="95"></meter></p>

<p><label for="peter">Peter's score:</label>
<meter id="peter" min="0" low="40" high="90" max="100" value="65"></meter></p>

<p><label for="linda">Linda's score:</label>
<meter id="linda" min="0" low="40" high="90" max="100" value="35"></meter></p> 

Output should be:

How to add HTML <meter> min Attribute with label Tag

How to add HTML <meter> optimum Attribute with label Tag

A gauge with an optimal value of 0.5.

Definition and Usage

The optimum attribute specifies the range where the gauge's value is considered to be an optimal value.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<meter optimum="number">

Attribute Values

Value Description
number Specifies a floating point number that is the optimal value of the gauge
index.html
Example: HTML
<p><label for="yinyang">Yin Yang:</label>
<meter id="yinyang" value="0.3" high="0.9" low="0.1" optimum="0.5"></meter></p> 

Output should be:

How to add HTML <meter> optimum Attribute with label Tag

How to add HTML <meter> value Attribute with label Tag

A gauge with a current value and min, max, high, and low segments.

Definition and Usage

The required value attribute specifies the current, or "measured", value of the gauge.

The value attribute must be between the min and max attribute values.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<meter value="number">

Attribute Values

Value Description
number Required. Specifies a floating point number that is the current value of the gauge
index.html
Example: HTML
<p><label for="anna">Anna's score:</label>
<meter id="anna" min="0" low="40" high="90" max="100" value="95"></meter></p>

<p><label for="peter">Peter's score:</label>
<meter id="peter" min="0" low="40" high="90" max="100" value="65"></meter></p>

<p><label for="linda">Linda's score:</label>
<meter id="linda" min="0" low="40" high="90" max="100" value="35"></meter></p> 

Output should be:

How to add HTML <meter> value Attribute with label Tag

How to add HTML <progress> Tag with label Tag

Show a progress bar.

Definition and Usage

The <progress> tag represents the completion progress of a task.

Tip: Always add the <label> tag for best accessibility practices!


Tips and Notes

Tip: Use the <progress> tag in conjunction with JavaScript to display the progress of a task.

Note: The <progress> tag is not suitable for representing a gauge (e.g. disk space usage or relevance of a query result). To represent a gauge, use the <meter> tag instead.


Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Attributes

Attribute Value Description
max number Specifies how much work the task requires in total. Default value is 1
value number Specifies how much of the task has been completed
index.html
Example: HTML
<label for="file">Downloading progress:</label>
<progress id="file" value="32" max="100"> 32% </progress>

Output should be:

How to add HTML <progress> Tag with label Tag

How to add HTML <progress> max Attribute with label Tag

Show a progress bar.

Definition and Usage

The max attribute specifies how much work the task requires in total.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<progress max="number">

Attribute Values

Value Description
number A floating point number that specifies how much work the task requires in total before it can be considered complete. Default value is 1.
index.html
Example: HTML
<label for="file">Downloading progress:</label>
<progress id="file" value="32" max="100"> 32% </progress> 

Output should be:

How to add HTML <progress> max Attribute with label Tag

How to add HTML <progress> value Attribute with label Tag

Definition and Usage

The value attribute specifies how much of the task has been completed.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<progress value="number">

Attribute Values

Value Description
number A floating point number that specifies how much of the task has been completed
index.html
Example: HTML
<label for="file">Downloading progress:</label>
<progress id="file" value="32" max="100"> 32% </progress> 

Output should be:

How to add HTML <progress> value Attribute with label Tag

How to add HTML <select> Attribute with label Tag

Create a drop-down list with four options.

Definition and Usage

The <select> element is used to create a drop-down list.

The <select> element is most often used in a form, to collect user input.

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 drop-down list will be submitted).

The id attribute is needed to associate the drop-down list with a label.

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!

Browser Support

index.html
Example: HTML
 <label for="cars">Choose a car:</label>

<select name="cars" id="cars">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="mercedes">Mercedes</option>
  <option value="audi">Audi</option>
</select> 

Output should be:

How to add HTML <select> Attribute with label Tag

How to add HTML <select> autofocus Attribute with label Tag

A drop-down list with autofocus.

Definition and Usage

The autofocus attribute is a boolean attribute.

When present, it specifies that the drop-down list should automatically get focus when the page loads.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<select autofocus>

index.html
Example: HTML
 <label for="cars">Choose a car:</label>

<select name="cars" id="cars" autofocus>
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="opel">Opel</option>
  <option value="audi">Audi</option>
</select> 

try
How to add HTML <select> autofocus Attribute with label Tag

How to add HTML <select> disabled Attribute with label Tag

A disabled drop-down list.

Definition and Usage

The disabled attribute is a boolean attribute.

When present, it specifies that the drop-down list should be disabled.

A disabled drop-down list is unusable and un-clickable.

The disabled attribute can be set to keep a user from using the drop-down list until some other condition has been met (like selecting a checkbox, etc.). Then, a JavaScript can remove the disabled value, and make the drop-down list usable.


Browser Support

Syntax

<select disabled>

index.html
Example: HTML
 <label for="cars">Choose a car:</label>

<select name="cars" id="cars" disabled>
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="mercedes">Mercedes</option>
  <option value="audi">Audi</option>
</select> 

Output should be:

How to add HTML <select> disabled Attribute with label Tag

How to add HTML <select> form Attribute with label Tag

A drop-down list located outside a form (but still a part of the form).

Definition and Usage

The form attribute specifies the form the drop-down list belongs to.

The value of this attribute must be equal to the id attribute of a <form> element in the same document.


Browser Support

Syntax

<select form="form_id">

Attribute Values

Value Description
form_id Specifies the form element the <select> element belongs to. The value of this attribute must be equal to the id attribute of a <form> element in the same document.
index.html
Example: HTML
<form action="/action_page.php" id="carform">
  <label for="fname">Firstname:</label>
  <input type="text" id="fname" name="fname">
  <input type="submit">
</form>

<label for="cars">Choose a car:</label>
<select name="cars" id="cars" form="carform">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="opel">Opel</option>
  <option value="audi">Audi</option>
</select> 

Output should be:

How to add HTML <select> form Attribute with label Tag

How to add HTML <select> multiple Attribute with label Tag

A drop-down list that allows multiple selections.

Definition and Usage

The multiple attribute is a boolean attribute.

When present, it specifies that multiple options can be selected at once.

Selecting multiple options vary in different operating systems and browsers:

  • For windows: Hold down the control (ctrl) button to select multiple options
  • For Mac: Hold down the command button to select multiple options

Because of the different ways of doing this, and because you have to inform the user that multiple selection is available, it is more user-friendly to use checkboxes instead.


Browser Support

Syntax

<select multiple>

index.html
Example: HTML
<label for="cars">Choose a car:</label>

<select name="cars" id="cars" multiple>
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="opel">Opel</option>
  <option value="audi">Audi</option>
</select> 

Output should be:

How to add HTML <select> multiple Attribute with label Tag

How to add HTML <select> name Attribute with label Tag

A drop-down list with a name attribute.

Definition and Usage

The name attribute specifies the name for a drop-down list.

The name attribute is used to reference elements in a JavaScript, or to reference form data after a form is submitted.


Browser Support

Syntax

<select name="text">

Attribute Values

Value Description
text The name of the drop-down list
index.html
Example: HTML
<label for="cars">Choose a car:</label>

<select name="cars" id="cars">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="opel">Opel</option>
  <option value="audi">Audi</option>
</select> 

Output should be:

How to add HTML <select> name Attribute with label Tag

How to add HTML <select> required Attribute with label Tag

An HTML form with a required drop-down list.

Definition and Usage

The required attribute is a boolean attribute.

When present, it specifies the user is required to select a value before submitting the form.


Browser Support

Syntax

<select required>

index.html
Example: HTML
<label for="cars">Choose a car:</label>

<select name="cars" id="cars" required>
  <option value="">None</option>
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="mercedes">Mercedes</option>
  <option value="audi">Audi</option>
</select> 

Output should be:

How to add HTML <select> required Attribute with label Tag

How to add HTML <select> size Attribute with label Tag

A drop-down list with three visible options.

Definition and Usage

The size attribute specifies the number of visible options in a drop-down list.

If the value of the size attribute is greater than 1, but lower than the total number of options in the list, the browser will add a scroll bar to indicate that there are more options to view.


Browser Support

Note: In Chrome and Safari, this attribute may not work as expected for size="2" and size="3".


Syntax

<select size="number">

Attribute Values

Value Description
number The number of visible options in the drop-down list. Default value is 1. If the multiple attribute is present, the default value is 4
index.html
Example: HTML
<label for="cars">Choose a car:</label>

<select name="cars" id="cars" size="3">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="opel">Opel</option>
  <option value="audi">Audi</option>
</select> 

Output should be:

How to add HTML <select> size Attribute with label Tag

How to Use <select> with <optgroup> label tags

Follow the Example.

index.html
Example: HTML
<label for="cars">Choose a car:</label>
<select name="cars" id="cars">
  <optgroup label="Swedish Cars">
    <option value="volvo">Volvo</option>
    <option value="saab">Saab</option>
  </optgroup>
  <optgroup label="German Cars">
    <option value="mercedes">Mercedes</option>
    <option value="audi">Audi</option>
  </optgroup>
</select> 

Output should be:

How to Use <select> with <optgroup> label tags

How to add HTML <textarea> Attributes with label Tag

A multi-line text input control (text area).

Definition and Usage

The <textarea> tag defines a multi-line text input control.

The <textarea> element is often used in a form, to collect user inputs like comments or reviews.

A text area can hold an unlimited number of characters, and the text renders in a fixed-width font (usually Courier).

The size of a text area is specified by the cols and rows attributes (or with CSS).

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 text area will be submitted).

The id attribute is needed to associate the text area with a label. 

Tip: Always add the <label> tag for best accessibility practices!


Browser Support

Attributes

Attribute Value Description
autofocus autofocus Specifies that a text area should automatically get focus when the page loads
cols number Specifies the visible width of a text area
dirname textareaname.dir Specifies that the text direction of the textarea will be submitted
disabled disabled Specifies that a text area should be disabled
form form_id Specifies which form the text area belongs to
maxlength number Specifies the maximum number of characters allowed in the text area
name text Specifies a name for a text area
placeholder text Specifies a short hint that describes the expected value of a text area
readonly readonly Specifies that a text area should be read-only
required required Specifies that a text area is required/must be filled out
rows number Specifies the visible number of lines in a text area
wrap hard
soft
Specifies how the text in a text area is to be wrapped when submitted in a form
index.html
Example: HTML
<label for="w3review">Review of Horje:</label>

<textarea id="w3review" name="w3review" rows="4" cols="50">
At horje.com you will learn how to make a website. They offer free tutorials in all web development technologies.
</textarea> 

Output should be:

How to add HTML <textarea> Attributes with label Tag

How to add HTML <textarea> autofocus Attribute with label Tag

A text area with autofocus.

Definition and Usage

The autofocus attribute is a boolean attribute.

When present, it specifies that the text area should automatically get focus when the page loads.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<textarea autofocus>

index.html
Example: HTML
<label for="css">Type</label><br>
<textarea autofocus>
At horje.com you will learn how to make a website. We offer free tutorials in all web development technologies.
</textarea> 
try
How to add HTML <textarea> autofocus Attribute with label Tag

How to add HTML <textarea> cols Attribute with label Tag

A text area with a specified height and width.

Definition and Usage

The cols attribute specifies the visible width of a text area.

Tip: The size of a text area can also be set by the CSS height and width properties.


Browser Support

Syntax

<textarea cols="number">

Attribute Values

Value Description
number Specifies the width of the text area (in average character width). Default value is 20
index.html
Example: HTML
<label for="css">Type</label><br>
<textarea rows="4" cols="50">
At horje.com you will learn how to make a website. We offer free tutorials in all web development technologies.
</textarea>

Output should be:

How to add HTML <textarea> cols Attribute with label Tag

How to add HTML <textarea> dirname Attribute with label Tag

An HTML form where the field's text direction will be submitted.

Definition and Usage

The dirname attribute enables the submission of the text direction of the text area.

The dirname attribute's value is always the name of the text area, followed by ".dir".


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<textarea name="myname" dirname="myname.dir"></textarea>

Attribute Values

Value Description
name.dir Specifies that the text direction of the textarea will be submitted.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The textarea dirname attribute</h1>
<form action="/action_page.php">
<label for="css">Type Text:</label><br>
<textarea name="explanation"dirname="explanation.dir"></textarea></br>
<input type="submit" value="Submit">
</form>

<p>When the form is being submitted, the text direction of the textarea will also be submitted.</p>

</body>
</html>

try
How to add HTML <textarea> dirname Attribute with label Tag

How to add HTML <textarea> disabled Attribute with label Tag

A disabled text area.

Definition and Usage

The disabled attribute is a boolean attribute.

When present, it specifies that the text area should be disabled.

A disabled text area is unusable and the text is not selectable (cannot be copied).

The disabled attribute can be set to keep a user from using the text area until some other condition has been met (like selecting a checkbox, etc.). Then, a JavaScript could remove the disabled value, and make the text area usable.


Browser Support

Syntax

<textarea disabled>

index.html
Example: HTML
<label for="css">Type Text:</label><br>
<textarea disabled>
At Horje.com you will learn how to make a website. We offer free tutorials in all web development technologies.
</textarea>

Output should be:

How to add HTML <textarea> disabled Attribute with label Tag

How to add HTML <textarea> form Attribute with label Tag

A text area located outside a form (but still a part of the form).

Definition and Usage

The form attribute specifies the form the text area belongs to.

The value of this attribute must be equal to the id attribute of a <form> element in the same document.


Browser Support

Syntax

<textarea form="form_id">

Attribute Values

Value Description
form_id Specifies the form element the <textarea> element belongs to. The value of this attribute must be the id attribute of a <form> element in the same document.
index.html
Example: HTML
<label for="css">Type Text:</label><br>
<textarea rows="4" cols="50" name="comment" form="usrform">
Enter text here...</textarea>

Output should be:

How to add HTML <textarea> form Attribute with label Tag

How to add HTML <textarea> maxlength Attribute with label Tag

Definition and Usage

The maxlength attribute specifies the maximum length (in characters) of a text area.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<textarea maxlength="number">

Attribute Values

Value Description
number The maximum number of characters allowed in the text area
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The textarea maxlength attribute</h1>
<label for="text">Type</label><br>
<textarea rows="4" cols="50" maxlength="50">
Enter text here...</textarea>

</body>
</html>

Output should be:

How to add HTML <textarea> maxlength Attribute with label Tag

How to add HTML <textarea> name Attribute with label Tag Part 2

A text area with a name attribute:

Definition and Usage

The name attribute specifies a name for a text area.

The name attribute is used to reference elements in a JavaScript, or to reference form data after a form is submitted.


Browser Support

Syntax

<textarea name="text">

Attribute Values

Value Description
text Specifies the name of the text area
index.html
Example: HTML
<form action="/action_page.php">
<label for="text">Type</label><br>
<textarea rows="4" cols="50" name="comment">
Enter text here...</textarea>
<input type="submit">
</form>

Output should be:

How to add HTML <textarea> name Attribute with label Tag Part 2

How to add HTML <textarea> placeholder Attribute with label Tag

A text area with a placeholder text.

Definition and Usage

The placeholder attribute specifies a short hint that describes the expected value of a text area.

The short hint is displayed in the text area before the user enters a value.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<textarea placeholder="text">

Attribute Values

Value Description
text Specifies a short hint that describes the expected value of the text area
index.html
Example: HTML
<label for="text">Who are you?</label><br>
<textarea rows="4" cols="50" placeholder="Describe yourself here..."></textarea>

Output should be:

How to add HTML <textarea> placeholder Attribute with label Tag

How to add HTML <textarea> readonly Attribute with label Tag

A read-only text area.

Definition and Usage

The readonly attribute is a boolean attribute.

When present, it specifies that a text area should be read-only.

In a read-only text area, the content cannot be changed, but a user can tab to it, highlight it and copy content from it.

The readonly attribute can be set to keep a user from using a text area until some other condition has been met (like selecting a checkbox, etc.). Then, a JavaScript is required to remove the readonly value, and make the text area editable.


Browser Support

Syntax

<textarea readonly>

index.html
Example: HTML
<label for="text">Type</label><br>
<textarea rows="4" cols="50" readonly>
At horje.com you will learn how to make a website. We offer free tutorials in all web development technologies.
</textarea>

Output should be:

How to add HTML <textarea> readonly Attribute with label Tag

How to add HTML <textarea> required Attribute with label Tag

A form with a required text area.

Definition and Usage

The required attribute is a boolean attribute.

When present, it specifies that a text area is required/must be filled out (in order to submit the form).


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<textarea required>

index.html
Example: HTML
<form action="/action_page.php">
<label for="text">Type</label><br>
<textarea rows="4" cols="50" name="comment" required>
</textarea>
<input type="submit">
</form>

Output should be:

How to add HTML <textarea> required Attribute with label Tag

How to add HTML <textarea> rows Attribute with label Tag

A text area with a specified height and width.

Definition and Usage

The rows attribute specifies the visible height of a text area, in lines.

Note: The size of a textarea can also be specified by the CSS height and width properties.


Browser Support

Syntax

<textarea rows="number">

Attribute Values

Value Description
number Specifies the height of the text area (in lines). Default value is 2
index.html
Example: HTML
<label for="text">Type</label><br>
<textarea rows="4" cols="50">
At horje.com you will learn how to make a website. We offer free tutorials in all web development technologies.
</textarea>

Output should be:

How to add HTML <textarea> rows Attribute with label Tag

How to add HTML <textarea> wrap Attribute with label Tag

The text in a text area with wrap="hard" will contain newlines (if any) when submitted in a form.

Definition and Usage

The wrap attribute specifies how the text in a text area is to be wrapped when submitted in a form.


Browser Support

Syntax

<textarea wrap="soft|hard">

Attribute Values

Value Description
soft The text in the textarea is not wrapped when submitted in a form. This is default
hard The text in the textarea is wrapped (contains newlines) when submitted in a form. When "hard" is used, the cols attribute must be specified
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The textarea wrap attribute</h1>

<form action="/action_page.php">
<label for="text">Type</label><br>
<textarea rows="2" cols="20" name="usrtxt" wrap="hard">
At Horje you will find free Web-building tutorials.
</textarea>
<input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <textarea> wrap Attribute with label Tag

How to add HTML <textarea> wrap soft Attribute with label Tag

The text in a text area with wrap="soft" will contain newlines (if any) when submitted in a form.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The textarea wrap attribute</h1>

<form action="/action_page.php">
  <label for="html">HTML</label><br>
<textarea rows="2" cols="20" name="usrtxt" wrap="soft">
At Horje you will find free Web-building tutorials.
</textarea>
<input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <textarea> wrap soft Attribute with label Tag

How to add HTML <textarea> wrap hard Attribute with label Tag

The text in a text area with wrap="hard" will contain newlines (if any) when submitted in a form:

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The textarea wrap attribute</h1>

<form action="/action_page.php">
  <label for="html">HTML</label><br>
<textarea rows="2" cols="20" name="usrtxt" wrap="hard">
At Horje you will find free Web-building tutorials.
</textarea>
<input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <textarea> wrap hard Attribute with label Tag

# Tips-64) What is HTML <legend> Tag

Group related elements in a form.

Definition and Usage

The <legend> tag defines a caption for the <fieldset> element.


Browser Support

How to add HTML <legend> Tag

Group related elements in a form.
index.html
Example: HTML
<form action="/action_page.php">
 <fieldset>
  <legend>Personalia:</legend>
  <label for="fname">First name:</label>
  <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>
  <input type="email" id="email" name="email"><br><br>
  <label for="birthday">Birthday:</label>
  <input type="date" id="birthday" name="birthday"><br><br>
  <input type="submit" value="Submit">
 </fieldset>
</form>

Output should be:

How to add HTML <legend> Tag

How to set the fieldset caption float to the right (with CSS) HTML <legend> Tag

Let the fieldset caption float to the right (with CSS).

index.html
Example: HTML
<form action="/action_page.php">
  <fieldset>
    <legend style="float:right">Personalia:</legend>
    <label for="fname">First name:</label>
    <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>
    <input type="email" id="email" name="email"><br><br>
    <label for="birthday">Birthday:</label>
    <input type="date" id="birthday" name="birthday"><br><br>
    <input type="submit" value="Submit">
  </fieldset>
</form>

Output should be:

How to set the fieldset caption float to the right (with CSS) HTML <legend> Tag

How to Use CSS to style <fieldset> and <legend>

The fieldset element + CSS

Follow the example.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
fieldset {
  background-color: #eeeeee;
}

legend {
  background-color: gray;
  color: white;
  padding: 5px 10px;
}

input {
  margin: 5px;
}
</style>
</head>
<body>

<h1>The fieldset element + CSS</h1>

<form action="/action_page.php">
 <fieldset>
  <legend>Personalia:</legend>
  <label for="fname">First name:</label>
  <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>
  <input type="email" id="email" name="email"><br><br>
  <label for="birthday">Birthday:</label>
  <input type="date" id="birthday" name="birthday"><br><br>
  <input type="submit" value="Submit">
 </fieldset>
</form>

</body>
</html>

Output should be:

How to Use CSS to style <fieldset> and <legend>

How to set Default CSS Settings of <legend> element

Most browsers will display the <legend> element with the following default values.

Change the default CSS settings to see the effect.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
legend { 
  display: block;
  padding-left: 2px;
  padding-right: 2px;
  border: none;
}
</style>
</head>
<body>

<p>A legend element is displayed like this:</p>

<fieldset>
  <legend>Personalia:</legend>
  Name: <input type="text"><br>
  Email: <input type="text"><br>
  Date of birth: <input type="text">
</fieldset>

<p>Change the default CSS settings to see the effect.</p>

</body>
</html>

Output should be:

How to set Default CSS Settings of <legend> element

# Tips-65) What is HTML <li> Tag

Definition and Usage

The <li> tag defines a list item.

The <li> tag is used inside ordered lists(<ol>), unordered lists (<ul>), and in menu lists (<menu>).

In <ul> and <menu>, the list items will usually be displayed with bullet points.

In <ol>, the list items will usually be displayed with numbers or letters.

Browser Support

How to create HTML <li> Tag

Example of The ol and ul elements.
index.html
Example: HTML
<ol>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol>

<p>The ul element defines an unordered list:</p>
<ul>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ul>

Output should be:

How to create HTML <li> Tag

How to create HTML <li> value Attribute

Use of the value attribute in an ordered list.

Definition and Usage

The value attribute sets the value of a list item. The following list items will increment from that number.

The value must be a number and can only be used in ordered lists (<ol>).


Browser Support

Syntax

<li value="number">

Attribute Values

Value Description
number Specifies the value of the list item
index.html
Example: HTML
 <ol>
  <li value="100">Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
  <li>Water</li>
  <li>Juice</li>
  <li>Beer</li>
</ol> 

Output should be:

How to create HTML <li> value Attribute

How to Use of the value attribute in an ordered list

Use of the value attribute in an ordered list.

index.html
Example: HTML
<ol>
  <li value="100">Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
  <li>Water</li>
  <li>Juice</li>
  <li>Beer</li>
</ol>

Output should be:

How to Use of the value attribute in an ordered list

How to Set different list style types (with CSS)

Define list type with CSS

index.html
Example: HTML
<ol>
  <li>Coffee</li>
  <li style="list-style-type:lower-alpha">Tea</li>
  <li>Milk</li>
</ol>
<ul>
  <li>Coffee</li>
  <li style="list-style-type:square">Tea</li>
  <li>Milk</li>
</ul>

Output should be:

How to Set different list style types (with CSS)

How to Create a list inside a list (a nested list)

A list inside another list.

index.html
Example: HTML
<ul>
  <li>Coffee</li>
  <li>Tea
    <ul>
      <li>Black tea</li>
      <li>Green tea</li>
    </ul>
  </li>
  <li>Milk</li>
</ul>

Output should be:

How to Create a list inside a list (a nested list)

How to Create a more complex nested list

A list in a list in a list.

index.html
Example: HTML
<ul>
  <li>Coffee</li>
  <li>Tea
    <ul>
      <li>Black tea</li>
      <li>Green tea
        <ul>
          <li>China</li>
          <li>Africa</li>
        </ul>
      </li>
    </ul>
  </li>
  <li>Milk</li>
</ul>

Output should be:

How to Create a more complex nested list

How to set Default CSS Settings of <li> element

Most browsers will display the <li> element with the following default values.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>
<style>
li {
  display: list-item;
}
</style>

<h1>The ol and ul elements</h1>

<p>The ol element defines an ordered list:</p>
<ol>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol>

<p>The ul element defines an unordered list:</p>
<ul>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ul>

</body>
</html>

Output should be:

How to set Default CSS Settings of <li> element

# Tips-66) What is HTML <link> Tag

Definition and Usage

The <link> tag defines the relationship between the current document and an external resource.

The <link> tag is most often used to link to external style sheets or to add a favicon to your website.

The <link> element is an empty element, it contains attributes only.


Browser Support

Attributes

Attribute Value Description
crossorigin anonymous
use-credentials
Specifies how the element handles cross-origin requests
href URL Specifies the location of the linked document
hreflang language_code Specifies the language of the text in the linked document
media media_query Specifies on what device the linked document will be displayed
referrerpolicy no-referrer
no-referrer-when-downgrade
origin
origin-when-cross-origin
unsafe-url
Specifies which referrer to use when fetching the resource
rel alternate
author
dns-prefetch
help
icon
license
next
pingback
preconnect
prefetch
preload
prerender
prev
search
stylesheet
Required. Specifies the relationship between the current document and the linked document
sizes HeightxWidth
any
Specifies the size of the linked resource. Only for rel="icon"
title   Defines a preferred or an alternate stylesheet
type media_type Specifies the media type of the linked document

How to create HTML <link> Tag

Link to an external style sheet.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" href="https://www.w3schools.com/tags/styles.css">
</head>
<body>

<h1>Hello World!</h1>

<h2>I am formatted with a linked style sheet.</h2>

<p>Me too!</p>

</body>
</html>

Output should be:

How to create HTML <link> Tag

How to create crossorigin Attributes on HTML <link> Tag

Setting the attribute name to an empty value, like crossorigin or crossorigin="", is the same as anonymous.

index.html
Example: HTML
<link rel="manifest" href="/app.webmanifest" crossorigin="use-credentials" />

How to create HTML <link> href Attribute

Link to an external stylesheet.

Definition and Usage

The href attribute specifies the location (URL) of the external resource (most often a style sheet file).


Browser Support

Syntax

<link href="URL">

Attribute Values

Value Description
URL The URL of the linked resource/document.

Possible values:

  • An absolute URL - points to another web site (like href="http://www.example.com/theme.css")
  • A relative URL - points to a file within a web site (like href="/themes/theme.css")
index.html
Example: HTML
<link rel="stylesheet" href="https://www.w3schools.com/tags/styles.css">

Output should be:

How to create HTML <link> href Attribute

How to create HTML <link> hreflang Attribute

Here, the hreflang attribute indicates that the linked document is in English.

Definition and Usage

The hreflang attribute specifies the language of the text in the linked document.

This attribute is only used if the href attribute is set.

Note: This attribute is purely advisory.


Browser Support

Note: The hreflang attribute does not render as anything special in any of the major browsers. However, it can be used by search engines, or in scripts.


Syntax

<link hreflang="langauge_code">

Attribute Values

Value Description
language_code A two-letter language code that specifies the language of the linked document.

To view all available language codes, go to our Language code reference.

index.html
Example: HTML
<link href="tag_link.asp" rel="parent" rev="subsection" hreflang="en">

Output should be:

How to create HTML <link> hreflang Attribute

How to create HTML <link> media Attribute

Two different style sheets for two different media types (screen and print).

Definition and Usage

The media attribute specifies what media/device the target resource is optimized for.

This attribute is mostly used with CSS style sheets to specify different styles for different media types.

The media attribute can accept several values.


Browser Support

Syntax

<link media="value">

Possible Operators

Value Description
and Specifies an AND operator
not Specifies a NOT operator
, Specifies an OR operator

Devices

Value Description
all Default. Used for all media type devices
print Used for Print preview mode/printed pages
screen Used for computer screens, tablets, smart-phones etc.
speech Used for screenreaders that "reads" the page out loud
aural Deprecated. Speech synthesizers
braille Deprecated. Braille feedback devices
handheld Deprecated. Handheld devices (small screen, limited bandwidth)
projection Deprecated. Projectors
tty Deprecated. Teletypes and similar media using a fixed-pitch character grid
tv Deprecated. Television type devices (low resolution, limited scroll ability)

Values

Value Description
aspect-ratio Specifies the width/height ratio of the targeted display area.
"min-" and "max-" prefixes can be used.
Example: media="screen and (max-aspect-ratio:16/9)"
color Specifies the bits per color of target display.
"min-" and "max-" prefixes can be used.
Example: media="screen and (min-color:3)"
color-index Specifies the number of colors the target display can handle.
"min-" and "max-" prefixes can be used.
Example: media="screen and (min-color-index:256)"
device-aspect-ratio Deprecated. Specifies the device-width/device-height ratio of the target display/paper.
device-width Deprecated. Specifies the width of the target display/paper.
device-height Deprecated. Specifies the height of the target display/paper.
grid Specifies if the output device is grid or bitmap.
Possible values are "1" for grid, and "0" otherwise.
Example: media="handheld and (grid:1)"
height Specifies the height of the  targeted display area.
"min-" and "max-" prefixes can be used.
Example: media="screen and (max-height:700px)"
monochrome Specifies the bits per pixel in a monochrome frame buffer.
"min-" and "max-" prefixes can be used.
Example: media="screen and (min-monochrome:2)"
orientation Specifies the orientation of the target display/paper.
Possible values: "portrait" or "landscape"
Example: media="all and (orientation: landscape)"
resolution Specifies the pixel density (dpi or dpcm) of the target display/paper.
"min-" and "max-" prefixes can be used.
Example: media="print and (min-resolution:300dpi)"
scan Specifies scanning method of a tv display.
Possible values are "progressive" and "interlace".
Example: media="tv and (scan:interlace)"
width Specifies the width of the targeted display area.
"min-" and "max-" prefixes can be used.
Example: media="screen and (min-width:500px)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_screen.css">
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_print.css" media="print">
</head>
<body>

<h1>Horje Example</h1>
<p><a href="tryhtml_link_media.htm" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to create HTML <link> media Attribute

How to use and value on HTML <link> media Attribute

and Specifies an AND operator
index.html
Example: HTML
<link rel="stylesheet" type="text/css" href="demo_print.css" media="screen and (max-aspect-ratio:16/9)">

Output should be:

How to use and value on HTML <link> media Attribute

How to use not value on HTML <link> media Attribute

not Specifies a NOT operator
index.html
Example: HTML
<link rel="stylesheet" type="text/css" href="demo_print.css" media="screen not (max-aspect-ratio:16/9)">

Output should be:

How to use not value on HTML <link> media Attribute

How to use , value on HTML <link> media Attribute

, Specifies an OR operator
index.html
Example: HTML
<link rel="stylesheet" type="text/css" href="demo_print.css" media="screen , (max-aspect-ratio:16/9)">

Output should be:

How to use , value on HTML <link> media Attribute

How to use and print on HTML <link> media Attribute

print Used for Print preview mode/printed pages
index.html
Example: HTML
<link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_print.css" media="print">

Output should be:

How to use and print on HTML <link> media Attribute

How to use all value on HTML <link> media Attribute

all Default. Used for all media type devices
index.html
Example: HTML
<link href="mobile.css" rel="stylesheet" media="all" />

Output should be:

How to use all value on HTML <link> media Attribute

How to use print value on HTML <link> media Attribute

print Used for Print preview mode/printed pages
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_screen.css">
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_print.css" media="print">
</head>
<body>

<h1>W3Schools Example</h1>
<p><a href="tryhtml_link_media.htm" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to use print value on HTML <link> media Attribute

How to use screen value on HTML <link> media Attribute

screen Used for computer screens, tablets, smart-phones etc.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_screen.css">
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_print.css" media="screen and (min-color-index:256)">
</head>
<body>

<h1>Horje Example</h1>
<p><a href="tryhtml_link_media.htm" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to use screen value on HTML <link> media Attribute

How to use speech value on HTML <link> media Attribute

speech Used for screenreaders that "reads" the page out loud
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_screen.css">
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_print.css" media="speech">
</head>
<body>

<h1>W3Schools Example</h1>
<p><a href="tryhtml_link_media.htm" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to use speech value on HTML <link> media Attribute

How to use speech value on HTML <link> media Attribute

aural Deprecated. Speech synthesizers
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_screen.css">
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_print.css" media="aural">
</head>
<body>

<h1>Horje Example</h1>
<p><a href="tryhtml_link_media.htm" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to use speech value on HTML <link> media Attribute

How to use braille value on HTML <link> media Attribute

braille Deprecated. Braille feedback devices
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_screen.css">
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_print.css" media="braille">
</head>
<body>

<h1>Horje Example</h1>
<p><a href="tryhtml_link_media.htm" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to use braille value on HTML <link> media Attribute

How to use handheld value on HTML <link> media Attribute

handheld Handheld devices (small screen, limited bandwidth)
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_screen.css">
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_print.css" media="handheld">
</head>
<body>

<h1>Horje Example</h1>
<p><a href="tryhtml_link_media.htm" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to use handheld value on HTML <link> media Attribute

How to use projection value on HTML <link> media Attribute

projection Projectors
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_screen.css">
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_print.css" media="projection">
</head>
<body>

<h1>Horje Example</h1>
<p><a href="tryhtml_link_media.htm" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to use projection value on HTML <link> media Attribute

How to use tty value on HTML <link> media Attribute

tty Deprecated. Teletypes and similar media using a fixed-pitch character grid
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_screen.css">
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_print.css" media="tty">
</head>
<body>

<h1>Horje Example</h1>
<p><a href="tryhtml_link_media.htm" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to use tty value on HTML <link> media Attribute

How to use tv value on HTML <link> media Attribute

tv Deprecated. Television type devices (low resolution, limited scroll ability)
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_screen.css">
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_print.css" media="tv and (scan:interlace)">
</head>
<body>

<h1>W3Schools Example</h1>
<p><a href="tryhtml_link_media.htm" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to use tv value on HTML <link> media Attribute

How to use aspect-ratio value on HTML <link> media Attribute

aspect-ratio Specifies the width/height ratio of the targeted display area.
"min-" and "max-" prefixes can be used.
Example: media="screen and (max-aspect-ratio:16/9)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_screen.css">
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_print.css" media="screen and (max-aspect-ratio:16/9)">
</head>
<body>

<h1>Horje Example</h1>
<p><a href="tryhtml_link_media.htm" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to use aspect-ratio value on HTML <link> media Attribute

How to use color value on HTML <link> media Attribute

color Specifies the bits per color of target display.
"min-" and "max-" prefixes can be used.
Example: media="screen and (min-color:3)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_screen.css">
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_print.css" media="screen and (min-color:3)">
</head>
<body>

<h1>Horje Example</h1>
<p><a href="tryhtml_link_media.htm" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to use color value on HTML <link> media Attribute

How to use color-index value on HTML <link> media Attribute

color-index Specifies the number of colors the target display can handle.
"min-" and "max-" prefixes can be used.
Example: media="screen and (min-color-index:256)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_screen.css">
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_print.css" media="screen and (min-color-index:256)">
</head>
<body>

<h1>Horje Example</h1>
<p><a href="tryhtml_link_media.htm" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to use color-index value on HTML <link> media Attribute

How to use device-aspect-ratio value on HTML <link> media Attribute

device-aspect-ratio Deprecated. Specifies the device-width/device-height ratio of the target display/paper.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_screen.css">
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_print.css" media="screen and (min-device-aspect-ratio: 16/9)">
</head>
<body>

<h1>Horje Example</h1>
<p><a href="tryhtml_link_media.htm" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to use device-aspect-ratio value on HTML <link> media Attribute

How to use device-width value on HTML <link> media Attribute

device-width Deprecated. Specifies the width of the target display/paper.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_screen.css">
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_print.css" media="screen and (max-device-width: 799px)">
</head>
<body>

<h1>Horje Example</h1>
<p><a href="tryhtml_link_media.htm" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to use device-width value on HTML <link> media Attribute

How to use device-height value on HTML <link> media Attribute

device-height Deprecated. Specifies the height of the target display/paper.
index.html
Example: HTML
<link
  rel="stylesheet"
  media="screen and (max-device-height: 799px)"
  href="https://www.w3schools.com/tags/demo_screen.css" />

Output should be:

How to use device-height value on HTML <link> media Attribute

How to use grid value on HTML <link> media Attribute

grid Specifies if the output device is grid or bitmap.
Possible values are "1" for grid, and "0" otherwise.
Example: media="handheld and (grid:1)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_screen.css">
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_print.css" media="handheld and (grid:1)">
</head>
<body>

<h1>Horje Example</h1>
<p><a href="tryhtml_link_media.htm" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to use grid value on HTML <link> media Attribute

How to use height value on HTML <link> media Attribute

height Specifies the height of the  targeted display area.
"min-" and "max-" prefixes can be used.
Example: media="screen and (max-height:700px)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_screen.css">
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_print.css" media="screen and (max-height:700px)">
</head>
<body>

<h1>Horje Example</h1>
<p><a href="tryhtml_link_media.htm" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to use height value on HTML <link> media Attribute

How to use monochrome value on HTML <link> media Attribute

monochrome Specifies the bits per pixel in a monochrome frame buffer.
"min-" and "max-" prefixes can be used.
Example: media="screen and (min-monochrome:2)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_screen.css">
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_print.css" media="screen and (min-monochrome:2)">
</head>
<body>

<h1>Horje Example</h1>
<p><a href="tryhtml_link_media.htm" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to use monochrome value on HTML <link> media Attribute

How to use orientation value on HTML <link> media Attribute

orientation Specifies the orientation of the target display/paper.
Possible values: "portrait" or "landscape"
Example: media="all and (orientation: landscape)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_screen.css">
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_print.css" media="all and (orientation: landscape)">
</head>
<body>

<h1>Horje Example</h1>
<p><a href="tryhtml_link_media.htm" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to use orientation value on HTML <link> media Attribute

How to use resolution value on HTML <link> media Attribute

resolution Specifies the pixel density (dpi or dpcm) of the target display/paper.
"min-" and "max-" prefixes can be used.
Example: media="print and (min-resolution:300dpi)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_screen.css">
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_print.css" media="print and (min-resolution:300dpi)">
</head>
<body>

<h1>Horje Example</h1>
<p><a href="tryhtml_link_media.htm" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to use resolution value on HTML <link> media Attribute

How to use scan value on HTML <link> media Attribute

scan Specifies scanning method of a tv display.
Possible values are "progressive" and "interlace".
Example: media="tv and (scan:interlace)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_screen.css">
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_print.css" media="tv and (scan:interlace)">
</head>
<body>

<h1>Horje Example</h1>
<p><a href="tryhtml_link_media.htm" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to use scan value on HTML <link> media Attribute

How to use width value on HTML <link> media Attribute

width Specifies the width of the targeted display area.
"min-" and "max-" prefixes can be used.
Example: media="screen and (min-width:500px)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_screen.css">
  <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/tags/demo_print.css" media="screen and (min-width:500px)">
</head>
<body>

<h1>Horje Example</h1>
<p><a href="tryhtml_link_media.htm" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to use width value on HTML <link> media Attribute

How to create HTML <iframe> referrerpolicy Attribute on HTML <link> Tag

Definition and Usage

The referrerpolicy attribute specifies which referrer information to send when fetching an iframe.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<iframe referrerpolicy="no-referrer|no-referrer-when-downgrade|origin|origin-when-cross-origin|same-origin|strict-origin-when-cross-origin|unsafe-url">

Attribute Values

Value Description
no-referrer No referrer information will be sent along with a request
no-referrer-when-downgrade Default. The referrer header will not be sent to origins without HTTPS
origin Send only scheme, host, and port to the request client
origin-when-cross-origin For cross-origin requests: Send only scheme, host, and port. For same-origin requests: Also include the path
same-origin For same-origin requests: Referrer info will be sent. For cross-origin requests: No referrer info will be sent
strict-origin Only send referrer info if the security level is the same (e.g. HTTPS to HTTPS). Do not send to a less secure destination (e.g. HTTPS to HTTP)
strict-origin-when-cross-origin Send full path when performing a same-origin request. Send only origin when the security level stays the same (e.g. HTTPS to HTTPS). Send no header to a less secure destination (HTTPS to HTTP)
unsafe-url Send origin, path and query string (but not fragment, password, or username). This value is considered unsafe
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The iframe referrerpolicy attribute</h1>

<iframe src="https://horje.com/" referrerpolicy="no-referrer">
  <p>Your browser does not support iframes.</p>
</iframe>

</body>
</html>

Output should be:

How to create HTML <iframe> referrerpolicy Attribute on HTML <link> Tag

How to create HTML <iframe> no-referrer Attribute on HTML <link> Tag

no-referrer No referrer information will be sent along with a request
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The iframe referrerpolicy attribute</h1>

<iframe src="https://w3schools.com/" referrerpolicy="no-referrer">
  <p>Your browser does not support iframes.</p>
</iframe>

</body>
</html>

Output should be:

How to create HTML <iframe> no-referrer Attribute on HTML <link> Tag

How to create HTML <iframe> no-referrer-when-downgrade Attribute on HTML <link> Tag

no-referrer-when-downgrade Default. The referrer header will not be sent to origins without HTTPS
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The iframe referrerpolicy attribute</h1>

<iframe src="https://w3schools.com/" referrerpolicy="no-referrer-when-downgrade">
  <p>Your browser does not support iframes.</p>
</iframe>

</body>
</html>

Output should be:

How to create HTML <iframe> no-referrer-when-downgrade Attribute on HTML <link> Tag

How to create HTML <iframe> origin Attribute on HTML <link> Tag

origin Send only scheme, host, and port to the request client
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The iframe referrerpolicy attribute</h1>

<iframe src="https://horje.com/" referrerpolicy="origin">
  <p>Your browser does not support iframes.</p>
</iframe>

</body>
</html>

Output should be:

How to create HTML <iframe> origin Attribute on HTML <link> Tag

How to create HTML <iframe> origin-when-cross-origin Attribute on HTML <link> Tag

origin-when-cross-origin For cross-origin requests: Send only scheme, host, and port. For same-origin requests: Also include the path
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The iframe referrerpolicy attribute</h1>

<iframe src="https://horje.com" referrerpolicy="origin-when-cross-origin">
  <p>Your browser does not support iframes.</p>
</iframe>

</body>
</html>

Output should be:

How to create HTML <iframe> origin-when-cross-origin Attribute on HTML <link> Tag

How to create HTML <iframe> same-origin Attribute on HTML <link> Tag

same-origin For same-origin requests: Referrer info will be sent. For cross-origin requests: No referrer info will be sent
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The iframe referrerpolicy attribute</h1>

<iframe src="https://horje.com" referrerpolicy="same-origin">
  <p>Your browser does not support iframes.</p>
</iframe>

</body>
</html>

Output should be:

How to create HTML <iframe> same-origin Attribute on HTML <link> Tag

How to create HTML <iframe> strict-origin Attribute on HTML <link> Tag

strict-origin Only send referrer info if the security level is the same (e.g. HTTPS to HTTPS). Do not send to a less secure destination (e.g. HTTPS to HTTP)
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The iframe referrerpolicy attribute</h1>

<iframe src="https://horje.com" referrerpolicy="strict-origin">
  <p>Your browser does not support iframes.</p>
</iframe>

</body>
</html>

Output should be:

How to create HTML <iframe> strict-origin Attribute on HTML <link> Tag

How to create HTML <iframe> strict-origin-when-cross-origin Attribute on HTML <link> Tag

strict-origin-when-cross-origin Send full path when performing a same-origin request. Send only origin when the security level stays the same (e.g. HTTPS to HTTPS). Send no header to a less secure destination (HTTPS to HTTP)
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The iframe referrerpolicy attribute</h1>

<iframe src="https://horje.com" referrerpolicy="strict-origin-when-cross-origin">
  <p>Your browser does not support iframes.</p>
</iframe>

</body>
</html>

Output should be:

How to create HTML <iframe> strict-origin-when-cross-origin Attribute on HTML <link> Tag

How to create HTML <iframe> unsafe-url Attribute on HTML <link> Tag

unsafe-url Send origin, path and query string (but not fragment, password, or username). This value is considered unsafe
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The iframe referrerpolicy attribute</h1>

<iframe src="https://horje.com" referrerpolicy="unsafe-url">
  <p>Your browser does not support iframes.</p>
</iframe>

</body>
</html>

Output should be:

How to create HTML <iframe> unsafe-url Attribute on HTML <link> Tag

How to add HTML <link> rel Attribute

Definition and Usage

The required rel attribute specifies the relationship between the current document and the linked document/resource.


Browser Support

Syntax

<link rel="value">

Attribute Values

Value Description
alternate Provides a link to an alternate version of the document (i.e. print page, translated or mirror).
Example: <link rel="alternate" type="application/atom+xml" title="W3Schools News" href="/blog/news/atom">
author Provides a link to the author of the document
dns-prefetch Specifies that the browser should preemptively perform DNS resolution for the target resource's origin
help Provides a link to a help document. Example: <link rel="help" href="/help/">
icon Imports an icon to represent the document.
Example: <link rel="icon" href="favicon.ico" type="image/x-icon">
license Provides a link to copyright information for the document
next Provides a link to the next document in the series
pingback Provides the address of the pingback server that handles pingbacks to the current document
preconnect Specifies that the browser should preemptively connect to the target resource's origin.
prefetch Specifies that the browser should preemptively fetch and cache the target resource as it is likely to be required for a follow-up navigation
preload Specifies that the browser agent must preemptively fetch and cache the target resource for current navigation according to the destination given by the "as" attribute (and the priority associated with that destination).
prerender Specifies that the browser should pre-render (load) the specified webpage in the background. So, if the user navigates to this page, it speeds up the page load (because the page is already loaded). Warning! This wastes the user's bandwidth! Only use prerender if you are absolutely sure that the webpage is required at some point in the user's journey
prev Indicates that the document is a part of a series, and that the previous document in the series is the referenced document
search Provides a link to a resource that can be used to search through the current document and its related pages.
stylesheet Imports a style sheet
index.html
Example: HTML
<link rel="stylesheet" href="styles.css">

Output should be:

How to add HTML <link> rel Attribute

How to add HTML alternate <link> rel Attribute

alternate Provides a link to an alternate version of the document (i.e. print page, translated or mirror).
Example: <link rel="alternate" type="application/atom+xml" title="W3Schools News" href="/blog/news/atom">
index.html
Example: HTML
<link rel="alternate" type="application/atom+xml" title="Horje News" href="/blog/news/atom">

Output should be:

How to add HTML alternate <link> rel Attribute

How to add HTML author <link> rel Attribute

author Provides a link to the author of the document
index.html
Example: HTML
<a href="/author-page.html" rel="author">link text</a>

Output should be:

How to add HTML author <link> rel Attribute

How to add HTML dns-prefetch <link> rel Attribute

dns-prefetch Specifies that the browser should preemptively perform DNS resolution for the target resource's origin
index.html
Example: HTML
<link rel="dns-prefetch stylesheet" href="https://css.static.com/mystyle.css" >

Output should be:

How to add HTML dns-prefetch <link> rel Attribute

How to add HTML help <link> rel Attribute

help Provides a link to a help document. Example: <link rel="help" href="/help/">
index.html
Example: HTML
<link rel="help" href="/help/">

Output should be:

How to add HTML help <link> rel Attribute

How to add HTML icon <link> rel Attribute

icon Imports an icon to represent the document.
Example: <link rel="icon" href="favicon.ico" type="image/x-icon">
index.html
Example: HTML
<link rel="icon" href="favicon.ico" type="image/x-icon">

Output should be:

How to add HTML icon <link> rel Attribute

How to add HTML license <link> rel Attribute

license Provides a link to copyright information for the document
index.html
Example: HTML
<link rel="license" href="#license" />

Output should be:

How to add HTML license <link> rel Attribute

How to add HTML next <link> rel Attribute

next Provides a link to the next document in the series
index.html
Example: HTML
<link rel="next" href="https://www.example.com/article?story=abc&page=2" />

Output should be:

How to add HTML next <link> rel Attribute

How to add HTML pingback <link> rel Attribute

pingback Provides the address of the pingback server that handles pingbacks to the current document
index.html
Example: HTML
<link rel="pingback" href="pingback server">

Output should be:

How to add HTML pingback <link> rel Attribute

How to add HTML preconnect <link> rel Attribute

preconnect Specifies that the browser should preemptively connect to the target resource's origin.
index.html
Example: HTML
<link rel="preconnect" href="https://example.com" />

Output should be:

How to add HTML preconnect <link> rel Attribute

How to add HTML prefetch <link> rel Attribute

prefetch Specifies that the browser should preemptively fetch and cache the target resource as it is likely to be required for a follow-up navigation

rel=prefetch

The prefetch keyword for the rel attribute of the <link> element provides a hint to browsers that the user is likely to need the target resource for future navigations, and therefore the browser can likely improve the user experience by preemptively fetching and caching the resource. <link rel="prefetch"> is used for same-site navigation resources, or for subresources used by same-site pages.

The result is kept in the HTTP cache on disk. Because of this it is useful for prefetching subresources, even if they are not used by the current page. You could also use it to prefetch the next document the user will likely visit on the site. However, as a result you need to be careful with headers — for example certain Cache-Control headers could block prefetching (for example no-cache or no-store).

Note: Because of such limitations, you are advised to use the Speculation Rules API for document prefetches instead, where it is supported.

<link rel="prefetch"> is functionally equivalent to a fetch() call with a priority: "low" option set on it, except that the former will generally have an even lower priority, and it will have a Sec-Purpose: prefetch header set on the request. Note that in general browsers will give prefetch resources a lower priority than preload ones (e.g. requested via <link rel="preload">) — the current page is more important than the next.

The fetch request for a prefetch operation results in an HTTP request that includes the HTTP header Sec-Purpose: prefetch. A server might use this header to change the cache timeouts for the resources, or perform other special handling. The request will also include the Sec-Fetch-Dest header with the value set to empty.

The Accept header in the request will match the value used for normal navigation requests. This allows the browser to find the matching cached resources following navigation.

index.html
Example: HTML
<link rel="prefetch" href="/landing-page" />

Output should be:

How to add HTML prefetch <link> rel Attribute

How to add HTML preload <link> rel Attribute

preload Specifies that the browser agent must preemptively fetch and cache the target resource for current navigation according to the destination given by the "as" attribute (and the priority associated with that destination).

The preload value of the <link> element's rel attribute lets you declare fetch requests in the HTML's <head>, specifying resources that your page will need very soon, which you want to start loading early in the page lifecycle, before browsers' main rendering machinery kicks in. This ensures they are available earlier and are less likely to block the page's render, improving performance. Even though the name contains the term load, it doesn't load and execute the script but only schedules it to be downloaded and cached with a higher priority.

index.html
Example: HTML
<link rel="preload" href="style.css" as="style" />

Output should be:

How to add HTML preload <link> rel Attribute

How to add HTML prerender <link> rel Attribute

prerender Specifies that the browser should pre-render (load) the specified webpage in the background. So, if the user navigates to this page, it speeds up the page load (because the page is already loaded). Warning! This wastes the user's bandwidth! Only use prerender if you are absolutely sure that the webpage is required at some point in the user's journey
index.html
Example: HTML
<link rel="prerender" href="/next-page">

How to add HTML prev <link> rel Attribute

prev Indicates that the document is a part of a series, and that the previous document in the series is the referenced document

A rel="prev" attribute value on a link specifies that the linked page is the previous page of the current page.

This can be used for articles, galleries, news, and other page in a series of pages.

A rel="prev" on an <a> element.
This link opens the previous page in a list of pages

index.html
Example: HTML
Go back to the <a rel="prev" href="/html/rel/license">previous page</a>

Output should be:

How to add HTML prev <link> rel Attribute

How to add HTML search <link> rel Attribute

A rel="search" on an <a> element.
This link is a Google search query with a filter for the current site.

search Provides a link to a resource that can be used to search through the current document and its related pages.
index.html
Example: HTML
To discover more:
 <a rel="search" href="https://google.com/search?q=site:dofactory.com" 
    target="_blank">Search here</a>.

Output should be:

 How to add HTML search <link> rel Attribute

How to add HTML stylesheet <link> rel Attribute

 

The rel='stylesheet' attribute is used to define the relationship between the linked file and the current HTML document.

The rel stands for "relationship", and is probably one of the key features of the <link> element — the value denotes how the item being linked to is related to the containing current document.

The current HTML document needs to tell the browser what you were linking to using the rel tag, otherwise the browser would have no idea what to do with the content you're linking to.

stylesheet Imports a style sheet

 

index.html
Example: HTML
<link href='style.css' rel='stylesheet'>

How to add HTML <link> sizes Attribute

Icon with specified size:

Definition and Usage

The sizes attribute specifies the sizes of icons for visual media.

This attribute is only used if rel="icon".


Browser Support

Syntax

<link sizes="HeightxWidth|any">

Attribute Values

Value Description
HeightxWidth Specifies one or more sizes for the linked icon.
The height and width values are separated by an "x" or "X".

Examples:

  • <link rel="icon" href="favicon.png" sizes="16x16" type="image/png"> (1 size)
  • <link rel="icon" href="favicon.png" sizes="16x16 32x32" type="image/png"> (2 sizes)
any Specifies that the icon is scalable (like an SVG image)

Examples:

  • <link rel="icon" href="icon.svg" sizes="any" type="image/svg+xml"> (any size)
index.html
Example: HTML
 <link rel="icon" href="demo_icon.gif" type="image/gif" sizes="16x16"> 

Output should be:

How to add HTML <link> sizes Attribute

How to add HTML <link> sizes HeightxWidth Attribute

any Specifies that the icon is scalable (like an SVG image)

Examples:

  • <link rel="icon" href="icon.svg" sizes="any" type="image/svg+xml"> (any size)
<link rel="icon" href="demo_icon.gif" type="image/gif" sizes="16x16">

Output should be:

How to add HTML <link> sizes HeightxWidth Attribute

How to add HTML <link> any sizes Attribute

any Specifies that the icon is scalable (like an SVG image)

Examples:

  • <link rel="icon" href="icon.svg" sizes="any" type="image/svg+xml"> (any size)
index.html
Example: HTML
<link rel="icon" href="demo_icon.gif" type="image/gif" sizes="any">

Output should be:

How to add HTML <link> any sizes Attribute

How to add HTML <link> title Attribute

title   Defines a preferred or an alternate stylesheet
index.html
Example: HTML
<link rel="stylesheet" 
type="text/css" href="paul.css" 
title="bog standard" />

How to add HTML <link> type Attribute

In the following example, the type attribute indicates that the linked document is an external style sheet:

Definition and Usage

The type attribute specifies the media type of the linked document/resource.

The most common value of type is "text/css". If you omit the type attribute, the browser will look at the rel attribute to guess the correct type. So, if rel="stylesheet", the browser will assume the type is "text/css".


Browser Support

Syntax

<link type="media_type">

Attribute Values

Value Description
media_type The media type of the linked document.
Look at IANA Media Types for a complete list of standard media types
index.html
Example: HTML
 <head>
  <link rel="stylesheet" type="text/css" href="styles.css">
</head> 

Output should be:

How to add HTML <link> type Attribute

# Tips-67) What is HTML <main> Tag

Specify the main content of the document:

Definition and Usage

The <main> tag specifies the main content of a document.

The content inside the <main> element should be unique to the document. It should not contain any content that is repeated across documents such as sidebars, navigation links, copyright information, site logos, and search forms.

Note: There must not be more than one <main> element in a document. The <main> element must NOT be a descendant of an <article>, <aside>, <footer>, <header>, or <nav> element.


Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Global Attributes

The <main> tag also supports the Global Attributes in HTML.


Event Attributes

The <main> tag also supports the Event Attributes in HTML.


How to create HTML <main> Tag

Specify the main content of the document:
index.html
Example: HTML
 <main>
  <h1>Most Popular Browsers</h1>
  <p>Chrome, Firefox, and Edge are the most used browsers today.</p>

  <article>
    <h2>Google Chrome</h2>
    <p>Google Chrome is a web browser developed by Google, released in 2008. Chrome is the world's most popular web browser today!</p>
  </article>

  <article>
    <h2>Mozilla Firefox</h2>
    <p>Mozilla Firefox is an open-source web browser developed by Mozilla. Firefox has been the second most popular web browser since January, 2018.</p>
  </article>

  <article>
    <h2>Microsoft Edge</h2>
    <p>Microsoft Edge is a web browser developed by Microsoft, released in 2015. Microsoft Edge replaced Internet Explorer.</p>
  </article>
</main> 

Output should be:

How to create HTML <main> Tag

How to Use CSS to style the <main> element

Follow the example

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
main {
  margin: 0;
  padding: 5px;
  background-color: lightgray;
}

main > h1, p, .browser {
  margin: 10px;
  padding: 5px;
}

.browser {
  background: white;
}

.browser > h2, p {
  margin: 4px;
  font-size: 90%;
}
</style>
</head>
<body>

<h1>The main element - Styled with CSS</h1>

<main>
  <h1>Most Popular Browsers</h1>
  <p>Chrome, Firefox, and Edge are the most used browsers today.</p>
  <article class="browser">
    <h2>Google Chrome</h2>
    <p>Google Chrome is a web browser developed by Google, released in 2008. Chrome is the world's most popular web browser today!</p>
  </article>
  <article class="browser">
    <h2>Mozilla Firefox</h2>
    <p>Mozilla Firefox is an open-source web browser developed by Mozilla. Firefox has been the second most popular web browser since January, 2018.</p>
  </article>
  <article class="browser">
    <h2>Microsoft Edge</h2>
    <p>Microsoft Edge is a web browser developed by Microsoft, released in 2015. Microsoft Edge replaced Internet Explorer.</p>
  </article>
</main>

</body>
</html>

Output should be:

How to Use CSS to style the <main> element

# Tips-68) What is HTML <map> Tag

An image map, with clickable areas.

Definition and Usage

The <map> tag is used to define an image map. An image map is an image with clickable areas.

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.

The <map> element contains a number of <area> elements, that defines the clickable areas in the image map.


Browser Support

Attributes

Attribute Value Description
name mapname Required. Specifies the name of the image map

Global Attributes

The <map> tag also supports the Global Attributes in HTML.


Event Attributes

The <map> tag also supports the Event Attributes in HTML.

How to add HTML <map> Tag

An image map, with clickable areas
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The map and area elements</h1>

<p>Click on the computer, the phone, or the cup of coffee to go to a new page and read more about the topic:</p>

<img src="workplace.jpg" alt="Workplace" usemap="#workmap" width="400" height="379">

<map name="workmap">
  <area shape="rect" coords="34,44,270,350" alt="Computer" href="computer.htm">
  <area shape="rect" coords="290,172,333,250" alt="Phone" href="phone.htm">
  <area shape="circle" coords="337,300,44" alt="Cup of coffee" href="coffee.htm">
</map>

</body>
</html>

Output should be:

How to add HTML <map> Tag

How to add Another image map, with clickable areas

See the Example.

index.html
Example: HTML
 <img src="planets.gif" width="145" height="126" alt="Planets"
usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" href="sun.htm" alt="Sun">
  <area shape="circle" coords="90,58,3" href="mercur.htm" alt="Mercury">
  <area shape="circle" coords="124,58,8" href="venus.htm" alt="Venus">
</map> 

Output should be:

How to add Another image map, with clickable areas

How to set Default CSS Settings

Click on the sun or on one of the planets to watch it closer.

index.php
Example: HTML
<style>
map {
  display: inline;
}
</style>
<h1>The map and area elements</h1>

<p>Click on the sun or on one of the planets to watch it closer:</p>

<img src="planets.gif" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="sun.htm">
  <area shape="circle" coords="90,58,3" alt="Mercury" href="mercur.htm">
  <area shape="circle" coords="124,58,8" alt="Venus" href="venus.htm">
</map>

Output should be:

How to set Default CSS Settings

# Tips-69) What is HTML <mark> Tag

Highlight parts of a text.

Definition and Usage

The <mark> tag defines text that should be marked or highlighted.


Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Global Attributes

The <mark> tag also supports the Global Attributes in HTML.


Event Attributes

The <mark> tag also supports the Event Attributes in HTML.

How to create HTML <mark> Tag

Highlight parts of a text.
index.html
Example: HTML
<p>Do not forget to buy <mark>milk</mark> today.</p>

Output should be:

How to create HTML <mark> Tag

How to set Default CSS Settings for MARK

Most browsers will display the <mark> element with the following default values.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
mark { 
  background-color: yellow;
  color: black;
}
</style>
</head>
<body>

<p>A mark element is displayed like this:</p>

<mark>Highlighted text!!</mark>

<p>Change the default CSS settings to see the effect.</p>

</body>
</html>

Output should be:

How to set Default CSS Settings for MARK

# Tips-70) What is HTML <menu> Tag

A menu list.

Definition and Usage

The <menu> tag defines an unordered list of content.

Use the <menu> tag together with the <li> tag to create menu items.

Note: <menu> tag is an alternative to the <ul> tag and browsers will treat these two lists equally.


Browser Support

Global Attributes

The <menu> tag also supports the Global Attributes in HTML.


Event Attributes

The <menu> tag also supports the Event Attributes in HTML.

How to create HTML <menu> Tag

A menu list:
index.html
Example: HTML
 <menu>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</menu> 

Output should be:

How to create HTML <menu> Tag

How to set Default CSS Settings on HTML <menu> Tag

Most browsers will display the <menu> element with the following default values:
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
menu {
  display: block;
  list-style-type: disc;
  margin-block-start: 1em;
  margin-block-end: 1em;
  margin-inline-start: 0px;
  margin-inline-end: 0px;
  padding-inline-start: 40px;
}
</style>
</head>
<body>

<p>A menu element is displayed like this:</p>

<menu>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</menu>

<p>Change the default CSS settings to see the effect.</p>

</body>
</html>

Output should be:

How to set Default CSS Settings on HTML <menu> Tag

# Tips-71) What is HTML <meta> Tag

Describe metadata within an HTML document.

Definition and Usage

The <meta> tag defines metadata about an HTML document. Metadata is data (information) about data.

<meta> tags always go inside the <head> element, and are typically used to specify character set, page description, keywords, author of the document, and viewport settings.

Metadata will not be displayed on the page, but is machine parsable.

Metadata is used by browsers (how to display content or reload page), search engines (keywords), and other web services.

There is a method to let web designers take control over the viewport (the user's visible area of a web page), through the <meta> tag (See "Setting The Viewport" example below).


Browser Support

Attributes

Attribute Value Description
charset character_set Specifies the character encoding for the HTML document
content text Specifies the value associated with the http-equiv or name attribute
http-equiv content-security-policy
content-type
default-style
refresh
Provides an HTTP header for the information/value of the content attribute
name application-name
author
description
generator
keywords
viewport

Global Attributes

The <meta> tag also supports the Global Attributes in HTML.

How to create HTML <meta> Tag

Describe metadata within an HTML document:
index.html
Example: HTML
 <head>
  <meta charset="UTF-8">
  <meta name="description" content="Free Web tutorials">
  <meta name="keywords" content="HTML, CSS, JavaScript">
  <meta name="author" content="John Doe">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head> 

Output should be:

How to create HTML <meta> Tag

How to Define keywords for search engines HTML <meta> Tag

Define keywords for search engines:

index.html
Example: HTML
<meta name="keywords" content="HTML, CSS, JavaScript">

How to Define a description of your web page HTML <meta> Tag

See the example.

index.html
Example: HTML
<meta name="description" content="Free Web tutorials for HTML and CSS">

How to Define the author of a page HTML <meta> Tag

See the Example.

index.html
Example: HTML
<meta name="author" content="John Doe">

How to Refresh document every 30 seconds <meta> Tag

See the Example.

index.html
Example: HTML
<meta http-equiv="refresh" content="30">

How to set Setting the viewport to make your website look good on all devices HTML <meta> Tag

See the example.

index.html
Example: HTML
<meta name="viewport" content="width=device-width, initial-scale=1.0">

How to add Setting the Viewport HTML <meta> Tag

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 dimensions and scaling.

The width=device-width part sets the width of the page to follow the screen-width of the device (which will vary depending on the device).

The initial-scale=1.0 part sets the initial zoom level when the page is first loaded by the browser.

Here is an example of a web page without the viewport meta tag, and the same web page with the viewport meta tag:

Tip: If you are browsing this page with a phone or a tablet, you can click on the two links below to see the difference.

index.html
Example: HTML
<meta name="viewport" content="width=device-width, initial-scale=1.0">

How to add HTML <meta> charset Attribute on HTML <meta> Tag

Specify the character encoding for the HTML document.

Definition and Usage

The charset attribute specifies the character encoding for the HTML document.

The HTML5 specification encourages web developers to use the UTF-8 character set, which covers almost all of the characters and symbols in the world!


Browser Support

Syntax

<meta charset="character_set">

Attribute Values

Value Description
character_set Specifies the character encoding for the HTML document. The HTML5 specification encourages web developers to use the UTF-8 character set!
index.html
Example: HTML
 <head>
  <meta charset="UTF-8">
</head> 

Output should be:

How to add HTML <meta> charset Attribute on HTML <meta> Tag

How to add HTML <meta> content Attribute for HTML <meta> Tag

Describe metadata within an HTML document.

Definition and Usage

The content attribute gives the value associated with the http-equiv or name attribute.


Browser Support

Syntax

<meta content="text">

Attribute Values

Value Description
text The content of the meta information
index.html
Example: HTML
 <head>
  <meta name="description" content="Free Web tutorials">
  <meta name="keywords" content="HTML,CSS,XML,JavaScript">
</head> 

Output should be:

How to add HTML <meta> content Attribute for HTML <meta> Tag

How to add HTML <meta> http-equiv Attribute on HTML <meta> Tag

Refresh document every 30 seconds.

Definition and Usage

The http-equiv attribute provides an HTTP header for the information/value of the content attribute.

The http-equiv attribute can be used to simulate an HTTP response header.


Browser Support

Syntax

<meta http-equiv="content-security-policy|content-type|default-style|refresh">

Attribute Values

Value Description
content-security-policy Specifies a content policy for the document.

Example:

<meta http-equiv="content-security-policy" content="default-src 'self'">

content-type Specifies the character encoding for the document.

Example:

<meta http-equiv="content-type" content="text/html; charset=UTF-8">

default-style Specified the preferred style sheet to use.

Example:

<meta http-equiv="default-style" content="the document's preferred stylesheet">

Note: The value of the content attribute above must match the value of the title attribute on a link element in the same document, or it must match the value of the title attribute on a style element in the same document.

refresh Defines a time interval for the document to refresh itself.

Example:

<meta http-equiv="refresh" content="300">

Note: The value "refresh" should be used carefully, as it takes the control of a page away from the user. Using "refresh" will cause a failure in W3C's Web Content Accessibility Guidelines.

index.html
Example: HTML
 <head>
  <meta http-equiv="refresh" content="30">
</head> 

Output should be:

How to add HTML <meta> http-equiv Attribute on HTML <meta> Tag

How to add HTML content-security-policy on <meta> http-equiv Attribute for HTML <meta> Tag

content-security-policy Specifies a content policy for the document.

Example:

<meta http-equiv="content-security-policy" content="default-src 'self'">

index.html
Example: HTML
<meta http-equiv="content-security-policy" content="default-src 'self'">

How to add HTML content-type on <meta> http-equiv Attribute for HTML <meta> Tag

content-type Specifies the character encoding for the document.

Example:

<meta http-equiv="content-type" content="text/html; charset=UTF-8">

index.html
Example: HTML
<meta http-equiv="content-type" content="text/html; charset=UTF-8">

How to add HTML default-style on <meta> http-equiv Attribute for HTML <meta> Tag

default-style Specified the preferred style sheet to use.

Example:

<meta http-equiv="default-style" content="the document's preferred stylesheet">

Note: The value of the content attribute above must match the value of the title attribute on a link element in the same document, or it must match the value of the title attribute on a style element in the same document.

index.html
Example: HTML
<meta http-equiv="default-style" content="the document's preferred stylesheet">

How to add HTML refresh on <meta> http-equiv Attribute for HTML <meta> Tag

refresh Defines a time interval for the document to refresh itself.

Example:

<meta http-equiv="refresh" content="300">

Note: The value "refresh" should be used carefully, as it takes the control of a page away from the user. Using "refresh" will cause a failure in W3C's Web Content Accessibility Guidelines.

index.html
Example: HTML
<meta http-equiv="refresh" content="300">

How to add HTML <meta> name Attribute on HTML <meta> Tag

Use the name attribute to define a description, keywords, and the author of an HTML document. Also define the viewport to control the page's dimensions and scaling for different devices.

The name attribute specifies the name for the metadata.

The name attribute specifies a name for the information/value of the content attribute.

Note: If the http-equiv attribute is set, the name attribute should not be set.

HTML5 introduced a method to let web designers take control over the viewport (the user's visible area of a web page), through the <meta> tag (See "Setting The Viewport" example below).


Browser Support

Syntax

<meta name="value">

Attribute Values

Value Description
application-name Specifies the name of the Web application that the page represents
author Specifies the name of the author of the document. Example:
<meta name="author" content="John Doe">
description Specifies a description of the page. Search engines can pick up this description to show with the results of searches. Example:
<meta name="description" content="Free web tutorials">
generator Specifies one of the software packages used to generate the document (not used on hand-authored pages). Example:
<meta name="generator" content="FrontPage 4.0">
keywords Specifies a comma-separated list of keywords - relevant to the page (Informs search engines what the page is about). Example:
<meta name="keywords" content="HTML, meta tag, tag reference">
viewport Controls the viewport (the user's visible area of a web page).

The viewport varies with the device, and will be smaller on a mobile phone than on a computer screen.

You should include the following <meta> viewport element in all your web pages:

<meta name="viewport" content="width=device-width, initial-scale=1.0">

A <meta> viewport element gives the browser instructions on how to control the page's dimensions and scaling.

The width=device-width part sets the width of the page to follow the screen-width of the device (which will vary depending on the device).

The initial-scale=1.0 part sets the initial zoom level when the page is first loaded by the browser.

Here is an example of a web page without the viewport meta tag, and the same web page with the viewport meta tag:

Tip: If you are browsing this page with a phone or a tablet, you can click on the two links below to see the difference.

index.html
Example: HTML
 <head>
  <meta name="description" content="Free Web tutorials">
  <meta name="keywords" content="HTML,CSS,JavaScript">
  <meta name="author" content="John Doe">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head> 

Output should be:

How to add HTML <meta> name Attribute on HTML <meta> Tag

How to add HTML application-name for <meta> name Attribute on HTML <meta> Tag

application-name Specifies the name of the Web application that the page represents
index.html
Example: HTML
<meta name="application-name" content="StackOverflow">

How to add HTML author for <meta> name Attribute on HTML <meta> Tag

author Specifies the name of the author of the document. Example:
<meta name="author" content="John Doe">
index.html
Example: HTML
 <meta name="author" content="John Doe"> 

How to add HTML description for <meta> name Attribute on HTML <meta> Tag

description Specifies a description of the page. Search engines can pick up this description to show with the results of searches. Example:
<meta name="description" content="Free web tutorials">
index.html
Example: HTML
 <meta name="description" content="Free web tutorials"> 

How to add HTML generator for <meta> name Attribute on HTML <meta> Tag

generator Specifies one of the software packages used to generate the document (not used on hand-authored pages). Example:
<meta name="generator" content="FrontPage 4.0">
index.html
Example: HTML
 <meta name="generator" content="FrontPage 4.0"> 

How to add HTML author for <meta> name Attribute on HTML <meta> Tag

keywords Specifies a comma-separated list of keywords - relevant to the page (Informs search engines what the page is about). Example:
<meta name="keywords" content="HTML, meta tag, tag reference">
index.html
Example: HTML
 <meta name="keywords" content="HTML, meta tag, tag reference"> 

How to add HTML viewport for <meta> name Attribute on HTML <meta> Tag

viewport Controls the viewport (the user's visible area of a web page).

The viewport varies with the device, and will be smaller on a mobile phone than on a computer screen.

You should include the following <meta> viewport element in all your web pages:

<meta name="viewport" content="width=device-width, initial-scale=1.0">

A <meta> viewport element gives the browser instructions on how to control the page's dimensions and scaling.

The width=device-width part sets the width of the page to follow the screen-width of the device (which will vary depending on the device).

The initial-scale=1.0 part sets the initial zoom level when the page is first loaded by the browser.

Here is an example of a web page without the viewport meta tag, and the same web page with the viewport meta tag:

Tip: If you are browsing this page with a phone or a tablet, you can click on the two links below to see the difference.

index.html
Example: HTML
 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 

Basic HTML Meta Tags

Here are some important html meta tag.

index.html
Example: HTML
<meta charset='UTF-8'>
<meta name='keywords' content='your, tags'>
<meta name='description' content='150 words'>
<meta name='subject' content='your website's subject'>
<meta name='copyright' content='company name'>
<meta name='language' content='ES'>
<meta name='robots' content='index,follow'>
<meta name='revised' content='Sunday, July 18th, 2010, 5:15 pm'>
<meta name='abstract' content=''>
<meta name='topic' content=''>
<meta name='summary' content=''>
<meta name='Classification' content='Business'>
<meta name='author' content='name, [email protected]'>
<meta name='designer' content=''>
<meta name='reply-to' content='[email protected]'>
<meta name='owner' content=''>
<meta name='url' content='http://www.websiteaddrress.com'>
<meta name='identifier-URL' content='http://www.websiteaddress.com'>
<meta name='directory' content='submission'>
<meta name='pagename' content='jQuery Tools, Tutorials and Resources - O'Reilly Media'>
<meta name='category' content=''>
<meta name='coverage' content='Worldwide'>
<meta name='distribution' content='Global'>
<meta name='rating' content='General'>
<meta name='revisit-after' content='7 days'>
<meta name='subtitle' content='This is my subtitle'>
<meta name='target' content='all'>
<meta name='HandheldFriendly' content='True'>
<meta name='MobileOptimized' content='320'>
<meta name='date' content='Sep. 27, 2010'>
<meta name='search_date' content='2010-09-27'>
<meta name='DC.title' content='Unstoppable Robot Ninja'>
<meta name='ResourceLoaderDynamicStyles' content=''>
<meta name='medium' content='blog'>
<meta name='syndication-source' content='https://mashable.com/2008/12/24/free-brand-monitoring-tools/'>
<meta name='original-source' content='https://mashable.com/2008/12/24/free-brand-monitoring-tools/'>
<meta name='verify-v1' content='dV1r/ZJJdDEI++fKJ6iDEl6o+TMNtSu0kv18ONeqM0I='>
<meta name='y_key' content='1e39c508e0d87750'>
<meta name='pageKey' content='guest-home'>
<meta itemprop='name' content='jQTouch'>
<meta http-equiv='Expires' content='0'>
<meta http-equiv='Pragma' content='no-cache'>
<meta http-equiv='Cache-Control' content='no-cache'>
<meta http-equiv='imagetoolbar' content='no'>
<meta http-equiv='x-dns-prefetch-control' content='off'>

OpenGraph Meta Tags

index.html
Example: HTML
<meta name='og:title' content='The Rock'>
<meta name='og:type' content='movie'>
<meta name='og:url' content='http://www.imdb.com/title/tt0117500/'>
<meta name='og:image' content='http://ia.media-imdb.com/rock.jpg'>
<meta name='og:site_name' content='IMDb'>
<meta name='og:description' content='A group of U.S. Marines, under command of...'>

<meta name='fb:page_id' content='43929265776'>
<meta name='application-name' content='foursquare'>
<meta name='og:email' content='[email protected]'>
<meta name='og:phone_number' content='650-123-4567'>
<meta name='og:fax_number' content='+1-415-123-4567'>

<meta name='og:latitude' content='37.416343'>
<meta name='og:longitude' content='-122.153013'>
<meta name='og:street-address' content='1601 S California Ave'>
<meta name='og:locality' content='Palo Alto'>
<meta name='og:region' content='CA'>
<meta name='og:postal-code' content='94304'>
<meta name='og:country-name' content='USA'>

<meta property='fb:admins' content='987654321'>
<meta property='og:type' content='game.achievement'>
<meta property='og:points' content='POINTS_FOR_ACHIEVEMENT'>

<meta property='og:video' content='http://example.com/awesome.swf'>
<meta property='og:video:height' content='640'>
<meta property='og:video:width' content='385'>
<meta property='og:video:type' content='application/x-shockwave-flash'>
<meta property='og:video' content='http://example.com/html5.mp4'>
<meta property='og:video:type' content='video/mp4'>
<meta property='og:video' content='http://example.com/fallback.vid'>
<meta property='og:video:type' content='text/html'>

<meta property='og:audio' content='http://example.com/amazing.mp3'>
<meta property='og:audio:title' content='Amazing Song'>
<meta property='og:audio:artist' content='Amazing Band'>
<meta property='og:audio:album' content='Amazing Album'>
<meta property='og:audio:type' content='application/mp3'>

Create Custom Meta Tags

Use custom meta tags to store data that you need in Javascript, instead of hard-coding that data into your Javascript. I store my Google Analytics code in meta tags. Here's some examples:

index.html
Example: HTML
<meta name='google-analytics' content='1-AHFKALJ'>
<meta name='disqus' content='abcdefg'>
<meta name='uservoice' content='asdfasdf'>
<meta name='mixpanel' content='asdfasdf'>

Company/Service Meta Tags

See the Example.

index.html
Example: HTML
<meta name='microid' content='mailto+http:sha1:e6058ed7fca4a1921cq91d7f1f3b8736cd3cc1g7'>
<meta name='readability-verification' content='E7aEHvVQpWc8VHDqKvaB2Z58hek2EAv2HuLuegv7'>
<meta name='google-site-verification' content='4SMIedO1X4IkYrYuhEC2VuovdQM36Xxb0btUjElqQyg'>
<meta name='ICBM' content='40.746990, -73.980537'>
<meta name='generator' content='WordPress 3.3.1'>
<meta name='norton-safeweb-site-verification' content='tz8iotmk-pkhui406y41y5bfmfxdwmaa4a-yc0hm6r0fga7s6j0j27qmgqkmc7oovihzghbzhbdjk-uiyrz438nxsjdbj3fggwgl8oq2nf4ko8gi7j4z7t78kegbidl4'>

Apple Meta Tags

See the Example.

index.html
Example: HTML
<meta name="apple-mobile-web-app-title" content="My App"> <!-- New in iOS6 -->
<meta name='apple-mobile-web-app-capable' content='yes'>
<meta name='apple-touch-fullscreen' content='yes'>
<meta name='apple-mobile-web-app-status-bar-style' content='black'>
<meta name='format-detection' content='telephone=no'>
<meta name='viewport' content='width=device-width; content='width = 320; initial-scale=1.0; maximum-scale=1.0; user-scalable=yes; target-densitydpi=160dpi'>

<link href='/apple-touch-icon.png' rel='apple-touch-icon' type='image/png'>
<link href='touch-icon-ipad.png' rel='apple-touch-icon' sizes='72x72'>
<link href='touch-icon-iphone4.png' rel='apple-touch-icon' sizes='114x114'>
<link href='/startup.png' rel='apple-touch-startup-image'>

<link href='http://github.com/images/touch-icon-iphone4.png' sizes='114x114' rel='apple-touch-icon-precomposed'>
<link href='http://github.com/images/touch-icon-ipad.png' sizes='72x72' rel='apple-touch-icon-precomposed'>
<link href='http://github.com/images/apple-touch-icon-57x57.png' sizes='57x57' rel='apple-touch-icon-precomposed'>

Internet Explorer Meta Tags

See the Example.

index.html
Example: HTML
<meta http-equiv='Page-Enter' content='RevealTrans(Duration=2.0,Transition=2)'>
<meta http-equiv='Page-Exit' content='RevealTrans(Duration=3.0,Transition=12)'>
<meta name='mssmarttagspreventparsing' content='true'>
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible"/>
<meta name='msapplication-starturl' content='http://blog.reybango.com/about/'>
<meta name='msapplication-window' content='width=800;height=600'>
<meta name='msapplication-navbutton-color' content='red'>
<meta name='application-name' content='Rey Bango Front-end Developer'>
<meta name='msapplication-tooltip' content='Launch Rey Bango's Blog'>
<meta name='msapplication-task' content='name=About;action-uri=/about/;icon-uri=/images/about.ico'>
<meta name='msapplication-task' content='name=The Big List;action-uri=/the-big-list-of-javascript-css-and-html-development-tools-libraries-projects-and-books/;icon-uri=/images/list_links.ico'>
<meta name='msapplication-task' content='name=jQuery Posts;action-uri=/category/jquery/;icon-uri=/images/jquery.ico'>
<meta name='msapplication-task' content='name=Start Developing;action-uri=/category/javascript/;icon-uri=/images/script.ico'>
<meta name='msvalidate.01' content='6E3AD52DC176461A3C81DD6E98003BC9'>
<meta http-equiv='cleartype' content='on'>

Google Meta Tags

See the Example.

index.html
Example: HTML
<meta name="news_keywords" content="World Cup, Brazil 2014, Spain vs Netherlands, soccer, football">

TweetMeme Meta Tags

See the Example.

index.html
Example: HTML
<meta name='tweetmeme-title' content='Retweet Button Explained'>

Blog Catalog Meta Tags

See the Example.

index.html
Example: HTML
<meta name='blogcatalog'>

Rails Meta Tags

See the Example.

index.html
Example: HTML
<meta name='csrf-param' content='authenticity_token'>
<meta name='csrf-token' content='/bZVwvomkAnwAI1Qd37lFeewvpOIiackk9121fFwWwc='>

HTML Link Tags

See the Example.

index.html
Example: HTML
<link rel='alternate' type='application/rss+xml' title='RSS' href='http://feeds.feedburner.com/martini'>
<link rel='alternate' type='application/atom+xml' title='Atom 0.3' href='https://example.com/feed.atom'>
<link rel='shortcut icon' type='image/ico' href='/favicon.ico'>
<link rel='fluid-icon' type='image/png' href='/fluid-icon.png'>
<link rel='me' type='text/html' href='http://google.com/profiles/thenextweb'>
<link rel='shortlink' href='http://blog.unto.net/?p=353'>
<link rel='archives' title='May 2003' href='http://blog.unto.net/2003/05/'>
<link rel='index' title='DeWitt Clinton' href='http://blog.unto.net/'>
<link rel='start' title='Pattern Recognition 1' href='http://blog.unto.net/photos/pattern_recognition_1_about/'>
<link rel='bookmark'title='Styleguide' href='http://paulrobertlloyd.com/about/styleguide/'>
<link rel='search' href='/search.xml' type='application/opensearchdescription+xml' title='Viatropos'>

<link rel='self' type='application/atom+xml' href='http://www.syfyportal.com/atomFeed.php?page=3'>
<link rel='first' href='http://www.syfyportal.com/atomFeed.php'>
<link rel='next' href='http://www.syfyportal.com/atomFeed.php?page=4'>
<link rel='previous' href='http://www.syfyportal.com/atomFeed.php?page=2'>
<link rel='last' href='http://www.syfyportal.com/atomFeed.php?page=147'>

<link rel='canonical' href='http://smallbiztrends.com/2010/06/9-things-to-do-before-entering-social-media.html'>
<link rel='EditURI' type='application/rsd+xml' title='RSD' href='http://smallbiztrends.com/xmlrpc.php?rsd'>
<link rel='pingback' href='http://smallbiztrends.com/xmlrpc.php'>
<link rel='stylesheet' media='only screen and (max-device-width: 480px)' href='http://wordpress.org/style/iphone.css' type='text/css'>
<link rel='wlwmanifest' href='http://www.example.com/wp-includes/wlwmanifest.xml' type='application/wlwmanifest+xml'>

Other Resources Meta Tag

See the Example.

index.html
Example: HTML

- [HTML5 Boilerplate explanations and suggestions of header tags](http://html5boilerplate.com/docs/head-Tips/)
- [Dublic Core Meta Tags](http://www.seoconsultants.com/meta-tags/dublin/)
- [Apple Meta Tags](http://developer.apple.com/safari/library/documentation/appleapplications/reference/safarihtmlref/articles/metatags.html)
- [OpenGraph Meta Tags](http://opengraphprotocol.org/)
- [Link Tag Meaning](http://intertwingly.net/wiki/pie/LinkTagMeaning)
- [Google Chrome HTML5 Tags](http://www.html5rocks.com/)


# Tips-72) What is HTML <meter> Tag

The <meter> HTML element represents either a scalar value within a known range or a fractional value.

Use the meter element to display a scalar value within a given range (a gauge):

Definition and Usage

The <meter> tag defines a scalar measurement within a known range, or a fractional value. This is also known as a gauge.

Examples: Disk usage, the relevance of a query result, etc.

Note: The <meter> tag should not be used to indicate progress (as in a progress bar). For progress bars, use the <progress> tag.

Tip: Always add the <label> tag for best accessibility practices!

Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Attributes

Attribute Value Description
form form_id Specifies which form the <meter> element belongs to
high number Specifies the range that is considered to be a high value
low number Specifies the range that is considered to be a low value
max number Specifies the maximum value of the range
min number Specifies the minimum value of the range. Default value is 0
optimum number Specifies what value is the optimal value for the gauge
value number Required. Specifies the current value of the gauge

Global Attributes

The <meter> tag also supports the Global Attributes in HTML.


Event Attributes

The <meter> tag also supports the Event Attributes in HTML.

How to create HTML <meter> Tag

Use the meter element to display a scalar value within a given range (a gauge):

index.html
Example: HTML
 <label for="disk_c">Disk usage C:</label>
<meter id="disk_c" value="2" min="0" max="10">2 out of 10</meter><br>

<label for="disk_d">Disk usage D:</label>
<meter id="disk_d" value="0.6">60%</meter> 

Output should be:

How to create HTML <meter> Tag

What is HTML <meter> form Attribute

Definition and Usage

The form attribute specifies the form the <meter> tag belongs to.

The value of this attribute must be equal to the id attribute of a <meter> element in the same document. 


Browser Support

Syntax

<meter form="form_id">

Attribute Values

Value Description
form_id Specifies the form element the <meter> element belongs to. The value of this attribute must be the id attribute of a <form> element in the same document.

How to create HTML <meter> form Attribute

A <meter> element located outside a form (but still a part of the form):

index.html
Example: HTML
 <form action="/action_page.php" method="get" id="form1">
  First name: <input type="text" name="fname"><br>
  <input type="submit" value="Submit">
</form>

<p><label for="anna">Anna's score:</label>
<meter id="anna" form="form1" name="anna" min="0" low="40" high="90" max="100" value="95"></meter></p> 

Output should be:

How to create HTML <meter> form Attribute

What is HTML <meter> high Attribute

Definition and Usage

The high attribute specifies the range where the gauge's value is considered to be a high value.

The high attribute value must be less than the max attribute value, and it also must be greater than the low and min attribute values.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<meter high="number">

Attribute Values

Value Description
number Specifies a floating point number that is considered to be a high value

How to create HTML <meter> high Attribute

A gauge with a current value and min, max, high, and low segments:

index.html
Example: HTML
 <p><label for="anna">Anna's score:</label>
<meter id="anna" min="0" low="40" high="90" max="100" value="95"></meter></p>

<p><label for="peter">Peter's score:</label>
<meter id="peter" min="0" low="40" high="90" max="100" value="65"></meter></p>

<p><label for="linda">Linda's score:</label>
<meter id="linda" min="0" low="40" high="90" max="100" value="35"></meter></p> 

Output should be:

How to create HTML <meter> high Attribute

What is HTML <meter> low Attribute

Definition and Usage

The low attribute specifies the range where the gauge's value is considered to be a low value.

The low attribute value must be greater than the min attribute value, and it also must be less than the high and max attribute values.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<meter low="number">

Attribute Values

Value Description
number Specifies a floating point number that is considered to be a low value

How to create HTML <meter> low Attribute

A gauge with a current value and min, max, high, and low segments:

index.html
Example: HTML
<p><label for="anna">Anna's score:</label>
<meter id="anna" min="0" low="40" high="90" max="100" value="95"></meter></p>

<p><label for="peter">Peter's score:</label>
<meter id="peter" min="0" low="40" high="90" max="100" value="65"></meter></p>

<p><label for="linda">Linda's score:</label>
<meter id="linda" min="0" low="40" high="90" max="100" value="35"></meter></p>

Output should be:

How to create HTML <meter> low Attribute

What is HTML <meter> max Attribute

Definition and Usage

The max attribute specifies the upper bound of the gauge.

The max attribute value must be greater than the min attribute value.

If unspecified, the default value is 1.

Tip: The max attribute, together with the min attribute, specifies the full range of the gauge.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<meter max="number">

Attribute Values

Value Description
number Specifies a floating point number that is the maximum value of the gauge. Default value is "1"

How to create HTML <meter> max Attribute

A gauge with a current value and min, max, high, and low segments:

index.html
Example: HTML
 <p><label for="anna">Anna's score:</label>
<meter id="anna" min="0" low="40" high="90" max="100" value="95"></meter></p>

<p><label for="peter">Peter's score:</label>
<meter id="peter" min="0" low="40" high="90" max="100" value="65"></meter></p>

<p><label for="linda">Linda's score:</label>
<meter id="linda" min="0" low="40" high="90" max="100" value="35"></meter></p> 

Output should be:

How to create HTML <meter> max Attribute

What is HTML <meter> min Attribute

Definition and Usage

The min attribute specifies the lower bound of the gauge.

The min attribute value must be less than the max attribute value.

If unspecified, the default value is 0.

Tip: The min attribute, together with the max attribute, specifies the full range of the gauge.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<meter min="number">

Attribute Values

Value Description
number Specifies a floating point number that is the minimum value of the gauge. Default value is 0

How to create HTML <meter> min Attribute

A gauge with a current value and min, max, high, and low segments:

index.html
Example: HTML
 <p><label for="anna">Anna's score:</label>
<meter id="anna" min="0" low="40" high="90" max="100" value="95"></meter></p>

<p><label for="peter">Peter's score:</label>
<meter id="peter" min="0" low="40" high="90" max="100" value="65"></meter></p>

<p><label for="linda">Linda's score:</label>
<meter id="linda" min="0" low="40" high="90" max="100" value="35"></meter></p> 

Output should be:

How to create HTML <meter> min Attribute

What is HTML <meter> optimum Attribute

Definition and Usage

The optimum attribute specifies the range where the gauge's value is considered to be an optimal value.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<meter optimum="number">

Attribute Values

Value Description
number Specifies a floating point number that is the optimal value of the gauge

How to create HTML <meter> optimum Attribute

A gauge with an optimal value of 0.5:

index.html
Example: HTML
 <p><label for="yinyang">Yin Yang:</label>
<meter id="yinyang" value="0.3" high="0.9" low="0.1" optimum="0.5"></meter></p> 

Output should be:

How to create HTML <meter> optimum Attribute

What is HTML <meter> value Attribute

Definition and Usage

The required value attribute specifies the current, or "measured", value of the gauge.

The value attribute must be between the min and max attribute values.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<meter value="number">

Attribute Values

Value Description
number Required. Specifies a floating point number that is the current value of the gauge

How to create HTML <meter> value Attribute

A gauge with a current value and min, max, high, and low segments:

index.html
Example: HTML
 <p><label for="anna">Anna's score:</label>
<meter id="anna" min="0" low="40" high="90" max="100" value="95"></meter></p>

<p><label for="peter">Peter's score:</label>
<meter id="peter" min="0" low="40" high="90" max="100" value="65"></meter></p>

<p><label for="linda">Linda's score:</label>
<meter id="linda" min="0" low="40" high="90" max="100" value="35"></meter></p> 

Output should be:

How to create HTML <meter> value Attribute

# Tips-73) What is HTML <nav> Tag

Definition and Usage

The <nav> tag defines a set of navigation links.

Notice that NOT all links of a document should be inside a <nav> element. The <nav> element is intended only for major blocks of navigation links.

Browsers, such as screen readers for disabled users, can use this element to determine whether to omit the initial rendering of this content.


Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Global Attributes

The <nav> tag also supports the Global Attributes in HTML.


Event Attributes

The <nav> tag also supports the Event Attributes in HTML

 

The <nav> HTML element represents a section of a page whose purpose is to provide navigation links, either within the current document or to other documents. Common examples of navigation sections are menus, tables of contents, and indexes.

 

How to create HTML <nav> Tag

A set of navigation links:

index.html
Example: HTML
 <nav>
  <a href="/html/">HTML</a> |
  <a href="/css/">CSS</a> |
  <a href="/js/">JavaScript</a> |
  <a href="/python/">Python</a>
</nav> 

Output should be:

How to create HTML <nav> Tag

How to set Default CSS Settings on HTML <nav> Tag

Most browsers will display the <nav> element with the following default values:

index.html
Example: HTML
<!DOCTYPE html>
<html>
<style>
nav {
  display: block;
}
</style>
<body>

<h1>The nav element</h1>

<p>The nav element defines a set of navigation links:</p>

<nav>
<a href="/html/">HTML</a> |
<a href="/css/">CSS</a> |
<a href="/js/">JavaScript</a> |
<a href="/python/">Python</a>
</nav>

</body>
</html>

Output should be:

How to set Default CSS Settings on HTML <nav> Tag

# Tips-74) What is HTML <noframes> Tag

The

HTML element provides content to be presented in browsers that don't support (or have disabled support for) the element. Although most commonly-used browsers support frames, there are exceptions, including certain special-use browsers including some mobile browsers, as well as text-mode browsers.

Not Supported in HTML5.

The

tag was used in HTML 4 to act as a fallback tag for browsers that did not support frames.


What to Use Instead of HTML <noframes> Tag?

Use the <iframe> tag to embed another document within the current HTML document:
index.html
Example: HTML
 <iframe src="https://horje.com"></iframe> 

Output should be:

What to Use Instead of HTML <noframes> Tag?

# Tips-75) What is HTML <noscript> Tag

The HTML element defines a section of HTML to be inserted if a script type on the page is unsupported or if scripting is currently turned off in the browser.

Definition and Usage

The <noscript> tag defines an alternate content to be displayed to users that have disabled scripts in their browser or have a browser that doesn't support script.

The <noscript> element can be used in both <head> and <body>. When used inside <head>, the <noscript> element could only contain <link>, <style>, and <meta> elements.


Browser Support

Global Attributes

The <noscript> tag also supports the Global Attributes in HTML.


Related Pages

HTML tutorial: HTML Scripts


Default CSS Settings

None.

How to create HTML <noscript> Tag

Use of the <noscript> tag:
index.html
Example: HTML
 <script>
document.write("Hello World!")
</script>
<noscript>Your browser does not support JavaScript!</noscript> 

Output should be:

How to create HTML <noscript> Tag

# Tips-76) What is HTML <object> Tag

The HTML element represents an external resource, which can be treated as an image, a nested browsing context, or a resource to be handled by a plugin.

Definition and Usage

The <object> tag defines a container for an external resource.

The external resource can be a web page, a picture, a media player, or a plug-in application.

To embed a picture, it is better to use the <img> tag.

To embed HTML, it is better to use the <iframe> tag.

To embed video or audio, it is better to use the <video> and <audio> tags.


Browser Support

Plug-ins

The <object> tag was originally designed to embed browser Plug-ins.

Plug-ins are computer programs that extend the standard functionality of the browser.

Plug-ins have been used for many different purposes:

  • Run Java applets
  • Run ActiveX controls
  • Display Flash movies
  • Display maps
  • Scan for viruses
  • Verify a bank id

Warning !

Most browsers no longer support Java Applets and Plug-ins.

ActiveX controls are no longer supported in any browser.

The support for Shockwave Flash has also been turned off in modern browsers.


Attributes

Attribute Value Description
data URL Specifies the URL of the resource to be used by the object
form form_id Specifies which form the object belongs to
height pixels Specifies the height of the object
name name Specifies a name for the object
type media_type Specifies the media type of data specified in the data attribute
typemustmatch true/false Specifies whether the type attribute and the actual content of the resource must match to be displayed
usemap #mapname Specifies the name of a client-side image map to be used with the object
width pixels Specifies the width of the object

Global Attributes

The <object> tag also supports the Global Attributes in HTML.


Event Attributes

The <object> tag also supports the Event Attributes in HTML.

HTML DOM reference: Object Object

How to create HTML <object> Tag

<object type="application/pdf" data="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/object" width="250" height="200"></object>

Output should be:

How to create HTML <object> Tag

How to create An embedded image on HTML <object> Tag

Add an image into HTML <object> Tag

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The object element</h1>

<object data="https://horje.com/avatar.png" width="300" height="200"></object>
 
</body>
</html>

Output should be:

How to create An embedded image on HTML <object> Tag

How to create An embedded HTML page on HTML <object> Tag

See the Example

index.html
Example: HTML
 <object data="https://horje.com/" width="500" height="200"></object> 

Output should be:

How to create An embedded HTML page on HTML <object> Tag

How to create An embedded video on HTML <object> Tag

See the Example.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<object data="https://file-examples.com/storage/fe58a1f07d66f447a9512f1/2017/04/file_example_MP4_480_1_5MG.mp4" width="400" height="300"></object>
 
</body>
</html>

Output should be:

How to create An embedded video on HTML <object> Tag

How to set Default CSS Settings on HTML <object> Tag

Most browsers will display the <object> element with the following default values.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<style>
object:focus {
  outline: none;
}
</style>
<body>

<object data="https://file-examples.com/storage/fe58a1f07d66f447a9512f1/2017/04/file_example_MP4_480_1_5MG.mp4" width="400" height="300"></object>
 
</body>
</html>

Output should be:

How to set Default CSS Settings on HTML <object> Tag

What is HTML <object> data Attribute

HTML is designed with extensibility in mind for data that should be associated with a particular element but need not have any defined meaning. data-* attributes allow us to store extra information on standard, semantic HTML elements without other hacks such as non-standard attributes, or extra properties on DOM.

Definition and Usage

The data attribute specifies the URL of the resource to be used by the object.


Browser Support

Syntax

<object data="URL">

Attribute Values

Value Description
URL Specifies the URL of the resource to be used by the object.

Possible values:

  • An absolute URL - points to data on another web site (like href="http://www.example.com/images/pic_trulli.jpg")
  • A relative URL - points to data within a web site (like href="pic_trulli.jpg")

How to create HTML <object> data Attribute

How to use the <object> element to embed an image.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The object element</h1>

<object data="https://horje.com/avatar.png" width="300" height="200"></object>
 
</body>
</html>

Output should be:

How to create HTML <object> data Attribute

What is HTML <object> form Attribute

The HTML <object> form Attribute is used to specify the one or more forms that the <object> Element.

Definition and Usage

The form attribute specifies the form the object belongs to.

The value of this attribute must be equal to the id attribute of a <form> element in the same document.


Browser Support

Syntax

<object form="form_id">

Attribute Values

Value Description
form_id Specifies the <form> element the <object> element belongs to. The value of this attribute must be the id attribute of a <form> element in the same document.

How to create HTML <object> form Attribute

An <object> element located outside a form (but still a part of the form).

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The object form attribute</h1>

<form action="/action_page.php" id="form1">
First name: <input type="text" name="fname"><br>
<input type="submit" value="Submit">
</form>

<object data="https://horje.com/avatar.png" width="300" height="200"></object>

<p><b>Note:</b> The form attribute is not supported in any of the major browsers.</p>

</body>
</html>

Output should be:

How to create HTML <object> form Attribute

What is HTML <object> height Attribute

The height attribute on an <object> tag sets the height of the object element.

The height is specified in pixels - without the ‘px‘ unit.

Definition and Usage

The height attribute specifies the height of the object, in pixels.


Browser Support

Syntax

<object height="pixels">

Attribute Values

Value Description
pixels The height of the object, in pixels (i.e. height="100")

How to add HTML <object> height Attribute

An embedded image with a height of 300 pixels and a width of 200 pixels:

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The object element</h1>

<object data="https://horje.com/avatar.png" width="300" height="200"></object>
 
</body>
</html>

Output should be:

How to add HTML <object> height Attribute

What is HTML <object> name Attribute

The HTML <object> name Attribute is used to specify the name of the embedded file. This attribute is also used as a reference for an object element in the Javascript.

Definition and Usage

The name attribute specifies the name of an <object> element.

The name attribute is used for referencing an <object> element in JavaScript (an alternative, is to reference it by using its id attribute).


Browser Support

Syntax

<object name="name">

Attribute Values

Value Description
name The name of the <object> element

How to add HTML <object> name Attribute

An <object> element with a name attribute.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The object name attribute</h1>

<object data="https://horje.com/avatar.png" name="obj1" width="300" height="200">
</object>
 
</body>
</html>

Output should be:

How to add HTML <object> name Attribute

What is HTML <object> type Attribute

The type attribute on an <object> tag specifies the media type of the embedded resource.

A media type indicates the format and nature of the resource.

Definition and Usage

The type attribute specifies the Internet media type of the object.


Browser Support

Syntax

<object type="media_type">

Attribute Values

Value Description
media_type The Internet media type of the embedded content.
Look at IANA Media Types for a complete list of standard media types.

How to add HTML <object> type Attribute

An <object> element with a specified media type.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The object type attribute</h1>

<object data="https://horje.com/avatar.png" type="image/jpg" width="500" height="300">
</object>
 
</body>
</html>

Output should be:

How to add HTML <object> type Attribute

What is <object> typemustmatch Attribute

This attribute is used in order to to make it safer for authors to embed untrusted resources where they expect a certain content type. The attribute specifies that the resource specified by the data attribute is only to be used if the value of the type attribute and the Content-Type of the aforementioned resource match.

The typemustmatch attribute must only be used when both the type and data is also being used.

The typemustmatch is a boolean attribute. If the attribute is present, its value must either be the empty string or a value that is an ASCII case-insensitive match for the attribute's canonical name, with no leading or trailing whitespace (i.e. either typemustmatch or typemustmatch="typemustmatch")..

 

typemustmatch true/false Specifies whether the type attribute and the actual content of the resource must match to be displayed

How to add <object> typemustmatch Attribute

See the example.

index.html
Example: HTML
<object data="https://cdn.bitdegree.org/learn/giphy%20(1).gif?raw=true" type="image/gif" width="550" height="450" typemustmatch></object>

Output should be:

How to add <object> typemustmatch Attribute

What is HTML <object> usemap Attribute

The useMap property on the HTMLImageElement interface reflects the value of the HTML usemap attribute, which is a string providing the name of the client-side image map to apply to the image.

Definition and Usage

The usemap attribute specifies the name of an image map to use with the object.

An image map is an image with clickable areas.

The usemap attribute is associated with a <map> element's name attribute, and creates a relationship between the object and the map.


Browser Support

Syntax

<object usemap="#mapname">

Attribute Values

Value Description
#mapname A hash character ("#") plus the name of the map element to use

How to add HTML <object> usemap Attribute

An <object> element using an image map:

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The object usemap attribute</h1>

<object data="https://horje.com/uploads/demo/2024-09-29-14-25-40-screenshot_2024-09-29_at_20-23-53_w3schools_online_html_editor.png" width="145" height="126" usemap="#planetmap"></object>

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="sun.htm">
  <area shape="circle" coords="90,58,3" alt="Mercury" href="mercur.htm">
  <area shape="circle" coords="124,58,8" alt="Venus" href="venus.htm">
</map>

<p><b>Note:</b> The usemap attribute of the object element is not supported in Chrome, 
Edge, Safari, and Opera.</p>
 
</body>
</html>

Output should be:

How to add HTML <object> usemap Attribute

What is HTML <object> width Attribute

The HTML <object> width attribute is used to specify the horizontal dimension of the embedded object, defining the width of the displayed content within the webpage.

Definition and Usage

The width attribute specifies the width of the object, in pixels.


Browser Support

Syntax

<object width="pixels">

Attribute Values

Value Description
pixels The width of the object, in pixels (i.e. width="100")

How to add HTML <object> width Attribute

An embedded image with a height of 300 pixels and a width of 200 pixels.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The object element</h1>

<object data="https://horje.com/avatar.png" width="300" height="200"></object>
 
</body>
</html>

Output should be:

How to add HTML <object> width Attribute

# Tips-77) What is HTML <ol> Tag

The <ol> HTML element represents an ordered list of items — typically rendered as a numbered list.

Definition and Usage

The <ol> tag defines an ordered list. An ordered list can be numerical or alphabetical.

The <li> tag is used to define each list item.

Tip: Use CSS to style lists.

Tip: For unordered list, use the <ul> tag. 


Browser Support

Attributes

Attribute Value Description
reversed reversed Specifies that the list order should be reversed (9,8,7...)
start number Specifies the start value of an ordered list
type 1
A
a
I
i
Specifies the kind of marker to use in the list

Global Attributes

The <ol> tag also supports the Global Attributes in HTML.


Event Attributes

The <ol> tag also supports the Event Attributes in HTML.

How to create HTML <ol> Tag

Here are Two different ordered lists (the first list starts at 1, and the second starts at 50).
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The ol element</h1>

<ol>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol>

<ol start="50">
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol>
 
</body>
</html>

Output should be:

How to create HTML <ol> Tag

How to Set different list types (with CSS):

See the Example and Learn More.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>Specify list type with CSS</h1>

<ol style="list-style-type:upper-roman">
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol>

<ol style="list-style-type:lower-alpha">
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol>

</body>
</html>

Output should be:

How to Set different list types (with CSS):

How to Display all the different list types available with CSS

See the Example and Learn More.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<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;}
ol.f {list-style-type: hebrew;}
ol.g {list-style-type: hiragana;}
ol.h {list-style-type: hiragana-iroha;}
ol.i {list-style-type: katakana;}
ol.j {list-style-type: katakana-iroha;}
ol.k {list-style-type: lower-alpha;}
ol.l {list-style-type: lower-greek;}
ol.m {list-style-type: lower-latin;}
ol.n {list-style-type: lower-roman;}
ol.o {list-style-type: upper-alpha;}
ol.p {list-style-type: upper-latin;}
ol.q {list-style-type: upper-roman;}
ol.r {list-style-type: none;}
ol.s {list-style-type: inherit;}
</style>
</head>
<body>

<h1>All the different list types for ol with CSS</h1>

<ol class="a">
  <li>Armenian type</li>
  <li>Tea</li>
  <li>Coca Cola</li>
</ol>

<ol class="b">
  <li>Cjk-ideographic type</li>
  <li>Tea</li>
  <li>Coca Cola</li>
</ol>

<ol class="c">
  <li>Decimal type</li>
  <li>Tea</li>
  <li>Coca Cola</li>
</ol>

<ol class="d">
  <li>Decimal-leading-zero type</li>
  <li>Tea</li>
  <li>Coca Cola</li>
</ol>

<ol class="e">
  <li>Georgian type</li>
  <li>Tea</li>
  <li>Coca Cola</li>
</ol>

<ol class="f">
  <li>Hebrew type</li>
  <li>Tea</li>
  <li>Coca Cola</li>
</ol>

<ol class="g">
  <li>Hiragana type</li>
  <li>Tea</li>
  <li>Coca Cola</li>
</ol>

<ol class="h">
  <li>Hiragana-iroha type</li>
  <li>Tea</li>
  <li>Coca Cola</li>
</ol>

<ol class="i">
  <li>Katakana type</li>
  <li>Tea</li>
  <li>Coca Cola</li>
</ol>

<ol class="j">
  <li>Katakana-iroha type</li>
  <li>Tea</li>
  <li>Coca Cola</li>
</ol>

<ol class="k">
  <li>Lower-alpha type</li>
  <li>Tea</li>
  <li>Coca Cola</li>
</ol>

<ol class="l">
  <li>Lower-greek type</li>
  <li>Tea</li>
  <li>Coca Cola</li>
</ol>

<ol class="m">
  <li>Lower-latin type</li>
  <li>Tea</li>
  <li>Coca Cola</li>
</ol>

<ol class="n">
  <li>Lower-roman type</li>
  <li>Tea</li>
  <li>Coca Cola</li>
</ol>

<ol class="o">
  <li>Upper-alpha type</li>
  <li>Tea</li>
  <li>Coca Cola</li>
</ol>

<ol class="p">
  <li>Upper-latin type</li>
  <li>Tea</li>
  <li>Coca Cola</li>
</ol>

<ol class="q">
  <li>Upper-roman type</li>
  <li>Tea</li>
  <li>Coca Cola</li>
</ol>

<ol class="r">
  <li>None type</li>
  <li>Tea</li>
  <li>Coca Cola</li>
</ol>

<ol class="s">
  <li>inherit type</li>
  <li>Tea</li>
  <li>Coca Cola</li>
</ol>

</body>
</html>

Output should be:

How to Display all the different list types available with CSS

How to Reduce and expand line-height in lists (with CSS)

See the Example and Learn More.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>Modify lineheight of lists with CSS</h1>

<p>Reduce line height with CSS:</p>
<ol style="line-height:80%">
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol>

<p>Expand line height with CSS:</p>
<ol style="line-height:180%">
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol>

</body>
</html>

Output should be:

How to Reduce and expand line-height in lists (with CSS)

How to Nest an unordered list inside an ordered list

See the Example and Learn more.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>An unordered list inside an ordered list</h1>

<ol>
  <li>Coffee</li>
  <li>Tea
    <ul>
      <li>Black tea</li>
      <li>Green tea</li>
    </ul>
  </li>
  <li>Milk</li>
</ol>

</body>
</html>

Output should be:

How to Nest an unordered list inside an ordered list

How to set Default CSS Settings on HTML <ol> Tag

Most browsers will display the <ol> element with the following default values.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
ol {
  display: block;
  list-style-type: decimal;
  margin-top: 1em;
  margin-bottom: 1em;
  margin-left: 0;
  margin-right: 0;
  padding-left: 40px;
}
</style>
</head>
<body>

<p>An ol element is displayed like this:</p>

<ol>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol>

<p>Change the default CSS settings to see the effect.</p>
 
</body>
</html>

Output should be:

How to set Default CSS Settings on HTML <ol> Tag

What is HTML <ol> reversed Attribute

Definition and Usage

The reversed attribute is a boolean attribute.

When present, it specifies that the list order should be descending (9,8,7...), instead of ascending (1, 2, 3...).


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<ol reversed>

How to add HTML <ol> reversed Attribute

Descending list order.

index.html
Example: HTML
 <ol reversed>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol> 

Output should be:

How to add HTML <ol> reversed Attribute

What is HTML <ol> start Attribute

Definition and Usage

The start attribute specifies the start value of the first list item in an ordered list.

This value is always an integer, even when the numbering type is letters or romans. E.g., to start counting list items from the letter "c" or the roman number "iii", use start="3".


Browser Support

Syntax

<ol start="number">

Attribute Values

Value Description
number Specifies the start value of the first list item in the ordered list

How to add HTML <ol> start Attribute

An ordered list starting at "50"

index.html
Example: HTML
 <ol start="50">
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol> 

Output should be:

How to add HTML <ol> start Attribute

What is HTML <ol> type Attribute

Definition and Usage

The type attribute specifies the kind of marker to use in the list (letters or numbers).

Tip: The CSS list-style-type property offers more types than the type attribute (see example below).


Browser Support

Syntax

<ol type="1|a|A|i|I">

Attribute Values

Value Description
1 Default. Decimal numbers (1, 2, 3, 4)
a Alphabetically ordered list, lowercase (a, b, c, d)
A Alphabetically ordered list, uppercase (A, B, C, D)
i Roman numbers, lowercase (i, ii, iii, iv)
I Roman numbers, uppercase (I, II, III, IV)

How to add HTML <ol> type Attribute

An ordered list with uppercase roman numbers.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The ol type attribute</h1>

<ol type="I">
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol>

</body>
</html>

Output should be:

How to add HTML <ol> type Attribute

How to Display all the different list types available with CSS on HTML <ol> type Attribute

All the different list types for ol with CSS.

index.html
Example: HTML
<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;}
ol.f {list-style-type: hebrew;}
ol.g {list-style-type: hiragana;}
ol.h {list-style-type: hiragana-iroha;}
ol.i {list-style-type: katakana;}
ol.j {list-style-type: katakana-iroha;}
ol.k {list-style-type: lower-alpha;}
ol.l {list-style-type: lower-greek;}
ol.m {list-style-type: lower-latin;}
ol.n {list-style-type: lower-roman;}
ol.o {list-style-type: upper-alpha;}
ol.p {list-style-type: upper-latin;}
ol.q {list-style-type: upper-roman;}
ol.r {list-style-type: none;}
ol.s {list-style-type: inherit;}
</style>

Output should be:

How to Display all the different list types available with CSS on HTML <ol> type Attribute

# Tips-78) What is HTML <optgroup> Tag

The <optgroup> HTML element creates a grouping of options within a <select> element.

Definition and Usage

The <optgroup> tag is used to group related options in a <select> element (drop-down list).

If you have a long list of options, groups of related options are easier to handle for a user.


Browser Support

Attributes

Attribute Value Description
disabled disabled Specifies that an option-group should be disabled
label text Specifies a label for an option-group

Global Attributes

The <optgroup> tag also supports the Global Attributes in HTML.


Event Attributes

The <optgroup> tag also supports the Event Attributes in HTML.

How to create HTML <optgroup> Tag

Group related options with <optgroup> tags. The optgroup tag is used to group related options in a drop-down list:
index.html
Example: HTML
<form action="/action_page.php">
  <label for="cars">Choose a car:</label>
  <select name="cars" id="cars">
    <optgroup label="Swedish Cars">
      <option value="volvo">Volvo</option>
      <option value="saab">Saab</option>
    </optgroup>
    <optgroup label="German Cars">
      <option value="mercedes">Mercedes</option>
      <option value="audi">Audi</option>
    </optgroup>
  </select>
  <br><br>
  <input type="submit" value="Submit">
</form>

Output should be:

How to create HTML <optgroup> Tag

What is HTML <optgroup> disabled Attribute

The disabled attribute for <optgroup> element in HTML is used to specify that the option-group is disabled. A disabled optgroup is un-clickable and unusable. It is a boolean attribute. 

Definition and Usage

The disabled attribute is a boolean attribute.

When present, it specifies that an option-group should be disabled.

A disabled option-group is unusable and un-clickable.

The disabled attribute can be set to keep a user from selecting the option-group until some other condition has been met (like selecting a checkbox, etc.). Then, a JavaScript is required to remove the disabled value, and make the option-group selectable.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<optgroup disabled>

How to add HTML <optgroup> disabled Attribute

A disabled option-group.

The optgroup disabled attribute

index.html
Example: HTML
<form action="/action_page.php">
  <label for="cars">Choose a car:</label>
  <select name="cars" id="cars">
    <optgroup label="Swedish Cars">
      <option value="volvo">Volvo</option>
      <option value="saab">Saab</option>
    </optgroup>
    <optgroup label="German Cars" disabled>
      <option value="mercedes">Mercedes</option>
      <option value="audi">Audi</option>
    </optgroup>
  </select>
  <br><br>
  <input type="submit" value="Submit">
</form>

Output should be:

How to add HTML <optgroup> disabled Attribute

What is HTML <optgroup> label Attribute

Definition and Usage

The label attribute specifies a label for an option-group.


Browser Support

Syntax

<optgroup label="text">

Attribute Values

Value Description
text Specifies a label/description for the option-group

How to add HTML <optgroup> label Attribute

Two option-groups with labels.

index.html
Example: HTML
<form action="/action_page.php">
  <label for="cars">Choose a car:</label>
  <select name="cars" id="cars">
    <optgroup label="Swedish Cars">
      <option value="volvo">Volvo</option>
      <option value="saab">Saab</option>
    </optgroup>
    <optgroup label="German Cars">
      <option value="mercedes">Mercedes</option>
      <option value="audi">Audi</option>
    </optgroup>
  </select>
  <br><br>
  <input type="submit" value="Submit">
</form>

Output should be:

How to add HTML <optgroup> label Attribute

# Tips-79) What is HTML <option> Tag

The <option> HTML element is used to define an item contained in a <select>, an <optgroup>, or a <datalist> element. As such, <option> can represent menu items in popups and other lists of items in an HTML document.

Definition and Usage

The <option> tag defines an option in a select list.

<option> elements go inside a <select>, <optgroup>, or <datalist> element.

Note: The <option> tag can be used without any attributes, but you usually need the value attribute, which indicates what is sent to the server on form submission.

Tip: If you have a long list of options, you can group related options within the <optgroup> tag. 


Browser Support

Attributes

Attribute Value Description
disabled disabled Specifies that an option should be disabled
label text Specifies a shorter label for an option
selected selected Specifies that an option should be pre-selected when the page loads
value text Specifies the value to be sent to a server

Global Attributes

The <option> tag also supports the Global Attributes in HTML.


Event Attributes

The <option> tag also supports the Event Attributes in HTML.

How to add HTML <option> Tag

A drop-down list with four options.
index.html
Example: HTML
<label for="cars">Choose a car:</label>

<select id="cars">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="opel">Opel</option>
  <option value="audi">Audi</option>
</select>

Output should be:

How to add HTML <option> Tag

How to Use of <option> in a <datalist> element:

Note: The datalist tag is not supported in Safari 12.0 (or earlier).

index.html
Example: HTML
<form action="/action_page.php" method="get">
  <label for="browser">Choose your browser from the list:</label>
  <input list="browsers" name="browser" id="browser">
  <datalist id="browsers">
    <option value="Edge">
    <option value="Firefox">
    <option value="Chrome">
    <option value="Opera">
    <option value="Safari">
  </datalist>
  <input type="submit">
</form>

Output should be:

How to Use of <option> in a <datalist> element:

How to Use of <option> in <optgroup> elements

The optgroup tag is used to group related options in a drop-down list.

index.html
Example: HTML
<form action="/action_page.php">
  <label for="cars">Choose a car:</label>
  <select name="cars" id="cars">
    <optgroup label="Swedish Cars">
      <option value="volvo">Volvo</option>
      <option value="saab">Saab</option>
    </optgroup>
    <optgroup label="German Cars">
      <option value="mercedes">Mercedes</option>
      <option value="audi">Audi</option>
    </optgroup>
  </select>
  <br><br>
  <input type="submit" value="Submit">
</form>

Output should be:

How to Use of <option> in <optgroup> elements

What is HTML <option> disabled Attribute

Definition and Usage

The disabled attribute is a boolean attribute.

When present, it specifies that an option should be disabled.

A disabled option is unusable and un-clickable.

The disabled attribute can be set to keep a user from selecting the option until some other condition has been met (like selecting a checkbox, etc.). Then, a JavaScript is required to remove the disabled value, and make the option selectable.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<option disabled>

How to add HTML <option> disabled Attribute

A drop-down list with one disabled option.

The option disabled attribute.

index.html
Example: HTML
<select id="cars">
  <option value="volvo" disabled>Volvo</option>
  <option value="saab">Saab</option>
  <option value="vw">VW</option>
  <option value="audi">Audi</option>
</select>

Output should be:

How to add HTML <option> disabled Attribute

What is HTML <option> label Attribute

Definition and Usage

The label attribute specifies a shorter version of an option.

The shorter version will be displayed in the drop-down list.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<option label="text">

Attribute Values

Value Description
text A shorter version for the option

What is HTML <option> label Attribute

Use of the label attribute in <option> elements.

Note: The option's label attribute is not supported in Firefox.

index.html
Example: HTML
<select id="cars">
  <option label="Volvo">Volvo (Latin for "I roll")</option>
  <option label="Saab">Saab (Swedish Aeroplane AB)</option>
  <option label="Mercedes">Mercedes (Mercedes-Benz)</option>
  <option label="Audi">Audi (Auto Union Deutschland Ingolstadt)</option>
</select>

Output should be:

What is HTML <option> label Attribute

What is HTML <option> selected Attribute

Definition and Usage

The selected attribute is a boolean attribute.

When present, it specifies that an option should be pre-selected when the page loads.

The pre-selected option will be displayed first in the drop-down list.

Tip: The selected attribute can also be set after the page loads, with a JavaScript.


Browser Support

Syntax

<option selected>

How to add HTML <option> selected Attribute

A drop-down list with a pre-selected option.

 

index.html
Example: HTML
<select id="cars">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="vw">VW</option>
  <option value="audi" selected>Audi</option>
</select>

Output should be:

How to add HTML <option> selected Attribute

What is HTML <option> value Attribute

Definition and Usage

The value attribute specifies the value to be sent to a server when a form is submitted.

The content between the opening <option> and closing </option> tags is what the browsers will display in a drop-down list. However, the value of the value attribute is what will be sent to the server when a form is submitted.

Note: If the value attribute is not specified, the content will be passed as a value instead.


Browser Support

Syntax

<option value="value">

Attribute Values

Value Description
value The value to be sent to the server

How to add HTML <option> value Attribute

A drop-down list inside an HTML form.

index.html
Example: HTML
<form action="/action_page.php">
<label for="cars">Choose a car:</label>

<select id="cars" name="cars">
  <option value="volvo">Volvo XC90</option>
  <option value="saab">Saab 95</option>
  <option value="mercedes">Mercedes SLK</option>
  <option value="audi">Audi TT</option>
</select>
<input type="submit" value="Submit">
</form>

Output should be:

How to add HTML <option> value Attribute

# Tips-80) What is HTML <output> Tag

Definition and Usage

The tag is used to represent the result of a calculation (like one performed by a script).


Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Attributes

Attribute Value Description
for element_id Specifies the relationship between the result of the calculation, and the elements used in the calculation
form form_id Specifies which form the output element belongs to
name name Specifies a name for the output element

Global Attributes

The tag also supports the Global Attributes in HTML.


Event Attributes

The tag also supports the Event Attributes in HTML.

How to add HTML <output> Tag

Perform a calculation and show the result in an <output> element.

index.html
Example: HTML
<form oninput="x.value=parseInt(a.value)+parseInt(b.value)">
<input type="range" id="a" value="50">
+<input type="number" id="b" value="25">
=<output name="x" for="a b"></output>
</form>

Output should be:

How to add HTML <output> Tag

How to set Default CSS Settings on HTML <output> Tag

Most browsers will display the <output> element with the following default values.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<style>
output {
  display: inline;
}
</style>
<body>

<h1>The output element</h1>

<form oninput="x.value=parseInt(a.value)+parseInt(b.value)">
<input type="range" id="a" value="50">
+<input type="number" id="b" value="25">
=<output name="x" for="a b"></output>
</form>

<p><strong>Note:</strong> The output element is not supported in Edge 12 (or earlier).</p>

</body>
</html>

Output should be:

How to set Default CSS Settings on HTML <output> Tag

What is HTML <output> for Attribute

Definition and Usage

The for attribute specifies the relationship between the result of the calculation, and the elements used in the calculation.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<output for="element_id">

Attribute Values

Value Description
element_id Specifies a space separated list of ids of one or more elements that specifies the relationship between the result of the calculation, and the elements used in the calculation

How to add HTML <output> for Attribute

It performs a calculation and show the result in an <output> element.

index.html
Example: HTML
<form oninput="x.value=parseInt(a.value)+parseInt(b.value)">
<input type="range" id="a" value="50">
+<input type="number" id="b" value="25">
=<output name="x" for="a b"></output>
</form>

Output should be:

How to add HTML <output> for Attribute

What is HTML <output> form Attribute

Definition and Usage

The form attribute specifies the form the <output> tag belongs to.

The value of the form attribute must be equal to the id attribute of a <form> element in the same document.


Browser Support

Syntax

<output form="form_id">

Attribute Values

Value Description
form_id Specifies the form element the <output> element belongs to. The value of this attribute must be the id attribute of a <form> element in the same document.

How to add HTML <output> form Attribute

It is An <output> element which is located outside a form (but still a part of the form).

index.html
Example: HTML
<form action="/action_page.php" id="numform" oninput="x.value=parseInt(a.value)+parseInt(b.value)">
<input type="range" id="a" name="a" value="50">
+ <input type="number" id="b" name="b" value="25">
<br><br>
<input type="submit">
</form>

Output should be:

How to add HTML <output> form Attribute

What is HTML <output> name Attribute

Definition and Usage

The name attribute specifies the name of an <output> element.

The name attribute is used to reference form data after it has been submitted, or to reference the element in a JavaScript.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<output name="name">

Attribute Values

Value Description
name Specifies the name of the <output> element

How to create HTML <output> name Attribute

It performs a calculation and show the result in an <output> element.

index.html
Example: HTML
<form oninput="x.value=parseInt(a.value)+parseInt(b.value)">
<input type="range" id="a" value="50">
+<input type="number" id="b" value="25">
=<output name="x" for="a b"></output>
</form>

Output should be:

How to create HTML <output> name Attribute

# Tips-81) What is HTML <p> Tag

The <p> tag makes a blank lines

Definition and Usage

The <p> tag defines a paragraph.

Browsers automatically add a single blank line before and after each <p> element.

Browser Support

Global Attributes

The <p> tag also supports the Global Attributes in HTML.


Event Attributes

The <p> tag also supports the Event Attributes in HTML.

 

How to craete HTML <p> Tag

A Paragraph is marked up as follows.
index.html
Example: HTML
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>

Output should be:

How to craete HTML <p> Tag

How to create an Align text in a paragraph with CSS on HTML <p> Tag

This is some text in a paragraph.

index.html
Example: HTML
<p style="text-align:right">This is some text in a paragraph.</p>

Output should be:

How to create an Align text in a paragraph with CSS on HTML <p> Tag

How to create Style paragraphs with CSS on HTML <p> Tag

See the Example and Learn More.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
p {
  color: navy;
  text-indent: 30px;
  text-transform: uppercase;
}
</style>
</head>
<body>

<h1>Style paragraphs with CSS</h1>

<p>World Wrestling Entertainment is an American professional wrestling promotion. It is owned and operated by TKO Group Holdings, a majority-owned subsidiary of Endeavor Group Holdings.</p>

<p>Prior to September 2023, the company's majority owner was its executive chairman, third-generation wrestling promoter Vince McMahon, who retained a 38.6% ownership of the company's outstanding stock and 81.1% of the voting power. The current entity, which was originally named Titan Sports, Inc., was incorporated on February 21, 1980</p>

</body>
</html>

Output should be:

How to create Style paragraphs with CSS on HTML <p> Tag

What is More Example on paragraphs on HTML <p> Tag

See The Example and Learn More.

index.html
Example: HTML
<p>
This paragraph
contains a lot of lines
in the source code,
but the browser 
ignores it.
</p>

Output should be:

What is More Example on paragraphs on HTML <p> Tag

What is the Poem problems in HTML on HTML <p> Tag

Note that the browser simply ignores the line breaks in the source code!

index.html
Example: HTML
<p>
   My Bonnie lies over the ocean.
   My Bonnie lies over the sea.
   My Bonnie lies over the ocean.
   Oh, bring back my Bonnie to me.
</p>

Output should be:

What is the Poem problems in HTML on HTML <p> Tag

How to set Default CSS Settings on HTML <p> Tag

Most browsers will display the <p> element with the following default values.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
p {
  display: block;
  margin-top: 1em;
  margin-bottom: 1em;
  margin-left: 0;
  margin-right: 0;
}
</style>
</head>
<body>

<p>A p element is displayed like this:</p>

<p>This is a paragraph.</p>

<p>Change the default CSS settings to see the effect.</p>

</body>
</html>

Output should be:

How to set Default CSS Settings on HTML <p> Tag

# Tips-82) What is HTML <param> Tag

The <param> tag in HTML is used to define a parameter for plug-ins that are associated with <object> element. It does not contain the end tag. The <param> tag also supports the Global Attributes and Event Attributes in HTML. Ensure the sound plays automatically by setting the “autoplay” parameter to “true”.

Definition and Usage

The <param> tag is used to define parameters for an <object> element.


Browser Support

The <param> tag is supported in all major browsers. However, the file format defined in <object> may not be supported in all browsers.

Attributes

Attribute Value Description
name name Specifies the name of a parameter
value value Specifies the value of the parameter

Global Attributes

The <param> tag also supports the Global Attributes in HTML.


Event Attributes

The <param> tag also supports the Event Attributes in HTML.

How to add HTML <param> Tag

It sets the "autoplay" parameter to "true", so the sound will start playing as soon as the page loads:
index.html
Example: HTML
<object data="horse.wav">
<param name="autoplay" value="true">
</object>

Output should be:

How to add HTML <param> Tag

How to set Default CSS Settings on HTML <param> Tag

Most browsers will display the <param> element with the following default values.

index.html
Example: HTML
<style>
param {
  display: none;
}
</style>
<object data="horse.wav">
<param name="autoplay" value="true">
</object>

Output should be:

How to set Default CSS Settings on HTML <param> Tag

What is HTML <param> name Attribute

Definition and Usage

The name attribute specifies the name of a <param> element.

The name attribute is used together with the value attribute to specify parameters for the plugin specified with the <object> tag.

The name attribute value can be any name supported by the specified object.


Browser Support

The name attribute is supported in all major browsers. However, the file format defined in <object> may not be supported in all browsers.


Syntax

<param name="name">

Attribute Values

Value Description
name The name of the parameter

How to add HTML <param> name Attribute

It sets the "autoplay" parameter to "true", so the sound will start playing as soon as the page loads:

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The param element</h1>

<object data="horse.wav">
<param name="autoplay" value="true">
</object>

</body>
</html>

Output should be:

How to add HTML <param> name Attribute

What is HTML <param> value Attribute

Definition and Usage

The value attribute specifies the value of a <param> element.

This attribute is used together with the name attribute to specify parameters for the plugin specified with the <object> tag.

The value can be any value supported by the specified object.


Browser Support

The value attribute is supported in all major browsers. However, the file format defined in <object> may not be supported in all browsers.


Syntax

<param value="value">

Attribute Values

Value Description
value The value of the parameter

How to add HTML <param> value Attribute

It sets the "autoplay" parameter to "true", so the sound will start playing as soon as the page loads:

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The param element</h1>

<object data="horse.wav">
<param name="autoplay" value="true">
</object>

</body>
</html>

Output should be:

How to add HTML <param> value Attribute

# Tips-83) What is HTML <picture> Tag

The <picture> HTML element contains zero or more <source> elements and one <img> element to offer alternative versions of an image for different display/device scenarios.

The browser will consider each child <source> element and choose the best match among them. If no matches are found—or the browser doesn't support the <picture> element—the URL of the <img> element's src attribute is selected. The selected image is then presented in the space occupied by the <img> element.

Definition and Usage

The <picture> tag gives web developers more flexibility in specifying image resources.

The most common use of the <picture> element will be for art direction in responsive designs. Instead of having one image that is scaled up or down based on the viewport width, multiple images can be designed to more nicely fill the browser viewport.

The <picture> element contains two tags: one or more <source> tags and one <img> tag.

The browser will look for the first <source> element where the media query matches the current viewport width, and then it will display the proper image (specified in the srcset attribute). The <img> element is required as the last child of the <picture> element, as a fallback option if none of the source tags matches.

Tip: The <picture> element works "similar" to <video> and <audio>. You set up different sources, and the first source that fits the preferences is the one being used.


Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Global Attributes

The <picture> tag also supports the Global Attributes in HTML.


Event Attributes

The <picture> tag also supports the Event Attributes in HTML.

How to add HTML <picture> Tag

Resize the browser window to load different images. See the Example and Learn More.
index.html
Example: HTML
<picture>
  <source media="(min-width:650px)" srcset="https://horje.com/avatar.png">
  <source media="(min-width:465px)" srcset="https://horje.com/avatar.png">
  <img src="https://horje.com/avatar.png" alt="Flowers" style="width:auto;">
</picture>

Output should be:

How to add HTML <picture> Tag

# Tips-84) What is HTML <pre> Tag

The <pre> HTML element represents preformatted text which is to be presented exactly as written in the HTML file. The text is typically rendered using a non-proportional, or monospaced, font. Whitespace inside this element is displayed as written.

Definition and Usage

The <pre> tag defines preformatted text.

Text in a <pre> element is displayed in a fixed-width font, and the text preserves both spaces and line breaks. The text will be displayed exactly as written in the HTML source code.

Also look at:

Tag Description
<code> Defines a piece of computer code
<samp> Defines sample output from a computer program
<kbd> Defines keyboard input
<var> Defines a variable

Browser Support

Global Attributes

The <pre> tag also supports the Global Attributes in HTML.


Event Attributes

The <pre> tag also supports the Event Attributes in HTML.

How to add HTML <pre> Tag

It is Preformatted a text.
index.html
Example: HTML
<pre>
Text in a pre element
is displayed in a fixed-width
font, and it preserves
both      spaces and
line breaks
</pre>

Output should be:

How to add HTML <pre> Tag

How to create a pre-formatted text with a fixed width (with CSS)

See the Example and Learn More.

index.html
Example: HTML
<h2>Standard pre</h2>
<pre>This is a standard pre. It will use as much space as it needs.</pre>

<h2>Fixed width pre</h2>
<div style="width:200px;overflow:auto">
<pre>This is a pre with a fixed width. It will use as much space as specified.</pre>
</div>

Output should be:

How to create a pre-formatted text with a fixed width (with CSS)

How to set Default CSS Settings on HTML pre Tag

Most browsers will display the <pre> element with the following default values.

index.html
Example: HTML
<style>
pre {
  display: block;
  font-family: monospace;
  white-space: pre;
  margin: 1em 0;
} 
</style>
<pre>
Text in a pre element
is displayed in a fixed-width
font, and it preserves
both      spaces and
line breaks
</pre>

Output should be:

How to set Default CSS Settings on HTML pre Tag

# Tips-85) What is HTML <progress> Tag

The <progress> HTML element displays an indicator showing the completion progress of a task, typically displayed as a progress bar.

Definition and Usage

The <progress> tag represents the completion progress of a task.

Tip: Always add the <label> tag for best accessibility practices!


Tips and Notes

Tip: Use the <progress> tag in conjunction with JavaScript to display the progress of a task.

Note: The <progress> tag is not suitable for representing a gauge (e.g. disk space usage or relevance of a query result). To represent a gauge, use the <meter> tag instead.


Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Attributes

Attribute Value Description
max number Specifies how much work the task requires in total. Default value is 1
value number Specifies how much of the task has been completed

Global Attributes

The <progress> tag also supports the Global Attributes in HTML.


Event Attributes

The <progress> tag also supports the Event Attributes in HTML.

How to add HTML <progress> Tag

It shows a progress bar.
index.html
Example: HTML
<label for="file">Downloading progress:</label>
<progress id="file" value="32" max="100"> 32% </progress>

Output should be:

How to add HTML <progress> Tag

What is HTML <progress> max Attribute

Definition and Usage

The max attribute specifies how much work the task requires in total.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<progress max="number">

Attribute Values

Value Description
number A floating point number that specifies how much work the task requires in total before it can be considered complete. Default value is 1.

How to add HTML <progress> max Attribute

It shows a progress bar.
index.html
Example: HTML
<label for="file">Downloading progress:</label>
<progress id="file" value="32" max="100"> 32% </progress>

Output should be:

How to add HTML <progress> max Attribute

What is HTML <progress> value Attribute

Definition and Usage

The value attribute specifies how much of the task has been completed.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<progress value="number">

Attribute Values

Value Description
number A floating point number that specifies how much of the task has been completed

How to add HTML <progress> value Attribute

It shows a progress bar.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The progress element</h1>

<label for="file">Downloading progress:</label>
<progress id="file" value="32" max="100"> 32% </progress>

</body>
</html>

Output should be:

How to add HTML <progress> value Attribute

# Tips-86) What is HTML <q> Tag

The <q> HTML element indicates that the enclosed text is a short inline quotation. Most modern browsers implement this by surrounding the text in quotation marks. This element is intended for short quotations that don't require paragraph breaks; for long quotations use the <blockquote> element.

Definition and Usage

The <q> tag defines a short quotation.

Browsers normally insert quotation marks around the quotation.

Tip: Use <blockquote> for long quotations. 

Browser Support

Attributes

Attribute Value Description
cite URL Specifies the source URL of the quote

Global Attributes

The <q> tag also supports the Global Attributes in HTML.


Event Attributes

The <q> tag also supports the Event Attributes in HTML.

How to create HTML <q> Tag

It marks up a short quotation.

index.html
Example: HTML
<p>WWF's goal is to: 
<q>Build a future where people live in harmony with nature.</q>
We hope they succeed.</p>

Output should be:

How to create HTML <q> Tag

How to Use CSS to style the <q> element

See the Example.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
q {
  color: gray;
  font-style: italic;
}
</style>
</head>
<body>

<h1>The q element + CSS</h1>

<p>WWF's goal is to: 
<q>Build a future where people live in harmony with nature.</q>
We hope they succeed.</p>

</body>
</html>

Output should be:

How to Use CSS to style the <q> element

How to set Default CSS Settings on HTML <q> Tag

Most browsers will display the <q> element with the following default values.

index.html
Example: HTML
<style>
q {
  display: inline;
}
 
q:before {
  content: open-quote;
}
 
q:after {
  content: close-quote;
}
</style>

Output should be:

How to set Default CSS Settings on HTML <q> Tag

What is HTML <q> cite Attribute

Definition and Usage

The cite attribute specifies the source URL of a quote.

Browser Support

Note: The cite attribute has no visual effect in ordinary web browsers, but can be used by screen readers.


Syntax

<q cite="URL">

Attribute Values

Value Description
URL Specifies the source URL of the quote.

Possible values:

  • An absolute URL - points to another web site (like href="http://www.example.com/page.htm")
  • A relative URL - points to a file within a web site (like href="page.htm")

How to add HTML <q> cite Attribute

It specify the source URL of a quote.

index.html
Example: HTML
<p>WWF's goal is to:
<q cite="http://www.wwf.org">
Build a future where people live in harmony with nature.</q>
We hope they succeed.
</p> 

Output should be:

How to add HTML <q> cite Attribute

# Tips-87) What is HTML <rp> Tag

The <rp> HTML element is used to provide fall-back parentheses for browsers that do not support display of ruby annotations using the <ruby> element. One <rp> element should enclose each of the opening and closing parentheses that wrap the <rt> element that contains the annotation's text.

Definition and Usage

The <rp> tag can be used to provide parentheses around a ruby text, to be shown by browsers that do not support ruby annotations.

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 information, and an optional <rp> element that defines what to show for browsers that not support ruby annotations.


Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Global Attributes

The <rp> tag also supports the Global Attributes in HTML.


Event Attributes

The <rp> tag also supports the Event Attributes in HTML.

How to create HTML <rp> Tag

It is A ruby annotation.
index.html
Example: HTML
<ruby>
漢 <rp>(</rp><rt>ㄏㄢˋ</rt><rp>)</rp>
</ruby>

Output should be:

How to create HTML <rp> Tag

More Example

Ruby annotations are for showing pronunciation of East Asian characters.
index.html
Example: HTML
<ruby> 漢 <rp>(</rp><rt>kan</rt><rp>)</rp> 字 <rp>(</rp><rt>ji</rt><rp>)</rp> </ruby>

Output should be:


# Tips-88) What is HTML <rt> Tag

The <rt> HTML element specifies the ruby text component of a ruby annotation, which is used to provide pronunciation, translation, or transliteration information for East Asian typography. The <rt> element must always be contained within a <ruby> element.

Definition and Usage

The <rt> tag defines an explanation or pronunciation of characters (for East Asian typography) in a ruby annotation.

<rt> uses together with <ruby> and <rp>: The <ruby> element 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.


Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Global Attributes

The <rt> tag also supports the Global Attributes in HTML.


Event Attributes

The <rt> tag also supports the Event Attributes in HTML.

How to create HTML <rt> Tag

It is A ruby annotation.
index.html
Example: HTML
<ruby>
 漢 <rt> ㄏㄢˋ </rt>
</ruby>

Output should be:

How to create HTML <rt> Tag

How to set Default CSS Settings on HTML <rt> Tag

Most browsers will display the <rt> element with the following default values.
index.html
Example: HTML
<style>
rt {
  line-height: normal;
}
</style>

Output should be:

How to set Default CSS Settings on HTML <rt> Tag

# Tips-89) What is HTML <ruby> Tag

The <ruby> HTML element represents small annotations that are rendered above, below, or next to base text, usually used for showing the pronunciation of East Asian characters. It can also be used for annotating other kinds of text, but this usage is less common.

Definition and Usage

The <ruby> tag specifies a ruby annotation.

A ruby annotation is a small extra text, attached to the main text to indicate the pronunciation or meaning of the corresponding characters. This kind of annotation is often used in Japanese publications.

Use <ruby> together with <rt> and <rp>: The <ruby> element 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 do not support ruby annotations.


Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Global Attributes

The <ruby> tag also supports the Global Attributes in HTML.


Event Attributes

The <ruby> tag also supports the Event Attributes in HTML.

How to create HTML <ruby> Tag

It is A ruby annotation.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The ruby and rt elements</h1>

<ruby>
 漢 <rt> ㄏㄢˋ </rt>
</ruby>

</body>
</html>

Output should be:

How to create HTML <ruby> Tag

# Tips-90) What is HTML <s> Tag

This tag is used to specify that the text content is no longer correct or accurate. This tag is similar but slightly different from the <del> tag. The <s> tag should not be used to define deleted text, rather use the <del> tag for that.

Definition and Usage

The <s> tag specifies text that is no longer correct, accurate or relevant. The text will be displayed with a line through it.

The <s> tag should not be used to define deleted text in a document, use the <del> tag for that.


Browser Support

 

Global Attributes

The <s> tag also supports the Global Attributes in HTML.


Event Attributes

The <s> tag also supports the Event Attributes in HTML.

How to create HTML <s> Tag

It marks up text that is no longer correct.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The s element</h1>

<p><s>Only 50 tickets left!</s></p>
<p>SOLD OUT!</p>

</body>
</html>

Output should be:

How to create HTML <s> Tag

How to set Default CSS Settings on HTML <s> Tag

Most browsers will display the <s> element with the following default values.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
s { 
  text-decoration: line-through;
}
</style>
</head>
<body>

<p>An s element is displayed like this:</p>

<p><s>Some no-longer correct text.</s></p>

<p>Change the default CSS settings to see the effect.</p>

</body>
</html>

Output should be:

How to set Default CSS Settings on HTML <s> Tag

# Tips-91) What is HTML <samp> Tag

The <samp> HTML element is used to enclose inline text which represents sample (or quoted) output from a computer program. Its contents are typically rendered using the browser's default monospaced font (such as Courier or Lucida Console).

Definition and Usage

The <samp> tag is used to define sample output from a computer program. The content inside is displayed in the browser's default monospace font.

Tip: This tag is not deprecated. However, it is possible to achieve richer effect by using CSS.

Also look at:

Tag Description
<code> Defines a piece of computer code
<kbd> Defines keyboard input
<var> Defines a variable
<pre> Defines preformatted text

Browser Support

Global Attributes

The <samp> tag also supports the Global Attributes in HTML.


Event Attributes

The <samp> tag also supports the Event Attributes in HTML.

How to create HTML <samp> Tag

It defines some text as sample output from a computer program in a document.
index.html
Example: HTML
<p><samp>File not found.<br>Press F1 to continue</samp></p>

Output should be:

How to create HTML <samp> Tag

How to set Default CSS Settings on HTML <samp> Tag

Most browsers will display the <samp> element with the following default values.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
samp { 
  font-family: monospace;
}
</style>
</head>
<body>

<p>A samp element is displayed like this:</p>

<samp>Sample output from a computer program</samp>

<p>Change the default CSS settings to see the effect.</p>

</body>
</html>

Output should be:

How to set Default CSS Settings on HTML <samp> Tag

# Tips-92) What is HTML <script> Tag

The <script> HTML element is used to embed executable code or data; this is typically used to embed or refer to JavaScript code. The <script> element can also be used with other languages, such as WebGL's GLSL shader programming language and JSON.

Definition and Usage

The <script> tag is used to embed a client-side script (JavaScript).

The <script> element either contains scripting statements, or it points to an external script file through the src attribute.

Common uses for JavaScript are image manipulation, form validation, and dynamic changes of content.


Tips and Notes

Tip: Also look at the <noscript> element for users that have disabled scripts in their browser, or have a browser that doesn't support client-side scripting.

Tip: If you want to learn more about JavaScript, visit our JavaScript Tutorial.


Browser Support

Attributes

Attribute Value Description
async async Specifies that the script is downloaded in parallel to parsing the page, and executed as soon as it is available (before parsing completes) (only for external scripts)
crossorigin anonymous
use-credentials
Sets the mode of the request to an HTTP CORS Request
defer defer Specifies that the script is downloaded in parallel to parsing the page, and executed after the page has finished parsing (only for external scripts)
integrity filehash Allows a browser to check the fetched script to ensure that the code is never loaded if the source has been manipulated
nomodule True
False
Specifies that the script should not be executed in browsers supporting ES2015 modules
referrerpolicy no-referrer
no-referrer-when-downgrade
origin
origin-when-cross-origin
same-origin
strict-origin
strict-origin-when-cross-origin
unsafe-url
Specifies which referrer information to send when fetching a script
src URL Specifies the URL of an external script file
type scripttype Specifies the media type of the script

How to create HTML <script> Tag

It writes "Hello JavaScript!" with JavaScript.
index.html
Example: HTML
<p id="demo"></p>

<script>
document.getElementById("demo").innerHTML = "Hello JavaScript!";
</script> 

Output should be:

How to create HTML <script> Tag

How to set Default CSS Settings on HTML <script> Tag

Most browsers will display the <script> element with the following default values.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<style>
script {
  display: none;
}
</style>
<body>

<h1>The script element</h1>

<p id="demo"></p>

<script>
document.getElementById("demo").innerHTML = "Hello JavaScript!";
</script> 

</body>
</html>

Output should be:

How to set Default CSS Settings on HTML <script> Tag

What is Differences Between HTML and XHTML

In XHTML, the content inside scripts is declared as #PCDATA (instead of CDATA), which means that entities will be parsed. This means that in XHTML, all special characters should be encoded, or all content should be wrapped inside a CDATA section.
index.html
Example: HTML
 <script type="text/javascript">
//<![CDATA[
let i = 10;
if (i < 5) {
  // some code
}
//]]>
</script>

What is HTML <script> async Attribute

Definition and Usage

The async attribute is a boolean attribute.

If the async attribute is set, the script is downloaded in parallel to parsing the page, and executed as soon as it is available. The parsing of the page is interrupted once the script is downloaded completely, and then the script is executed, before the parsing of the rest of the page continues.

Note: The async attribute is only for external scripts (and should only be used if the src attribute is present).

Note: There are several ways an external script can be executed:

  • If async is present: The script is downloaded in parallel to parsing the page, and executed as soon as it is available (before parsing completes)
  • If defer is present (and not async): The script is downloaded in parallel to parsing the page, and executed after the page has finished parsing
  • If neither async or defer is present: The script is downloaded and executed immediately, blocking parsing until the script is completed

Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<script async>

How to add HTML <script> async Attribute

It is a script that will be downloaded in parallel to parsing the page, and executed as soon as it is available.
index.html
Example: HTML
<p id="p1">Hello World!</p>
<script src="demo_async.js" async></script>

Output should be:

How to add HTML <script> async Attribute

What is HTML <script> crossorigin Attribute

Definition and Usage

The crossorigin attribute sets the mode of the request to an HTTP CORS Request.

Web pages often make requests to load resources on other servers. Here is where CORS comes in.

A cross-origin request is a request for a resource (e.g. style sheets, iframes, images, fonts, or scripts) from another domain.

CORS is used to manage cross-origin requests.

CORS stands for Cross-Origin Resource Sharing, and is a mechanism that allows resources on a web page to be requested from another domain outside their own domain. It defines a way of how a browser and server can interact to determine whether it is safe to allow the cross-origin request. CORS allows servers to specify who can access the assets on the server, among many other things.

Tip: The opposite of cross-origin requests is same-origin requests. This means that a web page can only interact with other documents that are also on the same server. This policy enforces that documents that interact with each other must have the same origin (domain).

Tip: Also look at the integrity attribute.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<script crossorigin="anonymous|use-credentials">

Attribute Values

Value Description
anonymous
use-credentials
Specifies the mode of the CORS request:
  • anonymous - A cross-origin request is performed. No credentials are sent
  • use-credentials - A cross-origin request is performed. Credentials are sent (e.g. a cookie, a certificate, a HTTP Basic authentication)

How to add HTML <script> crossorigin Attribute

Here is a link to a .js file on another server. Here we use both the integrity and crossorigin attributes.

<script
            type="text/javascript"
            src="my_script.js"
            crossorigin="anonymous"
        ></script>

Output should be:

How to add HTML <script> crossorigin Attribute

How to add HTML <script> crossorigin anonymous Attribute

Here is a link to a .js file on another server. Here we use both the integrity and crossorigin attributes.

index.html
Example: HTML
        <script
            type="text/javascript"
            src="my_script.js"
            crossorigin="anonymous"
        ></script>

Output should be:

How to add HTML <script> crossorigin anonymous Attribute

How to add HTML <script> crossorigin use-credentials Attribute

Here is a link to a .js file on another server. Here we use both the integrity and crossorigin attributes.

index.html
Example: HTML
 <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin="use-credentials">
</script> 

What is HTML <script> defer Attribute

Definition and Usage

The defer attribute is a boolean attribute.

If the defer attribute is set, it specifies that the script is downloaded in parallel to parsing the page, and executed after the page has finished parsing.

Note: The defer attribute is only for external scripts (should only be used if the src attribute is present).

Note: There are several ways an external script can be executed:

  • If async is present: The script is downloaded in parallel to parsing the page, and executed as soon as it is available (before parsing completes)
  • If defer is present (and not async): The script is downloaded in parallel to parsing the page, and executed after the page has finished parsing
  • If neither async or defer is present: The script is downloaded and executed immediately, blocking parsing until the script is completed

Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<script defer>

How to add HTML <script> defer Attribute

It is a script that will be downloaded in parallel to parsing the page, and executed after the page has finished parsing.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The script defer attribute</h1>

<script src="https://www.w3schools.com/tags/demo_defer.js" defer></script>

<p>The script above requests information from the paragraph below. Normally, this is not possible, because the script is executed before the paragraph exists.</p>

<p id="p1">Hello World!</p>

<p>However, the defer attribute specifies that the script should be executed later. This way the script can request information from the paragraph.</p>

</body>
</html>

Output should be:

How to add HTML <script> defer Attribute

What is HTML <script> integrity Attribute

Definition and Usage

The integrity attribute allows a browser to check the fetched script to ensure that the code is never loaded if the source has been manipulated.

Subresource Integrity (SRI) is a W3C specification that allows web developers to ensure that resources hosted on third-party servers have not been altered. Use of SRI is recommended!

When using SRI, the webpage holds the hash and the server holds the file (the .js file in this case). The browser downloads the file, then checks it, to make sure that it is a match with the hash in the integrity attribute. If it matches, the file is used, and if not, the file is blocked.

You can use an online SRI hash generator to generate integrity hashes: SRI Hash Generator


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<script integrity="filehash">

Attribute Values

Value Description
filehash The file hashing value of the external script file

How to create HTML <script> integrity Attribute

It links to a CDN, using both the integrity and crossorigin atributes.
index.html
Example: HTML
 <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin="anonymous">
</script> 

What is nomodule HTML <script> Tag

The noModule property of the HTMLScriptElement interface is a boolean value that indicates whether the script should be executed in browsers that support ES modules. Practically, this can be used to serve fallback scripts to older browsers that do not support JavaScript modules.

It reflects the nomodule attribute of the <script> element.

nomodule True
False
Specifies that the script should not be executed in browsers supporting ES2015 modules

How to create nomodule on HTML <script> Tag

A boolean, true means that the script should not be executed in browsers that support ES modules, false otherwise.
index.html
Example: HTML
<script id="el" nomodule>
  // If the browser supports JavaScript modules, the following script will not be executed.
  console.log("The browser does not support JavaScript modules");
</script>
<script>
const el = document.getElementById("el");
console.log(el.noModule); // Output: true
</script>

What is HTML <script> referrerpolicy Attribute

Definition and Usage

The referrerpolicy attribute specifies which referrer information to send when fetching a script.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<script referrerpolicy="no-referrer|no-referrer-when-downgrade|origin|origin-when-cross-origin|same-origin|strict-origin-when-cross-origin|unsafe-url">

Attribute Values

Value Description
no-referrer No referrer information is sent
no-referrer-when-downgrade Default. Sends the origin, path, and query string if the protocol security level stays the same or is higher (HTTP to HTTP, HTTPS to HTTPS, HTTP to HTTPS is ok). Sends nothing to less secure level (HTTPS to HTTP is not ok)
origin Sends the origin (scheme, host, and port) of the document
origin-when-cross-origin Sends the origin of the document for cross-origin request. Sends the origin, path, and query string for same-origin request
same-origin Sends a referrer for same-origin request. Sends no referrer for cross-origin request
strict-origin-when-cross-origin Sends the origin if the protocol security level stays the same or is higher (HTTP to HTTP, HTTPS to HTTPS, and HTTP to HTTPS is ok). Sends nothing to less secure level (HTTPS to HTTP)
unsafe-url Sends the origin, path, and query string (regardless of security). Use this value carefully!

How to create HTML <script> referrerpolicy Attribute

It sets the referrerpolicy for a script.

index.html
Example: HTML
<script src="myscripts.js" referrerpolicy="origin"></script>

How to add no-referrer value on HTML <script> referrerpolicy Attribute

The Referer header will be omitted entirely. No referrer information is sent along with requests.

index.html
Example: HTML
<script src="myscripts.js" referrerpolicy="no-referrer"></script>

How to add no-referrer-when-downgrade value on HTML <script> referrerpolicy Attribute

The URL is sent as a referrer when the protocol security level stays the same (e.g.HTTP→HTTP, HTTPS→HTTPS), but isn't sent to a less secure destination (e.g. HTTPS→HTTP).

no-referrer-when-downgrade Default. Sends the origin, path, and query string if the protocol security level stays the same or is higher (HTTP to HTTP, HTTPS to HTTPS, HTTP to HTTPS is ok). Sends nothing to less secure level (HTTPS to HTTP is not ok)
index.html
Example: HTML
<script src="myscripts.js" referrerpolicy="no-referrer-when-downgrade"></script>

How to add origin value on HTML <script> referrerpolicy Attribute

Only send the origin of the document as the referrer in all cases. The document https://example.com/page.html will send the referrer https://example.com/.

origin Sends the origin (scheme, host, and port) of the document
index.html
Example: HTML
<script src="myscripts.js" referrerpolicy="origin"></script>

How to add origin-when-cross-origin value on HTML <script> referrerpolicy Attribute

Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.

origin-when-cross-origin Sends the origin of the document for cross-origin request. Sends the origin, path, and query string for same-origin request
index.html
Example: HTML
<script src="myscripts.js" referrerpolicy="origin-when-cross-origin"></script>

How to add same-origin value on HTML <script> referrerpolicy Attribute

A referrer will be sent for same-site origins, but cross-origin requests will contain no referrer information.

same-origin Sends a referrer for same-origin request. Sends no referrer for cross-origin request
index.html
Example: HTML
<script src="myscripts.js" referrerpolicy="same-origin"></script>

JS Example of same-origin value on HTML <script> referrerpolicy Attribute

JS Example

script.js
Example: JS
const scriptElem = document.createElement("script");
scriptElem.src = "/";
scriptElem.referrerPolicy = "same-origin";
document.body.appendChild(scriptElem);

How to add strict-origin value on HTML <script> referrerpolicy Attribute

Only send the origin of the document as the referrer when the protocol security level stays the same (e.g. HTTPS→HTTPS), but don't send it to a less secure destination (e.g. HTTPS→HTTP).

index.html
Example: HTML
<script src="myscripts.js" referrerpolicy="strict-origin"></script>

How to add strict-origin-when-cross-origin value on HTML <script> referrerpolicy Attribute

This is the user agent's default behavior if no policy is specified. Send a full URL when performing a same-origin request, only send the origin when the protocol security level stays the same (e.g. HTTPS→HTTPS), and send no header to a less secure destination (e.g. HTTPS→HTTP).

strict-origin-when-cross-origin Sends the origin if the protocol security level stays the same or is higher (HTTP to HTTP, HTTPS to HTTPS, and HTTP to HTTPS is ok). Sends nothing to less secure level (HTTPS to HTTP)
index.html
Example: HTML
<script src="myscripts.js" referrerpolicy="strict-origin-when-cross-origin"></script>

How to add unsafe-url value on HTML <script> referrerpolicy Attribute

Send a full URL when performing a same-origin or cross-origin request. This policy will leak origins and paths from TLS-protected resources to insecure origins. Carefully consider the impact of this setting.

unsafe-url Sends the origin, path, and query string (regardless of security). Use this value carefully!
index.html
Example: HTML
<script src="myscripts.js" referrerpolicy="unsafe-url"></script>

What is HTML <script> src Attribute

The <script> HTML element is used to embed executable code or data; this is typically used to embed or refer to JavaScript code. The <script> element can also be used with other languages, such as WebGL's GLSL shader programming language and JSON.

Definition and Usage

The src attribute specifies the URL of an external script file.

If you want to run the same JavaScript on several pages in a web site, you should create an external JavaScript file, instead of writing the same script over and over again. Save the script file with a .js extension, and then refer to it using the src attribute in the <script> tag.

Note: The external script file cannot contain the <script> tag.

Note: Point to the external script file exactly where you would have written the script.


Browser Support

Syntax

<script src="URL">

Attribute Values

Value Description
URL The URL of the external script file.

Possible values:

  • An absolute URL - points to another web site (like src="http://www.example.com/example.js")
  • A relative URL - points to a file within a web site (like src="/scripts/example.js")

How to add HTML <script> src Attribute

It points to an external JavaScript file.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The script src attribute</h1>

<script src="demo_script_src.js">
</script>

</body>
</html>

Output should be:

How to add HTML <script> src Attribute

What is HTML <script> type Attribute

Definition and Usage

The type attribute specifies the type of the script.

The type attribute identifies the content between the <script> and </script> tags.


Browser Support

Syntax

<script type="scripttype">

Attribute Values

Value Description
scripttype Specifies the type of the script.

Some common values:
  • A JavaScript MIME type like: text/javascript (default)module:
  • Another MIME type. src attribute will be ignored

Look at IANA Media Types for a complete list of standard media types.

How to create HTML <script> type Attribute

It is a script with the type attribute specified.
index.html
Example: HTML
<p id="demo"></p>

<script type="text/javascript">
document.getElementById("demo").innerHTML = "Hello JavaScript!";
</script>

Output should be:

How to create HTML <script> type Attribute

# Tips-93) What is HTML <search> Tag

The <search> HTML element is a container representing the parts of the document or application with form controls or other content related to performing a search or filtering operation. The <search> element semantically identifies the purpose of the element's contents as having search or filtering capabilities. The search or filtering functionality can be for the website or application, the current web page or document, or the entire Internet or subsection thereof.

Definition and Usage

The <search> tag is used to specify that here comes a set of elements that is related to search.

Elements inside a <search> elements can typically be form elements used to perform a search.

Note: The <search> element does not render as anything special in a browser. However, you can use CSS to style the <search> element and its content.


Browser Support

Global Attributes

The <search> tag also supports the Global Attributes in HTML.


Event Attributes

The <search> tag also supports the Event Attributes in HTML.

How to create HTML <search> Tag

It surrounds the search form with a search element:
index.html
Example: HTML
<search>
  <form>
    <input name="fsrch" id="fsrch" placeholder="Search Horje">
  </form>
</search>

Output should be:

How to create HTML <search> Tag

How to set Default CSS Settings on HTML <search> Tag

Most browsers will display the <search> element with the following default values:
index.html
Example: HTML
<style>
search { 
  display: block;
}
</style>

Output should be:

How to set Default CSS Settings on HTML <search> Tag

# Tips-94) What is HTML <section> Tag

The <section> HTML element represents a generic standalone section of a document, which doesn't have a more specific semantic element to represent it. Sections should always have a heading, with very few exceptions.

Definition and Usage

The <section> tag defines a section in a document.


Browser Support

The numbers in the table specify the first browser version that fully supports the element.


Global Attributes

The <section> tag also supports the Global Attributes in HTML.


Event Attributes

The <section> tag also supports the Event Attributes in HTML.

How to create HTML <section> Tag

Here are Two sections in a document.
index.html
Example: HTML
<section>
  <h2>WWF History</h2>
  <p>The World Wide Fund for Nature (WWF) is an international organization working on issues regarding the conservation, research and restoration of the environment, formerly named the World Wildlife Fund. WWF was founded in 1961.</p>
</section>

<section>
  <h2>WWF's Symbol</h2>
  <p>The Panda has become the symbol of WWF. The well-known panda logo of WWF originated from a panda named Chi Chi that was transferred from the Beijing Zoo to the London Zoo in the same year of the establishment of WWF.</p>
</section>

Output should be:

How to create HTML <section> Tag

# Tips-95) What is HTML <select> Tag

The <select> HTML element represents a control that provides a menu of options.

Definition and Usage

The <select> element is used to create a drop-down list.

The <select> element is most often used in a form, to collect user input.

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 drop-down list will be submitted).

The id attribute is needed to associate the drop-down list with a label.

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!


Browser Support

Attributes

Attribute Value Description
autofocus autofocus Specifies that the drop-down list should automatically get focus when the page loads
disabled disabled Specifies that a drop-down list should be disabled
form form_id Defines which form the drop-down list belongs to
multiple multiple Specifies that multiple options can be selected at once
name name Defines a name for the drop-down list
required required Specifies that the user is required to select a value before submitting the form
size number Defines the number of visible options in a drop-down list

Global Attributes

The <select> tag also supports the Global Attributes in HTML.


Event Attributes

The <select> tag also supports the Event Attributes in HTML.

How to create HTML <select> Tag

It creates a drop-down list with four options

index.html
Example: HTML
<form action="/action_page.php">
  <label for="cars">Choose a car:</label>
  <select name="cars" id="cars">
    <option value="volvo">Volvo</option>
    <option value="saab">Saab</option>
    <option value="opel">Opel</option>
    <option value="audi">Audi</option>
  </select>
  <br><br>
  <input type="submit" value="Submit">
</form>

Output should be:

How to create HTML <select> Tag

How to add Use <select> with <optgroup> tags

The optgroup tag is used to group related options in a drop-down list.

index.html
Example: HTML
<form action="/action_page.php">
  <label for="cars">Choose a car:</label>
  <select name="cars" id="cars">
    <optgroup label="Swedish Cars">
      <option value="volvo">Volvo</option>
      <option value="saab">Saab</option>
    </optgroup>
    <optgroup label="German Cars">
      <option value="mercedes">Mercedes</option>
      <option value="audi">Audi</option>
    </optgroup>
  </select>
  <br><br>
  <input type="submit" value="Submit">
</form>

Output should be:

How to add Use <select> with <optgroup> tags

What is HTML <select> autofocus Attribute

The autofocus attribute specifies whether the <element> should be auto-focused when the page document loads.

Definition and Usage

The autofocus attribute is a boolean attribute.

When present, it specifies that the drop-down list should automatically get focus when the page loads.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<select autofocus>

How to add HTML <select> autofocus Attribute

It is a drop-down list with autofocus

index.html
Example: HTML
<form action="/action_page.php">
  <label for="cars">Choose a car:</label>
  <select name="cars" id="cars" autofocus>
    <option value="volvo">Volvo</option>
    <option value="saab">Saab</option>
    <option value="opel">Opel</option>
    <option value="audi">Audi</option>
  </select>
  <br><br>
  <input type="submit" value="Submit">
</form>

Output should be:

How to add HTML <select> autofocus Attribute

What is HTML <select> disabled Attribute

The disabled attribute for <select> element in HTML is used to specify that the select element is disabled. A disabled drop-down list is un-clickable and unusable. It is a boolean attribute. 

Definition and Usage

The disabled attribute is a boolean attribute.

When present, it specifies that the drop-down list should be disabled.

A disabled drop-down list is unusable and un-clickable.

The disabled attribute can be set to keep a user from using the drop-down list until some other condition has been met (like selecting a checkbox, etc.). Then, a JavaScript can remove the disabled value, and make the drop-down list usable.


Browser Support

Syntax

<select disabled>

How to create HTML <select> disabled Attribute

It is a disabled drop-down list
index.html
Example: HTML
<form action="/action_page.php">
  <label for="cars">Choose a car:</label>
  <select name="cars" id="cars" disabled>
    <option value="volvo">Volvo</option>
    <option value="saab">Saab</option>
    <option value="mercedes">Mercedes</option>
    <option value="audi">Audi</option>
  </select>
  <br><br>
  <input type="submit" value="Submit">
</form>

Output should be:

How to create HTML <select> disabled Attribute

What is HTML <select> form Attribute

Definition and Usage

The form attribute specifies the form the drop-down list belongs to.

The value of this attribute must be equal to the id attribute of a <form> element in the same document.


Browser Support

Syntax

<select form="form_id">

Attribute Values

Value Description
form_id Specifies the form element the <select> element belongs to. The value of this attribute must be equal to the id attribute of a <form> element in the same document.

How to create HTML <select> form Attribute

It is A drop-down list located outside a form (but still a part of the form)
index.html

Output should be:

How to create HTML <select> form Attribute

What is HTML <select> multiple Attribute

Definition and Usage

The multiple attribute is a boolean attribute.

When present, it specifies that multiple options can be selected at once.

Selecting multiple options vary in different operating systems and browsers:

  • For windows: Hold down the control (ctrl) button to select multiple options
  • For Mac: Hold down the command button to select multiple options

Because of the different ways of doing this, and because you have to inform the user that multiple selection is available, it is more user-friendly to use checkboxes instead.


Browser Support

Syntax

<select multiple>

How to add HTML <select> multiple Attribute

It is A drop-down list that allows multiple selections.
index.html
Example: HTML
<form action="/action_page.php">
  <label for="cars">Choose a car:</label>
  <select name="cars" id="cars" multiple>
    <option value="volvo">Volvo</option>
    <option value="saab">Saab</option>
    <option value="opel">Opel</option>
    <option value="audi">Audi</option>
  </select>
  <br><br>
  <input type="submit" value="Submit">
</form>

Output should be:

How to add HTML <select> multiple Attribute

What is HTML <select> name Attribute

Definition and Usage

The name attribute specifies the name for a drop-down list.

The name attribute is used to reference elements in a JavaScript, or to reference form data after a form is submitted.


Browser Support

Syntax

<select name="text">

Attribute Values

Value Description
text The name of the drop-down list

How to add HTML <select> name Attribute

This is A drop-down list with a name attribute.
index.html
Example: HTML
<form action="/action_page.php">
  <label for="cars">Choose a car:</label>
  <select name="cars" id="cars">
    <option value="volvo">Volvo</option>
    <option value="saab">Saab</option>
    <option value="opel">Opel</option>
    <option value="audi">Audi</option>
  </select>
  <br><br>
  <input type="submit" value="Submit">
</form>

Output should be:

How to add HTML <select> name Attribute

What is HTML <select> required Attribute

Definition and Usage

The required attribute is a boolean attribute.

When present, it specifies the user is required to select a value before submitting the form.


Browser Support

Syntax

<select required>

What is HTML <select> required Attribute

This is An HTML form with a required drop-down list.
index.html
Example: HTML
<form action="/action_page.php">
  <label for="cars">Choose a car:</label>
  <select name="cars" id="cars" required>
    <option value="">None</option>
    <option value="volvo">Volvo</option>
    <option value="saab">Saab</option>
    <option value="mercedes">Mercedes</option>
    <option value="audi">Audi</option>
  </select>
  <br><br>
  <input type="submit" value="Submit">
</form>

Output should be:

What is HTML <select> required Attribute

What is HTML <select> size Attribute

Definition and Usage

The size attribute specifies the number of visible options in a drop-down list.

If the value of the size attribute is greater than 1, but lower than the total number of options in the list, the browser will add a scroll bar to indicate that there are more options to view.


Browser Support

Note: In Chrome and Safari, this attribute may not work as expected for size="2" and size="3".


Syntax

<select size="number">

Attribute Values

Value Description
number The number of visible options in the drop-down list. Default value is 1. If the multiple attribute is present, the default value is 4

How to add HTML <select> size Attribute

It is A drop-down list with three visible options
index.html
Example: HTML
<form action="/action_page.php">
  <label for="cars">Choose a car:</label>
  <select id="cars" name="cars" size="3">
    <option value="volvo">Volvo</option>
    <option value="saab">Saab</option>
    <option value="opel">Opel</option>
    <option value="audi">Audi</option>
  </select>
  <br><br>
  <input type="submit" value="Submit">
</form>

Output should be:

How to add HTML <select> size Attribute

# Tips-96) What is HTML <small> Tag

The <small> HTML element represents side-comments and small print, like copyright and legal text, independent of its styled presentation. By default, it renders text within it one font-size smaller, such as from small to x-small.

Definition and Usage

The <small> tag defines smaller text (like copyright and other side-comments).

Tip: This tag is not deprecated, but it is possible to achieve richer (or the same) effect with CSS.


Browser Support

Global Attributes

The <small> tag also supports the Global Attributes in HTML.


Event Attributes

The <small> tag also supports the Event Attributes in HTML.

How to create HTML <small> Tag

It defines a smaller text.
index.html
Example: HTML
<p><small>This is some smaller text.</small></p>

Output should be:

How to create HTML <small> Tag

How to Use CSS to define smaller text

See the Example.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
span.small {
  font-size: smaller;
}
</style>
</head>
<body>

<h1>Use CSS to define smaller text</h1>

<p>This is some normal text.</p>
<p><span class="small">This is some smaller text.</span></p>

</body>
</html>

Output should be:

How to Use CSS to define smaller text

How to set Default CSS Settings on HTML <small> Tag

Most browsers will display the <small> element with the following default values.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
small { 
  font-size: smaller;
}
</style>
</head>
<body>

<p>A small element is displayed like this:</p>

<small>Some smaller text</small>

<p>Change the default CSS settings to see the effect.</p>

</body>
</html>

Output should be:

How to set Default CSS Settings on HTML <small> Tag

# Tips-97) What is HTML <source> Tag

Definition and Usage

The <source> tag is used to specify multiple media resources for media elements, such as <video>, <audio>, and <picture>.

The <source> tag allows you to specify alternative video/audio/image files which the browser may choose from, based on browser support or viewport width. The browser will choose the first <source> it supports.


Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Attributes

Attribute Value Description
media media_query Accepts any valid media query that would normally be defined in a CSS
sizes   Specifies image sizes for different page layouts
src URL Required when <source> is used in <audio> and <video>. Specifies the URL of the media file
srcset URL Required when <source> is used in <picture>. Specifies the URL of the image to use in different situations
type MIME-type Specifies the MIME-type of the resource

Global Attributes

The <source> tag also supports the Global Attributes in HTML.


Event Attributes

The <source> tag also supports the Event Attributes in HTML.


How to create HTML <source> Tag

It is An audio player with two source files. The browser will choose the first <source> it supports.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The source element</h1>

<p>Click on the play button to play a sound:</p>

<audio controls>
  <source src="https://file-examples.com/storage/fe36b23e6a66fc0679c1f86/2017/11/file_example_OOG_1MG.ogg" type="audio/ogg">
  <source src="https://file-examples.com/storage/fe36b23e6a66fc0679c1f86/2017/11/file_example_MP3_700KB.mp3" type="audio/mpeg">
  Your browser does not support the audio element.
</audio>

</body>
</html>

Output should be:

How to create HTML <source> Tag

How to Use <source> within <video> to play a video

See the Example.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The video element</h1>

<video width="320" height="240" controls>
  <source src="https://www.sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4" type="video/mp4">
  <source src="https://www.sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4" type="video/ogg">
  Your browser does not support the video tag.
</video>

</body>
</html>

Output should be:

How to Use <source> within <video> to play a video

How to Use <source> within <picture> to define different images based on the viewport width

See the Eample.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>

<h1>The picture element</h1>

<p>Resize the browser window to load different images.</p>

<picture>
  <source media="(min-width:650px)" srcset="https://horje.com/avatar.png">
  <source media="(min-width:465px)" srcset="https://horje.com/avatar.png">
  <img src="https://horje.com/avatar.png" alt="Horje" style="width:auto;">
</picture>

</body>
</html>

Output should be:

How to Use <source> within <picture> to define different images based on the viewport width

What is HTML <source> media Attribute

Definition and Usage

The media attribute accepts any valid media query that would normally be defined in a CSS.

Note: This attribute can accept several values.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<source media="media_query">

Devices

Value Description
all Suitable for all devices. This is default
aural Speech synthesizers
braille Braille feedback devices
handheld Handheld devices (small screen, limited bandwidth)
projection Projectors
print Print preview mode/printed pages
screen Computer screens
tty Teletypes and similar media using a fixed-pitch character grid
tv Television type devices (low resolution, limited scroll ability)

Values

Value Description
width Specifies the width of the targeted display area.
"min-" and "max-" prefixes can be used.
Example: media="screen and (min-width:500px)"
height Specifies the height of the targeted display area.
"min-" and "max-" prefixes can be used.
Example: media="screen and (max-height:700px)"
device-width Specifies the width of the target display/paper.
"min-" and "max-" prefixes can be used.
Example: media="screen and (device-width:500px)"
device-height Specifies the height of the target display/paper.
"min-" and "max-" prefixes can be used.
Example: media="screen and (device-height:500px)"
orientation Specifies the orientation of the target display/paper.
Possible values: "portrait" or "landscape"
Example: media="all and (orientation: landscape)"
aspect-ratio Specifies the width/height ratio of the targeted display area.
"min-" and "max-" prefixes can be used.
Example: media="screen and (aspect-ratio:16/9)"
device-aspect-ratio Specifies the device-width/device-height ratio of the target display/paper.
"min-" and "max-" prefixes can be used.
Example: media="screen and (aspect-ratio:16/9)"
color Specifies the bits per color of target display.
"min-" and "max-" prefixes can be used.
Example: media="screen and (color:3)"
color-index Specifies the number of colors the target display can handle.
"min-" and "max-" prefixes can be used.
Example: media="screen and (min-color-index:256)"
monochrome Specifies the bits per pixel in a monochrome frame buffer.
"min-" and "max-" prefixes can be used.
Example: media="screen and (monochrome:2)"
resolution Specifies the pixel density (dpi or dpcm) of the target display/paper.
"min-" and "max-" prefixes can be used.
Example: media="print and (resolution:300dpi)"
scan Specifies scanning method of a tv display.
Possible values are "progressive" and "interlace".
Example: media="tv and (scan:interlace)"
grid Specifies if the output device is grid or bitmap.
Possible values are "1" for grid, and "0" otherwise.
Example: media="handheld and (grid:1)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The source media attribute</h1>

<picture>
  <source media="(min-width: 650px)" srcset="https://horje.com/avatar.png">
  <source media="(min-width: 465px)" srcset="https://horje.com/avatar.png">
  <img src="https://horje.com/avatar.png" alt="Horje Icon" style="width:auto;">
</picture>

</body>
</html>

Output should be:

What is HTML <source> media Attribute

How to add HTML <source> media Attribute

It is a <picture> element with two source files, and a fallback image.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The source media attribute</h1>

<picture>
  <source media="(min-width: 650px)" srcset="https://horje.com/avatar.png">
  <source media="(min-width: 465px)" srcset="https://horje.com/avatar.png">
  <img src="https://horje.com/avatar.png" alt="Horje Icon" style="width:auto;">
</picture>

</body>
</html>

Output should be:

How to add HTML <source> media Attribute

How to add and Value in HTML <source> media Attribute

and Specifies an AND operator
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The source media attribute</h1>

<picture>
  <source media="screen and (min-width:500px)" srcset="https://horje.com/avatar.png">
  <source media="screen and (min-width:500px)" srcset="https://horje.com/avatar.png">
  <img src="https://horje.com/avatar.png" alt="Horje Icon" style="width:auto;">
</picture>

</body>
</html>

Output should be:

How to add and Value in HTML <source> media Attribute

How to add not Value in HTML <source> media Attribute

not Specifies a NOT operator
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The source media attribute</h1>

<picture>
  <source media="screen not (min-width:500px)" srcset="https://horje.com/avatar.png">
  <source media="screen and (min-width:500px)" srcset="https://horje.com/avatar.png">
  <img src="https://horje.com/avatar.png" alt="Horje Icon" style="width:auto;">
</picture>

</body>
</html>

Output should be:

How to add not Value in HTML <source> media Attribute

How to add or/, Value in HTML <source> media Attribute

, Specifies an OR operator
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The source media attribute</h1>

<picture>
  <source media="screen not (min-width:500px)" srcset="https://horje.com/avatar.png">
  <source media="screen or (min-width:500px)" srcset="https://horje.com/avatar.png">
  <img src="https://horje.com/avatar.png" alt="Horje Icon" style="width:auto;">
</picture>

</body>
</html>

Output should be:

How to add or/, Value in HTML <source> media Attribute

How to add all Value in HTML <source> media Attribute

all Suitable for all devices. This is default
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The source media attribute</h1>

<picture>
  <source media="screen not (min-width:500px)" srcset="https://horje.com/avatar.png">
  <source media="all and (orientation: landscape)" srcset="https://horje.com/avatar.png">
  <img src="https://horje.com/avatar.png" alt="Horje Icon" style="width:auto;">
</picture>

</body>
</html>

Output should be:

How to add all Value in HTML <source> media Attribute

How to add aural Value in HTML <source> media Attribute

aural Speech synthesizers
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The source media attribute</h1>

<picture>
  <source media="screen not (min-width:500px)" srcset="https://horje.com/avatar.png">
  <source media="all aural (orientation: landscape)" srcset="https://horje.com/avatar.png">
  <img src="https://horje.com/avatar.png" alt="Horje Icon" style="width:auto;">
</picture>

</body>
</html>

Output should be:

How to add aural Value in HTML <source> media Attribute

How to add braille Value in HTML <source> media Attribute

braille Braille feedback devices
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The source media attribute</h1>

<picture>
  <source media="screen not (min-width:500px)" srcset="https://horje.com/avatar.png">
  <source media="braille and (min-width:500px)" srcset="https://horje.com/avatar.png">
  <img src="https://horje.com/avatar.png" alt="Horje Icon" style="width:auto;">
</picture>

</body>
</html>

Output should be:

How to add braille Value in HTML <source> media Attribute

How to add handheld Value in HTML <source> media Attribute

handheld Handheld devices (small screen, limited bandwidth)
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The source media attribute</h1>

<picture>
  <source media="screen not (min-width:500px)" srcset="https://horje.com/avatar.png">
  <source media="handheld and (min-width:500px)" srcset="https://horje.com/avatar.png">
  <img src="https://horje.com/avatar.png" alt="Horje Icon" style="width:auto;">
</picture>

</body>
</html>

Output should be:

How to add handheld Value in HTML <source> media Attribute

How to add projection Value in HTML <source> media Attribute

projection Projectors
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The source media attribute</h1>

<picture>
  <source media="screen not (min-width:500px)" srcset="https://horje.com/avatar.png">
  <source media="projection and (min-width:500px)" srcset="https://horje.com/avatar.png">
  <img src="https://horje.com/avatar.png" alt="Horje Icon" style="width:auto;">
</picture>

</body>
</html>

Output should be:

How to add projection Value in HTML <source> media Attribute

How to add print Value in HTML <source> media Attribute

print Print preview mode/printed pages
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The source media attribute</h1>

<picture>
  <source media="screen not (min-width:500px)" srcset="https://horje.com/avatar.png">
  <source media="print and (min-width:500px)" srcset="https://horje.com/avatar.png">
  <img src="https://horje.com/avatar.png" alt="Horje Icon" style="width:auto;">
</picture>

</body>
</html>

Output should be:

How to add print Value in HTML <source> media Attribute

How to add screen Value in HTML <source> media Attribute

screen Computer screens
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The source media attribute</h1>

<picture>
  <source media="screen not (min-width:500px)" srcset="https://horje.com/avatar.png">
  <source media="print and (min-width:500px)" srcset="https://horje.com/avatar.png">
  <img src="https://horje.com/avatar.png" alt="Horje Icon" style="width:auto;">
</picture>

</body>
</html>

Output should be:

How to add screen Value in HTML <source> media Attribute

How to add tty Value in HTML <source> media Attribute

tty Teletypes and similar media using a fixed-pitch character grid
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The source media attribute</h1>

<picture>
  <source media="screen not (min-width:500px)" srcset="https://horje.com/avatar.png">
  <source media="tty and (min-width:500px)" srcset="https://horje.com/avatar.png">
  <img src="https://horje.com/avatar.png" alt="Horje Icon" style="width:auto;">
</picture>

</body>
</html>

Output should be:

How to add tty Value in HTML <source> media Attribute

How to add tv Value in HTML <source> media Attribute

tv Television type devices (low resolution, limited scroll ability)
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The source media attribute</h1>

<picture>
  <source media="screen not (min-width:500px)" srcset="https://horje.com/avatar.png">
  <source media="tv and (min-width:500px)" srcset="https://horje.com/avatar.png">
  <img src="https://horje.com/avatar.png" alt="Horje Icon" style="width:auto;">
</picture>

</body>
</html>

Output should be:

How to add tv Value in HTML <source> media Attribute

How to add width Value in HTML <source> media Attribute

width Specifies the width of the targeted display area.
"min-" and "max-" prefixes can be used.
Example: media="screen and (min-width:500px)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The source media attribute</h1>

<picture>
  <source media="screen not (min-width:500px)" srcset="https://horje.com/avatar.png">
  <source media="screen and (min-width:500px)" srcset="https://horje.com/avatar.png">
  <img src="https://horje.com/avatar.png" alt="Horje Icon" style="width:auto;">
</picture>

</body>
</html>

Output should be:

How to add width Value in HTML <source> media Attribute

How to add height Value in HTML <source> media Attribute

height Specifies the height of the targeted display area.
"min-" and "max-" prefixes can be used.
Example: media="screen and (max-height:700px)"
index.html
Example: HTML
<source media="screen and (max-height:700px)" srcset="https://horje.com/avatar.png">

Output should be:

How to add height Value in HTML <source> media Attribute

How to add device-width Value in HTML <source> media Attribute

device-width Specifies the width of the target display/paper.
"min-" and "max-" prefixes can be used.
Example: media="screen and (device-width:500px)"
index.html
Example: HTML
<source media="screen and (device-width:500px)" srcset="https://horje.com/avatar.png">

Output should be:

How to add device-width Value in HTML <source> media Attribute

How to add device-height Value in HTML <source> media Attribute

device-height Specifies the height of the target display/paper.
"min-" and "max-" prefixes can be used.
Example: media="screen and (device-height:500px)"
index.html
Example: PHP
<source media="screen and (device-height:500px)" srcset="https://horje.com/avatar.png">

Output should be:

How to add device-height Value in HTML <source> media Attribute

How to add orientation Value in HTML <source> media Attribute

orientation Specifies the orientation of the target display/paper.
Possible values: "portrait" or "landscape"
Example: media="all and (orientation: landscape)"
index.html
Example: HTML
<source media="all and (orientation: landscape)" srcset="https://horje.com/avatar.png">

Output should be:

How to add orientation Value in HTML <source> media Attribute

How to add aspect-ratio Value in HTML <source> media Attribute

aspect-ratio Specifies the width/height ratio of the targeted display area.
"min-" and "max-" prefixes can be used.
Example: media="screen and (aspect-ratio:16/9)"
index.html
Example: HTML
<source media="screen and (aspect-ratio:16/9)" srcset="https://horje.com/avatar.png">

Output should be:

How to add aspect-ratio Value in HTML <source> media Attribute

How to add device-aspect-ratio Value in HTML <source> media Attribute

device-aspect-ratio Specifies the device-width/device-height ratio of the target display/paper.
"min-" and "max-" prefixes can be used.
Example: media="screen and (aspect-ratio:16/9)"
index.html
Example: HTML
<source media="screen and (aspect-ratio:16/9)" srcset="https://horje.com/avatar.png">

Output should be:

How to add device-aspect-ratio Value in HTML <source> media Attribute

How to add color Value in HTML <source> media Attribute

color Specifies the bits per color of target display.
"min-" and "max-" prefixes can be used.
Example: media="screen and (color:3)"
index.html
Example: HTML
<source media="screen and (color:3)" srcset="https://horje.com/avatar.png">

try
How to add color Value in HTML <source> media Attribute

How to add color-index Value in HTML <source> media Attribute

color-index Specifies the number of colors the target display can handle.
"min-" and "max-" prefixes can be used.
Example: media="screen and (min-color-index:256)"
index.html
Example: HTML
<source media="screen and (min-color-index:256)" srcset="https://horje.com/avatar.png">

Output should be:

How to add color-index Value in HTML <source> media Attribute

How to add monochrome Value in HTML <source> media Attribute

monochrome Specifies the bits per pixel in a monochrome frame buffer.
"min-" and "max-" prefixes can be used.
Example: media="screen and (monochrome:2)"
index.html
Example: HTML
<source media="screen and (min-color-index:256)" srcset="https://horje.com/avatar.png">

Output should be:

How to add monochrome Value in HTML <source> media Attribute

How to add resolution Value in HTML <source> media Attribute

resolution Specifies the pixel density (dpi or dpcm) of the target display/paper.
"min-" and "max-" prefixes can be used.
Example: media="print and (resolution:300dpi)"
index.html
Example: HTML
<source media="print and (resolution:300dpi)" srcset="https://horje.com/avatar.png">

Output should be:

How to add resolution Value in HTML <source> media Attribute

How to add scan Value in HTML <source> media Attribute

scan Specifies scanning method of a tv display.
Possible values are "progressive" and "interlace".
Example: media="tv and (scan:interlace)"
<source media="tv and (scan:interlace)" srcset="https://horje.com/avatar.png">

Output should be:

How to add scan Value in HTML <source> media Attribute

How to add grid Value in HTML <source> media Attribute

grid Specifies if the output device is grid or bitmap.
Possible values are "1" for grid, and "0" otherwise.
Example: media="handheld and (grid:1)"
index.html
Example: HTML
<source media="handheld and (grid:1)" srcset="https://horje.com/avatar.png">

Output should be:

How to add grid Value in HTML <source> media Attribute

How to add HTML <source> size Attribute

sizes   Specifies image sizes for different page layouts
index.html
Example: HTML
<picture>
  <source srcset="https://horje.com/avatar.png 120w,
                  https://horje.com/avatar.png 193w,
                  https://horje.com/avatar.png 278w"
          sizes="(max-width: 710px) 120px,
                 (max-width: 991px) 193px,
                 278px">
  
  <img src="https://horje.com/avatar.png" alt="Gust">
</picture>

Output should be:

How to add HTML <source> size Attribute

How to add HTML <source> src Attribute

Definition and Usage

The src attribute specifies the URL of the media file to play.

This attribute is required when <source> is used in <audio> and <video>.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<source src="URL">

Attribute Values

Value Description
URL Specifies the URL of the media file.

Possible values:

  • An absolute URL - points to another web site (like href="http://www.example.com/horse.ogg")
  • A relative URL - points to a file within a web site (like href="horse.ogg")
index.html
Example: HTML
<audio controls>
  <source src="https://file-examples.com/storage/fe36b23e6a66fc0679c1f86/2017/11/file_example_OOG_1MG.ogg" type="audio/ogg">
  <source src="https://file-examples.com/storage/fe36b23e6a66fc0679c1f86/2017/11/file_example_MP3_700KB.mp3" type="audio/mpeg">
  Your browser does not support the audio element.
</audio>

Output should be:

How to add HTML <source> src Attribute

How to add HTML <source> srcset Attribute

Definition and Usage

The srcset attribute specifies the URL of the image to use in different situations.

This attribute is required when <source> is used in <picture>.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<source srcset="URL">

Attribute Values

Value Description
URL Specifies the URL of the image.

Possible values:

  • An absolute URL - points to another web site (like href="http://www.example.com/flower.jpg")
  • A relative URL - points to a file within a web site (like href="flower.jpg")
index.html
Example: HTML
<source media="screen and (min-color-index:256)" srcset="https://horje.com/avatar.png">

Output should be:

How to add HTML <source> srcset Attribute

How to add HTML <source> type Attribute

Definition and Usage

The type attribute specifies the Internet media type (formerly known as MIME type) of the media resource.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<source type="media_type">

Attribute Values

Value Description
media_type Specifies the Internet media type of the media resource.

Common media types:
For video:
  • video/ogg
  • video/mp4
  • video/webm
For audio:
  • audio/ogg
  • audio/mpeg
Look at IANA Media Types for a complete list of standard media types

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The video element</h1>

<video width="320" height="240" controls>
  <source src="https://www.sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4" type="video/mp4">
  <source src="https://www.sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4" type="video/ogg">
  Your browser does not support the video tag.
</video>

</body>
</html>

Output should be:

How to add HTML <source> type Attribute

# Tips-98) What is HTML <span> Tag

Definition and Usage

The <span> tag is an inline container used to mark up a part of a text, or a part of a document.

The <span> tag is easily styled by CSS or manipulated with JavaScript using the class or id attribute.

The <span> tag is much like the <div> element, but <div> is a block-level element and <span> is an inline element.


Browser Support

Global Attributes

The <span> tag also supports the Global Attributes in HTML.


Event Attributes

The <span> tag also supports the Event Attributes in HTML.

How to create HTML <span> Tag

A <span> element which is used to color a part of a text.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The span element</h1>

<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>

</body>
</html>

Output should be:

How to create HTML <span> Tag

# Tips-99) What is HTML <strike> Tag

Not Supported in HTML5.

The <strike> tag was used in HTML 4 to define strikethrough text.

What to Use Instead of HTML <strike> Tag?

Use the <del> tag to define deleted text.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The del element</h1>

<p>My favorite color is <del>blue</del> <ins>red</ins>!</p>

</body>
</html>

Output should be:

What to Use Instead of HTML <strike> Tag?

How to Use <s> Tag Instead of HTML <strike> Tag?

Use the <s> tag to mark up text that is no longer correct.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The s element</h1>

<p><s>Only 50 tickets left!</s></p>
<p>SOLD OUT!</p>

</body>
</html>

Output should be:

How to Use <s> Tag Instead of HTML <strike> Tag?

# Tips-100) What is HTML <strong> Tag

Definition and Usage

The <strong> tag is used to define text with strong importance. The content inside is typically displayed in bold.

Tip: Use the <b> tag to specify bold text without any extra importance!

Browser Support

Global Attributes

The <strong> tag also supports the Global Attributes in HTML.


Event Attributes

The <strong> tag also supports the Event Attributes in HTML.

How to create HTML <strong> Tag

Define important text in a document.
index.html
Example: HTML
 <strong>This text is important!</strong>

Output should be:

How to create HTML <strong> Tag

# Tips-101) What is HTML <style> Tag

Definition and Usage

The <style> tag is used to define style information (CSS) for a document.

Inside the <style> element you specify how HTML elements should render in a browser.

The <style> element must be included inside the <head> section of the document.


Tips and Notes

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 be used (see example below)!

Tip: To link to an external style sheet, use the <link> tag.

Tip: To learn more about style sheets, please read our CSS Tutorial.


Browser Support

Attributes

Attribute Value Description
media media_query Specifies what media/device the media resource is optimized for
type text/css Specifies the media type of the <style> tag

Global Attributes

The <style> tag also supports the Global Attributes in HTML.


Event Attributes

The <style> tag also supports the Event Attributes in HTML.

How to create HTML <style> Tag

Use of the <style> element to apply a simple style sheet to an HTML document.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
h1 {color:red;}
p {color:blue;}
</style>
</head>
<body>

<h1>This is a heading</h1>
<p>This is a paragraph.</p>

</body>
</html>

Output should be:

How to create HTML <style> Tag

How to add Multiple styles for the same elements in HTML <style> Tag

Multiple styles for the same elements.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
  h1 {color:red;}
  p {color:blue;}
</style>
<style>
  h1 {color:green;}
  p {color:pink;}
</style>
</head>
<body>

<h1>This is a heading</h1>
<p>This is a paragraph.</p>

<p>Notice that if some properties have been defined for the same selector (element) in different style sheets, the value from the last read style sheet will be used!</p>

</body>
</html>

Output should be:

How to add Multiple styles for the same elements in HTML <style> Tag

How to set Default CSS Settings in HTML <style> Tag

Most browsers will display the <style> element with the following default values.

index.html
Example: HTML
<style>
style {
  display: none;
}
</style>

How to add HTML <style> media Attribute in HTML <style> Tag

Definition and Usage

The media attribute specifies what media/device the CSS style is optimized for.

This attribute is used to specify that the style is for special devices (like iPhone), speech or print media.

Tip: This attribute can accept several values.


Browser Support

Syntax

<style media="value">

Possible Operators

Value Description
and Specifies an AND operator
not Specifies a NOT operator
, Specifies an OR operator

 

Devices

Value Description
all Default. Suitable for all devices
aural Speech synthesizers
braille Braille feedback devices
handheld Handheld devices (small screen, limited bandwidth)
projection Projectors
print Print preview mode/printed pages
screen Computer screens
tty Teletypes and similar media using a fixed-pitch character grid
tv Television type devices (low resolution, limited scroll ability)

Values

Value Description
width Specifies the width of the targeted display area.
"min-" and "max-" prefixes can be used.
Example: media="screen and (min-width:500px)"
height Specifies the height of the  targeted display area.
"min-" and "max-" prefixes can be used.
Example: media="screen and (max-height:700px)"
device-width Specifies the width of the target display/paper.
"min-" and "max-" prefixes can be used.
Example: media="screen and (device-width:500px)"
device-height Specifies the height of the target display/paper.
"min-" and "max-" prefixes can be used.
Example: media="screen and (device-height:500px)"
orientation Specifies the orientation of the target display/paper.
Possible values: "portrait" or "landscape"
Example: media="all and (orientation: landscape)"
aspect-ratio Specifies the width/height ratio of the targeted display area.
"min-" and "max-" prefixes can be used.
Example: media="screen and (aspect-ratio:16/9)"
device-aspect-ratio Specifies the device-width/device-height ratio of the target display/paper.
"min-" and "max-" prefixes can be used.
Example: media="screen and (aspect-ratio:16/9)"
color Specifies the bits per color of target display.
"min-" and "max-" prefixes can be used.
Example: media="screen and (color:3)"
color-index Specifies the number of colors the target display can handle.
"min-" and "max-" prefixes can be used.
Example: media="screen and (min-color-index:256)"
monochrome Specifies the bits per pixel in a monochrome frame buffer.
"min-" and "max-" prefixes can be used.
Example: media="screen and (monochrome:2)"
resolution Specifies the pixel density (dpi or dpcm) of the target display/paper.
"min-" and "max-" prefixes can be used.
Example: media="print and (resolution:300dpi)"
scan Specifies scanning method of a tv display.
Possible values are "progressive" and "interlace".
Example: media="tv and (scan:interlace)"
grid Specifies if the output device is grid or bitmap.
Possible values are "1" for grid, and "0" otherwise.
Example: media="handheld and (grid:1)"
index.html
Example: HTML
 <style media="print">
h1 {color:#000000;}
p {color:#000000;}
body {background-color:#FFFFFF;}
</style> 

try
How to add HTML <style> media Attribute in HTML <style> Tag

How to add and Value in HTML <style> media Attribute

and Specifies an AND operator
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
h1 {color:#FF0000;}
p {color:#0000FF;}
body {background-color:#FFEFD6;}
</style>

<style media="screen and (min-width:500px)">
h1 {color:#000000;}
p {color:#000000;}
body {background-color:#FFFFFF;}
</style>
</head>
<body>

<h1>Horje Example</h1>
<p><a href="/learn/816/what-is-html-style-tag" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to add and Value in HTML <style> media Attribute

How to add not Value in HTML <style> media Attribute

not Specifies a NOT operator
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
h1 {color:#FF0000;}
p {color:#0000FF;}
body {background-color:#FFEFD6;}
</style>

<style media="screen not (color:3)">
h1 {color:#000000;}
p {color:#000000;}
body {background-color:#FFFFFF;}
</style>
</head>
<body>

<h1>Horje Example</h1>
<p><a href="/learn/816/what-is-html-style-tag" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to add not Value in HTML <style> media Attribute

How to add , Value in HTML <style> media Attribute

, Specifies an OR operator
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
h1 {color:#FF0000;}
p {color:#0000FF;}
body {background-color:#FFEFD6;}
</style>

<style media="screen , (color:3)">
h1 {color:#000000;}
p {color:#000000;}
body {background-color:#FFFFFF;}
</style>
</head>
<body>

<h1>Horje Example</h1>
<p><a href="/learn/816/what-is-html-style-tag" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to add , Value in HTML <style> media Attribute

How to add all Value in HTML <style> media Attribute

all Default. Suitable for all devices
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
h1 {color:#FF0000;}
p {color:#0000FF;}
body {background-color:#FFEFD6;}
</style>

<style media="all and (orientation: landscape)">
h1 {color:#000000;}
p {color:#000000;}
body {background-color:#FFFFFF;}
</style>
</head>
<body>

<h1>Horje Example</h1>
<p><a href="/learn/816/what-is-html-style-tag" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to add all Value in HTML <style> media Attribute

How to add aural Value in HTML <style> media Attribute

aural Speech synthesizers
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
h1 {color:#FF0000;}
p {color:#0000FF;}
body {background-color:#FFEFD6;}
</style>

<style media="aural and (orientation: landscape)">
h1 {color:#000000;}
p {color:#000000;}
body {background-color:#FFFFFF;}
</style>
</head>
<body>

<h1>Horje Example</h1>
<p><a href="/learn/816/what-is-html-style-tag" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to add aural Value in HTML <style> media Attribute

How to add braille Value in HTML <style> media Attribute

braille Braille feedback devices
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
h1 {color:#FF0000;}
p {color:#0000FF;}
body {background-color:#FFEFD6;}
</style>

<style media="braille and (orientation: landscape)">
h1 {color:#000000;}
p {color:#000000;}
body {background-color:#FFFFFF;}
</style>
</head>
<body>

<h1>Horje Example</h1>
<p><a href="/learn/816/what-is-html-style-tag" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to add braille Value in HTML <style> media Attribute

How to add handheld Value in HTML <style> media Attribute

handheld Handheld devices (small screen, limited bandwidth)
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
h1 {color:#FF0000;}
p {color:#0000FF;}
body {background-color:#FFEFD6;}
</style>

<style media="handheld and (orientation: landscape)">
h1 {color:#000000;}
p {color:#000000;}
body {background-color:#FFFFFF;}
</style>
</head>
<body>

<h1>Horje Example</h1>
<p><a href="/learn/816/what-is-html-style-tag" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to add handheld Value in HTML <style> media Attribute

How to add projection Value in HTML <style> media Attribute

projection Projectors
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
h1 {color:#FF0000;}
p {color:#0000FF;}
body {background-color:#FFEFD6;}
</style>

<style media="projection and (orientation: landscape)">
h1 {color:#000000;}
p {color:#000000;}
body {background-color:#FFFFFF;}
</style>
</head>
<body>

<h1>Horje Example</h1>
<p><a href="/learn/816/what-is-html-style-tag" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to add projection Value in HTML <style> media Attribute

How to add print Value in HTML <style> media Attribute

print Print preview mode/printed pages
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
h1 {color:#FF0000;}
p {color:#0000FF;}
body {background-color:#FFEFD6;}
</style>

<style media="print and (resolution:300dpi)">
h1 {color:#000000;}
p {color:#000000;}
body {background-color:#FFFFFF;}
</style>
</head>
<body>

<h1>Horje Example</h1>
<p><a href="/learn/816/what-is-html-style-tag" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to add print Value in HTML <style> media Attribute

How to add screen Value in HTML <style> media Attribute

screen Computer screens
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
h1 {color:#FF0000;}
p {color:#0000FF;}
body {background-color:#FFEFD6;}
</style>

<style media="screen and (min-width:500px)">
h1 {color:#000000;}
p {color:#000000;}
body {background-color:#FFFFFF;}
</style>
</head>
<body>

<h1>Horje Example</h1>
<p><a href="/learn/816/what-is-html-style-tag" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to add screen Value in HTML <style> media Attribute

How to add tty Value in HTML <style> media Attribute

tty Teletypes and similar media using a fixed-pitch character grid
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
h1 {color:#FF0000;}
p {color:#0000FF;}
body {background-color:#FFEFD6;}
</style>

<style media="tty and (min-width:500px)">
h1 {color:#000000;}
p {color:#000000;}
body {background-color:#FFFFFF;}
</style>
</head>
<body>

<h1>Horje Example</h1>
<p><a href="/learn/816/what-is-html-style-tag" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to add tty Value in HTML <style> media Attribute

How to add tv Value in HTML <style> media Attribute

tv Television type devices (low resolution, limited scroll ability)
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
h1 {color:#FF0000;}
p {color:#0000FF;}
body {background-color:#FFEFD6;}
</style>

<style media="tv and (scan:interlace)">
h1 {color:#000000;}
p {color:#000000;}
body {background-color:#FFFFFF;}
</style>
</head>
<body>

<h1>Horje Example</h1>
<p><a href="/learn/816/what-is-html-style-tag" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to add tv Value in HTML <style> media Attribute

How to add width Value in HTML <style> media Attribute

width Specifies the width of the targeted display area.
"min-" and "max-" prefixes can be used.
Example: media="screen and (min-width:500px)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
h1 {color:#FF0000;}
p {color:#0000FF;}
body {background-color:#FFEFD6;}
</style>

<style media="screen and (min-width:500px)">
h1 {color:#000000;}
p {color:#000000;}
body {background-color:#FFFFFF;}
</style>
</head>
<body>

<h1>Horje Example</h1>
<p><a href="/learn/816/what-is-html-style-tag" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to add width Value in HTML <style> media Attribute

How to add height Value in HTML <style> media Attribute

height Specifies the height of the  targeted display area.
"min-" and "max-" prefixes can be used.
Example: media="screen and (max-height:700px)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
h1 {color:#FF0000;}
p {color:#0000FF;}
body {background-color:#FFEFD6;}
</style>

<style media="screen and (max-height:700px)">
h1 {color:#000000;}
p {color:#000000;}
body {background-color:#FFFFFF;}
</style>
</head>
<body>

<h1>Horje Example</h1>
<p><a href="/learn/816/what-is-html-style-tag" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to add height Value in HTML <style> media Attribute

How to add device-width Value in HTML <style> media Attribute

device-width Specifies the width of the target display/paper.
"min-" and "max-" prefixes can be used.
Example: media="screen and (device-width:500px)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
h1 {color:#FF0000;}
p {color:#0000FF;}
body {background-color:#FFEFD6;}
</style>

<style media="screen and (device-width:500px)">
h1 {color:#000000;}
p {color:#000000;}
body {background-color:#FFFFFF;}
</style>
</head>
<body>

<h1>Horje Example</h1>
<p><a href="/learn/816/what-is-html-style-tag" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to add device-width Value in HTML <style> media Attribute

How to add device-height Value in HTML <style> media Attribute

device-height Specifies the height of the target display/paper.
"min-" and "max-" prefixes can be used.
Example: media="screen and (device-height:500px)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
h1 {color:#FF0000;}
p {color:#0000FF;}
body {background-color:#FFEFD6;}
</style>

<style media="screen and (device-height:500px)">
h1 {color:#000000;}
p {color:#000000;}
body {background-color:#FFFFFF;}
</style>
</head>
<body>

<h1>Horje Example</h1>
<p><a href="/learn/816/what-is-html-style-tag" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to add device-height Value in HTML <style> media Attribute

How to add orientation Value in HTML <style> media Attribute

orientation Specifies the orientation of the target display/paper.
Possible values: "portrait" or "landscape"
Example: media="all and (orientation: landscape)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
h1 {color:#FF0000;}
p {color:#0000FF;}
body {background-color:#FFEFD6;}
</style>

<style media="all and (orientation: landscape)">
h1 {color:#000000;}
p {color:#000000;}
body {background-color:#FFFFFF;}
</style>
</head>
<body>

<h1>Horje Example</h1>
<p><a href="/learn/816/what-is-html-style-tag" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to add orientation Value in HTML <style> media Attribute

How to add aspect-ratio Value in HTML <style> media Attribute

aspect-ratio Specifies the width/height ratio of the targeted display area.
"min-" and "max-" prefixes can be used.
Example: media="screen and (aspect-ratio:16/9)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
h1 {color:#FF0000;}
p {color:#0000FF;}
body {background-color:#FFEFD6;}
</style>

<style media="screen and (aspect-ratio:16/9)">
h1 {color:#000000;}
p {color:#000000;}
body {background-color:#FFFFFF;}
</style>
</head>
<body>

<h1>Horje Example</h1>
<p><a href="/learn/816/what-is-html-style-tag" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to add aspect-ratio Value in HTML <style> media Attribute

How to add device-aspect-ratio Value in HTML <style> media Attribute

device-aspect-ratio Specifies the device-width/device-height ratio of the target display/paper.
"min-" and "max-" prefixes can be used.
Example: media="screen and (aspect-ratio:16/9)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
h1 {color:#FF0000;}
p {color:#0000FF;}
body {background-color:#FFEFD6;}
</style>

<style media="screen and (aspect-ratio:16/9)">
h1 {color:#000000;}
p {color:#000000;}
body {background-color:#FFFFFF;}
</style>
</head>
<body>

<h1>Horje Example</h1>
<p><a href="/learn/816/what-is-html-style-tag" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to add device-aspect-ratio Value in HTML <style> media Attribute

How to add color Value in HTML <style> media Attribute

color Specifies the bits per color of target display.
"min-" and "max-" prefixes can be used.
Example: media="screen and (color:3)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
h1 {color:#FF0000;}
p {color:#0000FF;}
body {background-color:#FFEFD6;}
</style>

<style media="screen and (color:3)">
h1 {color:#000000;}
p {color:#000000;}
body {background-color:#FFFFFF;}
</style>
</head>
<body>

<h1>Horje Example</h1>
<p><a href="/learn/816/what-is-html-style-tag" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to add color Value in HTML <style> media Attribute

How to add color-index Value in HTML <style> media Attribute

color-index Specifies the number of colors the target display can handle.
"min-" and "max-" prefixes can be used.
Example: media="screen and (min-color-index:256)"

 

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
h1 {color:#FF0000;}
p {color:#0000FF;}
body {background-color:#FFEFD6;}
</style>

<style media="screen and (min-color-index:256)">
h1 {color:#000000;}
p {color:#000000;}
body {background-color:#FFFFFF;}
</style>
</head>
<body>

<h1>Horje Example</h1>
<p><a href="/learn/816/what-is-html-style-tag" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to add color-index Value in HTML <style> media Attribute

How to add monochrome Value in HTML <style> media Attribute

monochrome Specifies the bits per pixel in a monochrome frame buffer.
"min-" and "max-" prefixes can be used.
Example: media="screen and (monochrome:2)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
h1 {color:#FF0000;}
p {color:#0000FF;}
body {background-color:#FFEFD6;}
</style>

<style media="screen and (monochrome:2)">
h1 {color:#000000;}
p {color:#000000;}
body {background-color:#FFFFFF;}
</style>
</head>
<body>

<h1>Horje Example</h1>
<p><a href="/learn/816/what-is-html-style-tag" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to add monochrome Value in HTML <style> media Attribute

How to add resolution Value in HTML <style> media Attribute

resolution Specifies the pixel density (dpi or dpcm) of the target display/paper.
"min-" and "max-" prefixes can be used.
Example: media="print and (resolution:300dpi)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
h1 {color:#FF0000;}
p {color:#0000FF;}
body {background-color:#FFEFD6;}
</style>

<style media="tv and (scan:interlace)">
h1 {color:#000000;}
p {color:#000000;}
body {background-color:#FFFFFF;}
</style>
</head>
<body>

<h1>Horje Example</h1>
<p><a href="/learn/816/what-is-html-style-tag" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to add resolution Value in HTML <style> media Attribute

How to add scan Value in HTML <style> media Attribute

scan Specifies scanning method of a tv display.
Possible values are "progressive" and "interlace".
Example: media="tv and (scan:interlace)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
h1 {color:#FF0000;}
p {color:#0000FF;}
body {background-color:#FFEFD6;}
</style>

<style media="tv and (scan:interlace)">
h1 {color:#000000;}
p {color:#000000;}
body {background-color:#FFFFFF;}
</style>
</head>
<body>

<h1>Horje Example</h1>
<p><a href="/learn/816/what-is-html-style-tag" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to add scan Value in HTML <style> media Attribute

How to add grid Value in HTML <style> media Attribute

grid Specifies if the output device is grid or bitmap.
Possible values are "1" for grid, and "0" otherwise.
Example: media="handheld and (grid:1)"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
h1 {color:#FF0000;}
p {color:#0000FF;}
body {background-color:#FFEFD6;}
</style>

<style media="handheld and (grid:1)">
h1 {color:#000000;}
p {color:#000000;}
body {background-color:#FFFFFF;}
</style>
</head>
<body>

<h1>Horje Example</h1>
<p><a href="/learn/816/what-is-html-style-tag" target="_blank">Click here</a> to open this page in a new window (without the tryit part).</p>
<p>If you print this page, or open it in print preview, you will see that it is styled with the media="print" stylesheet. The "print" stylesheet contains black text on white background.</p>

</body>
</html>

Output should be:

How to add grid Value in HTML <style> media Attribute

How to add HTML <style> type Attribute

Definition and Usage

The type attribute specifies the Internet media type (formerly known as MIME type) of the <style> tag.

The type attribute identifies the content between the <style> and </style> tags.

The default value is "text/css", which indicates that the content is CSS.


Browser Support

Syntax

<style type="media_type">

Use the type attribute to specify the media type of the <style> tag :

Attribute Values

Value Description
media_type The Internet media type of the style sheet. For now, the only supported value is "text/css". Look at IANA Media Types for a complete list of standard media types
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
h1 {color:red;}
p {color:blue;}
</style>
</head>
<body>

<h1>This is a heading</h1>
<p>This is a paragraph.</p>

</body>
</html>

Output should be:

How to add HTML <style> type Attribute

# Tips-102) What is HTML <sub> Tag

Definition and Usage

The <sub> tag defines subscript text. Subscript text appears half a character below the normal line, and is sometimes rendered in a smaller font. Subscript text can be used for chemical formulas, like H2O.

Tip: Use the <sup> tag to define superscripted text.


Browser Support

Global Attributes

The <sub> tag also supports the Global Attributes in HTML.


Event Attributes

The <sub> tag also supports the Event Attributes in HTML.


How to create HTML <sub> Tag

It subscripts text.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The sub and sup elements</h1>

<p>This text contains <sub>subscript</sub> text.</p>
<p>This text contains <sup>superscript</sup> text.</p>

</body>
</html>

Output should be:

How to create HTML <sub> Tag

How to set Default CSS Settings in HTML <sub> Tag

Most browsers will display the <sub> element with the following default values.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
sub {
  vertical-align: sub;
  font-size: smaller;
}
</style>
</head>
<body>

<p>A sub element is displayed like this:</p>

<p>This text contains <sub>subscript text</sub></p>

<p>Change the default CSS settings to see the effect.</p>

</body>
</html>

Output should be:

How to set Default CSS Settings in HTML <sub> Tag

# Tips-103) What is HTML <summary> Tag

Definition and Usage

The <summary> tag defines a visible heading for the <details> element. The heading can be clicked to view/hide the details.

Note: The <summary> element should be the first child element of the <details> element.


Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Global Attributes

The <summary> tag also supports the Global Attributes in HTML.


Event Attributes

The <summary> tag also supports the Event Attributes in HTML.

How to create HTML <summary> Tag

It is using the <summary> element.
index.html
Example: HTML
 <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> 

Output should be:

How to create HTML <summary> Tag

How to use CSS to style <details> and <summary>

More Example.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
details > summary {
  padding: 4px;
  width: 200px;
  background-color: #eeeeee;
  border: none;
  box-shadow: 1px 1px 2px #bbbbbb;
  cursor: pointer;
}

details > p {
  background-color: #eeeeee;
  padding: 4px;
  margin: 0;
  box-shadow: 1px 1px 2px #bbbbbb;
}
</style>
</head>
<body>

<h1>The details and summary elements + CSS</h1>

<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>

</body>
</html>

Output should be:

How to use CSS to style <details> and <summary>

How to set Default CSS Settings in HTML <summary> Tag

Most browsers will display the <summary> element with the following default values.

index.html
Example: HTML
<style>
summary {
  display: block;
}
</style>

Output should be:

How to set Default CSS Settings in HTML <summary> Tag

# Tips-104) What is HTML <sup> Tag

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].

Tip: Use the <sub> tag to define subscript text.


Browser Support

Global Attributes

The <sup> tag also supports the Global Attributes in HTML.


Event Attributes

The <sup> tag also supports the Event Attributes in HTML.

How to create HTML <sup> Tag

It superscripts text.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The sub and sup elements</h1>

<p>This text contains <sub>subscript</sub> text.</p>
<p>This text contains <sup>superscript</sup> text.</p>

</body>
</html>

Output should be:

How to create HTML <sup> Tag

How to set Default CSS Settings in HTML <sup> Tag

Most browsers will display the <sup> element with the following default values.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
sup {
    vertical-align: super;
    font-size: smaller;
}
</style>
</head>
<body>

<p>A sup element is displayed like this:</p>

<p>This text contains <sup>superscript text</sup></p>

<p>Change the default CSS settings to see the effect.</p>

</body>
</html>

Output should be:

How to set Default CSS Settings in HTML <sup> Tag

# Tips-105) What is HTML <svg> Tag

Definition and Usage

The <svg> tag defines a container for SVG graphics.

SVG has several methods for drawing paths, boxes, circles, text, and graphic images.

To learn more about SVG, please read our SVG Tutorial.


Browser Support

How to create HTML <svg> Tag

It draws a circle.
index.html
Example: HTML
<svg width="100" height="100">
  <circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />
  Sorry, your browser does not support inline SVG.
</svg>

Output should be:

How to create HTML <svg> Tag

How to Draw a rectangle HTML <svg> Tag

Draw a rectangle.

index.html
Example: HTML
 <svg width="400" height="100">
  <rect width="400" height="100" style="fill:rgb(0,0,255);stroke-width:10;stroke:rgb(0,0,0)" />
</svg> 

Output should be:

How to Draw a rectangle HTML <svg> Tag

How to Draw a square with rounded corners HTML <svg> Tag

The svg element.

index.html
Example: HTML
 <svg width="400" height="180">
  <rect x="50" y="20" rx="20" ry="20" width="150" height="150" style="fill:red;stroke:black;stroke-width:5;opacity:0.5" />
</svg> 

Output should be:

How to Draw a square with rounded corners HTML <svg> Tag

How to Draw a star HTML <svg> Tag

Draw a star.

index.html
Example: HTML
 <svg width="300" height="200">
  <polygon points="100,10 40,198 190,78 10,78 160,198"
  style="fill:lime;stroke:purple;stroke-width:5;fill-rule:evenodd;" />
</svg> 

Output should be:

How to Draw a star HTML <svg> Tag

How to Draw an SVG logo HTML <svg> Tag

Draw an SVG logo.

index.html
Example: HTML
 <svg height="130" width="500">
<defs>
<linearGradient id="grad1" x1="0%" y1="0%" x2="100%" y2="0%">
  <stop offset="0%" style="stop-color:rgb(255,255,0);stop-opacity:1" />
  <stop offset="100%" style="stop-color:rgb(255,0,0);stop-opacity:1" />
</linearGradient>
</defs>

<ellipse cx="100" cy="70" rx="85" ry="55" fill="url(#grad1)" />

<text fill="#ffffff" font-size="45" font-family="Verdana" x="50" y="86">SVG</text>
</svg> 

Output should be:

How to Draw an SVG logo HTML <svg> Tag

# Tips-106) What is HTML <table> Tag

Definition and Usage

The <table> tag defines an HTML table.

An HTML table consists of one <table> element and one or more <tr>, <th>, and <td> elements.

The <tr> element defines a table row, the <th> element defines a table header, and the <td> element defines a table cell.

An HTML table may also include <caption>, <colgroup>, <thead>, <tfoot>, and <tbody> elements.


Browser Support

Global Attributes

The <table> tag also supports the Global Attributes in HTML.


Event Attributes

The <table> tag also supports the Event Attributes in HTML.

 

 

How to create HTML <table>

It is a simple HTML table, containing two columns and two rows.
index.html
Example: HTML
 <table>
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
</table> 

Output should be:

How to create HTML <table>

How to add collapsed borders to a table (with CSS) on HTML <table> Tag

Table with Collapsed Borders.

index.html
Example: HTML
 <html>
<head>
<style>
table, th, td {
  border: 1px solid black;
  border-collapse: collapse;
}
</style>
</head>
<body>

<table>
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
  <tr>
    <td>February</td>
    <td>$80</td>
  </tr>
</table>

</body>
</html> 

Output should be:

How to add collapsed borders to a table (with CSS) on HTML <table> Tag

How to right-align a table (with CSS) on HTML <table> Tag

This is some text to be wrapped around the table. This is some text to be wrapped around the table. This is some text to be wrapped around the table.

index.html
Example: HTML
 <table style="float:right">
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
  <tr>
    <td>February</td>
    <td>$80</td>
  </tr>
</table> 

Output should be:

How to right-align a table (with CSS) on HTML <table> Tag

How to center-align a table (with CSS) on HTML <table> Tag

To center a table, set left and right margin to auto.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
  border: 1px solid black;
}
table.center {
  margin-left: auto; 
  margin-right: auto;
}
</style>
</head>
<body>

<h1>Center a Table</h1>
<p>To center a table, set left and right margin to auto:</p>

<table class="center">
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
  <tr>
    <td>February</td>
    <td>$80</td>
  </tr>
</table>

</body>
</html>

Output should be:

How to center-align a table (with CSS) on HTML <table> Tag

How to add background-color to a table (with CSS) o HTML <table> Tag

background-color to a table (with CSS)

index.html
Example: HTML
 <table style="background-color:#00FF00">
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
  <tr>
    <td>February</td>
    <td>$80</td>
  </tr>
</table> 

Output should be:

How to add background-color to a table (with CSS) o HTML <table> Tag

How to add padding to a table (with CSS) on HTML <table> Tag

See Example.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
  border: 1px solid black;
}

th, td {
  padding: 10px;
}
</style>
</head>
<body>

<h1>Add Padding to a Table</h1>

<table>
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
  <tr>
    <td>February</td>
    <td>$80</td>
  </tr>
</table>

</body>
</html>

Output should be:

How to add padding to a table (with CSS) on HTML <table> Tag

How to set table width (with CSS) on HTML <table> Tag

Add a Specific Width to a Table.

index.html
Example: HTML
 <table style="width:400px">
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
  <tr>
    <td>February</td>
    <td>$80</td>
  </tr>
</table> 

Output should be:

How to set table width (with CSS) on HTML <table> Tag

How to create table headers using HTML <table> Tag

There are two examples.

  1. Horizontal headers.
  2. Vertical headers.
index.html
Example: HTML
 <table>
  <tr>
    <th>Name</th>
    <th>Email</th>
    <th>Phone</th>
  </tr>
  <tr>
    <td>John Doe</td>
    <td>[email protected]</td>
    <td>123-45-678</td>
  </tr>
</table> 

Output should be:

How to create table headers using HTML <table> Tag

How to create a table with a caption on HTML <table> Tag

The caption element

index.html
Example: HTML
 <table>
  <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>$80</td>
  </tr>
</table> 

Output should be:

How to create a table with a caption on HTML <table> Tag

How to define table cells that span more than one row or one column

Colspan and rowspan

index.html
Example: HTML
 <table>
  <tr>
    <th>Name</th>
    <th>Email</th>
    <th colspan="2">Phone</th>
  </tr>
  <tr>
    <td>John Doe</td>
    <td>[email protected]</td>
    <td>123-45-678</td>
    <td>212-00-546</td>
  </tr>
</table> 

Output should be:

How to define table cells that span more than one row or one column

How to set Default CSS Settings on HTML <table> Tag

Most browsers will display the <table> element with the following default values.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
table { 
  display: table;
  border-collapse: separate;
  border-spacing: 2px;
  border-color: gray;
}
</style>
</head>
<body>

<table>
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
  <tr>
    <td>February</td>
    <td>$80</td>
  </tr>
</table>

</body>
</html>

Output should be:

How to set Default CSS Settings on HTML <table> Tag

# Tips-107) What is HTML <tbody> Tag

Definition and Usage

The <tbody> tag is used to group the body content in an HTML table.

The <tbody> element is used in conjunction with the <thead> and <tfoot> elements to specify each part of a table (body, header, footer).

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.

Note: The <tbody> element must have one or more <tr> tags inside.

The <tbody> tag must be used in the following context: As a child of a <table> element, after any <caption>, <colgroup>, and <thead> elements.

Tip: The <thead>, <tbody>, and <tfoot> elements will not affect the layout of the table by default. However, you can use CSS to style these elements (see example below)!


Browser Support

Global Attributes

The <tbody> tag also supports the Global Attributes in HTML.


Event Attributes

The <tbody> tag also supports the Event Attributes in HTML.

How to create HTML <tbody> Tag

An HTML table with a <thead>, <tbody>, and a <tfoot> element.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
  border: 1px solid black;
}
</style>
</head>
<body>

<h1>The thead, tbody, and tfoot elements</h1>

<table>
  <thead>
    <tr>
      <th>Month</th>
      <th>Savings</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>January</td>
      <td>$100</td>
    </tr>
    <tr>
      <td>February</td>
      <td>$80</td>
    </tr>
  </tbody>
  <tfoot>
    <tr>
      <td>Sum</td>
      <td>$180</td>
    </tr>
  </tfoot>
</table>

</body>
</html>

Output should be:

How to create HTML <tbody> Tag

How to set Style <thead>, <tbody>, and <tfoot> with CSS

The thead, tbody, and tfoot elements - Styled with CSS

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
thead {color:green;}
tbody {color:blue;}
tfoot {color:red;}

table, th, td {
  border: 1px solid black;
}
</style>
</head>
<body>

<h1>The thead, tbody, and tfoot elements - Styled with CSS</h1>

<table>
  <thead>
    <tr>
      <th>Month</th>
      <th>Savings</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>January</td>
      <td>$100</td>
    </tr>
    <tr>
      <td>February</td>
      <td>$80</td>
    </tr>
  </tbody>
  <tfoot>
    <tr>
      <td>Sum</td>
      <td>$180</td>
    </tr>
  </tfoot>
</table>

</body>
</html>

Output should be:

How to set Style <thead>, <tbody>, and <tfoot> with CSS

How to align content inside <tbody> (with CSS)

Right-align content in tbody

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
  border: 1px solid black;
}
</style>
</head>
<body>

<h1>Right-align content in tbody</h1>

<table style="width:100%">
  <thead>
    <tr>
      <th>Month</th>
      <th>Savings</th>
    </tr>
  </thead>
  <tbody style="text-align:right">
    <tr>
      <td>January</td>
      <td>$100</td>
    </tr>
    <tr>
      <td>February</td>
      <td>$80</td>
    </tr>
  </tbody>
</table>

</body>
</html>

Output should be:

How to align content inside <tbody> (with CSS)

How to vertical align content inside <tbody> (with CSS)

Vertical-align content in tbody

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
  border: 1px solid black;
}
</style>
</head>
<body>

<h1>Vertical-align content in tbody</h1>

<table style="width:50%;">
    <tr>
      <th>Month</th>
      <th>Savings</th>
    </tr>
  <tbody style="vertical-align:bottom">
    <tr style="height:100px">
      <td>January</td>
      <td>$100</td>
    </tr>
    <tr style="height:100px">
      <td>February</td>
      <td>$80</td>
    </tr>
  </tbody>  
</table>

</body>
</html>

Output should be:

How to vertical align content inside <tbody> (with CSS)

How to set Default CSS Settings on HTML <tbody> Tag

Most browsers will display the <tbody> element with the following default values.

index.html
Example: HTML
<style>
tbody {
  display: table-row-group;
  vertical-align: middle;
  border-color: inherit;
}
</style>

# Tips-108) What is HTML <td> Tag

Definition and Usage

The <td> tag defines a standard data cell in an HTML table.

An HTML table has two kinds of cells:

  • Header cells - contains header information (created with the <th> element)
  • Data cells - contains data (created with the <td> element)

The text in <td> elements are regular and left-aligned by default.

The text in <th> elements are bold and centered by default. 


Browser Support

Attributes

Attribute Value Description
colspan number Specifies the number of columns a cell should span
headers header_id Specifies one or more header cells a cell is related to
rowspan number Sets the number of rows a cell should span

Global Attributes

The <td> tag also supports the Global Attributes in HTML.


Event Attributes

The <td> tag also supports the Event Attributes in HTML.

How to create HTML <td> Tag

It is a simple HTML table, with two rows and four table cells.
index.html
Example: HTML
 <table>
  <tr>
    <td>Cell A</td>
    <td>Cell B</td>
  </tr>
  <tr>
    <td>Cell C</td>
    <td>Cell D</td>
  </tr>
</table> 

Output should be:

How to create HTML <td> Tag

How to align content inside <td> (with CSS)

Right-align content in some data cells

index.html
Example: HTML
 <table style="width:100%">
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td style="text-align:right">$100</td>
  </tr>
  <tr>
    <td>February</td>
    <td style="text-align:right">$80</td>
  </tr>
</table> 

Output should be:

How to align content inside <td> (with CSS)

How to add background-color to table cell (with CSS)

Add Background Color to td

index.html
Example: HTML
 <table>
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td style="background-color:#FF0000">January</td>
    <td style="background-color:#00FF00">$100</td>
  </tr>
 </table> 

Output should be:

How to add background-color to table cell (with CSS)

How to set the height of a table cell (with CSS)

Add Specific Height to td

index.html
Example: HTML
 <table>
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td style="height:100px">January</td>
    <td style="height:100px">$100</td>
  </tr>
</table> 

Output should be:

How to set the height of a table cell (with CSS)

How to specify no word-wrapping in table cell (with CSS)

Add Nowrap to td

index.html
Example: HTML
 <table>
  <tr>
    <th>Poem</th>
  </tr>
  <tr>
    <td style="white-space:nowrap">Never increase, beyond what is necessary, the number of entities required to explain anything</td>
  </tr>
</table> 

Output should be:

How to specify no word-wrapping in table cell (with CSS)

How to vertical align content inside <td> (with CSS)

Vertical-align content in td

index.html
Example: HTML
 <table style="width:50%;">
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr style="height:100px">
    <td style="vertical-align:bottom">January</td>
    <td style="vertical-align:bottom">$100</td>
  </tr>
</table> 

Output should be:

How to vertical align content inside <td> (with CSS)

How to set the width of a table cell (with CSS)

Add a width i percent for tds

index.html
Example: HTML
 <table style="width:100%">
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td style="width:70%">January</td>
    <td style="width:30%">$100</td>
  </tr>
</table> 

Output should be:

How to set the width of a table cell (with CSS)

How to create table headers

Table Headers
  1. Horizontal headers
  2. Vertical headers
index.html
Example: HTML
 <table>
  <tr>
    <th>Name</th>
    <th>Email</th>
    <th>Phone</th>
  </tr>
  <tr>
    <td>John Doe</td>
    <td>[email protected]</td>
    <td>123-45-678</td>
  </tr>
</table> 

Output should be:

How to create table headers

How to create a table with a caption

The caption element

index.html
Example: HTML
 <table>
  <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>$80</td>
  </tr>
</table> 

Output should be:

How to create a table with a caption

How to define table cells that span more than one row or one column on HTML <TD>

Colspan and rowspan
  1. Cell that spans two columns
  2. Cell that spans two rows

 

index.html
Example: HTML
 <table>
  <tr>
    <th>Name</th>
    <th>Email</th>
    <th colspan="2">Phone</th>
  </tr>
  <tr>
    <td>John Doe</td>
    <td>[email protected]</td>
    <td>123-45-678</td>
    <td>212-00-546</td>
  </tr>
</table> 

Output should be:

How to define table cells that span more than one row or one column on HTML <TD>

How to set Default CSS Settings on HTML <td>

Most browsers will display the <td> element with the following default values.

index.html
Example: HTML
<style>
td {
  display: table-cell;
  vertical-align: inherit;
}
</style>
 <table>
  <tr>
    <td>Cell A</td>
    <td>Cell B</td>
  </tr>
  <tr>
    <td>Cell C</td>
    <td>Cell D</td>
  </tr>
</table> 


# Tips-109) What is HTML <template> Tag

Definition and Usage

The <template> tag is used as a container to hold some HTML content hidden from the user when the page loads.

The content inside <template> can be rendered later with a JavaScript.

You can use the <template> tag if you have some HTML code you want to use over and over again, but not until you ask for it. To do this without the <template> tag, you have to create the HTML code with JavaScript to prevent the browser from rendering the code.


Browser Support

Global Attributes

The <template> tag supports the Global Attributes in HTML.

How to create HTML <template> Tag

Use <template> to hold some content that will be hidden when the page loads. Use JavaScript to display it:
index.html
Example: HTML
 <button onclick="showContent()">Show hidden content</button>

<template>
  <h2>Flower</h2>
  <img src="img_white_flower.jpg" width="214" height="204">
</template>

<script>
function showContent() {
  let temp = document.getElementsByTagName("template")[0];
  let clon = temp.content.cloneNode(true);
  document.body.appendChild(clon);
}
</script> 

Output should be:

How to create HTML <template> Tag

How to fill the web page with one new div element on HTML <template> Tag

Fill the web page with one new div element for each item in an array. The HTML code of each div element is inside the template element.

index.html
Example: HTML
 <template>
  <div class="myClass">I like: </div>
</template>

<script>
let myArr = ["Audi", "BMW", "Ford", "Honda", "Jaguar", "Nissan"];
function showContent() {
  let temp, item, a, i;
  temp = document.getElementsByTagName("template")[0];
  item = temp.content.querySelector("div");
  for (i = 0; i < myArr.length; i++) {
    a = document.importNode(item, true);
    a.textContent += myArr[i];
    document.body.appendChild(a);
  }
}
</script> 

Output should be:

How to fill the web page with one new div element on HTML <template> Tag

How to check browser support for <template>

Test template Support

index.html
Example: HTML
<script>
if (document.createElement("template").content) {
  document.write("Your browser supports template!");
} else {
  document.write("Your browser does not supports template!");
}
</script> 

Output should be:

How to check browser support for <template>

# Tips-110) What is HTML <textarea> Tag

Definition and Usage

The <textarea> tag defines a multi-line text input control.

The <textarea> element is often used in a form, to collect user inputs like comments or reviews.

A text area can hold an unlimited number of characters, and the text renders in a fixed-width font (usually Courier).

The size of a text area is specified by the cols and rows attributes (or with CSS).

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 text area will be submitted).

The id attribute is needed to associate the text area with a label. 

Tip: Always add the <label> tag for best accessibility practices!


Browser Support

Attributes

Attribute Value Description
autofocus autofocus Specifies that a text area should automatically get focus when the page loads
cols number Specifies the visible width of a text area
dirname textareaname.dir Specifies that the text direction of the textarea will be submitted
disabled disabled Specifies that a text area should be disabled
form form_id Specifies which form the text area belongs to
maxlength number Specifies the maximum number of characters allowed in the text area
name text Specifies a name for a text area
placeholder text Specifies a short hint that describes the expected value of a text area
readonly readonly Specifies that a text area should be read-only
required required Specifies that a text area is required/must be filled out
rows number Specifies the visible number of lines in a text area
wrap hard
soft
Specifies how the text in a text area is to be wrapped when submitted in a form

Global Attributes

The <textarea> tag also supports the Global Attributes in HTML.


Event Attributes

The <textarea> tag also supports the Event Attributes in HTML.


How to create HTML <textarea> Tag

It is A multi-line text input control (text area).
index.html
Example: HTML
 <label for="w3review">Review of W3Schools:</label>

<textarea id="w3review" name="w3review" rows="4" cols="50">
At horje.com you will learn how to make a website. They offer free tutorials in all web development technologies.
</textarea> 

Output should be:

How to create HTML <textarea> Tag

How to Disable default resize option HTML textarea

The textarea element - Disable default resize option.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
textarea {
  resize: none;
}
</style>
</head>
<body>

<h1>The textarea element - Disable default resize option</h1>

<p><label for="w3review">Review of Horje:</label></p>

<textarea id="w3review" name="w3review" rows="4" cols="50">
At horje.com you will learn how to make a website. They offer free tutorials in all web development technologies.

Output should be:

How to Disable default resize option HTML textarea

How to add HTML <textarea> autofocus Attribute on HTML <textarea> Tag

It is A text area with autofocus.

index.html
Example: HTML
 <textarea autofocus>
At w3schools.com you will learn how to make a website. We offer free tutorials in all web development technologies.
</textarea> 

Output should be:

How to add HTML <textarea> autofocus Attribute on HTML <textarea> Tag

How to add HTML <textarea> cols Attribute

It is A text area with a specified height and width.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The textarea rows and cols attributes</h1>

<textarea rows="4" cols="50">
At horje.com you will learn how to make a website. We offer free tutorials in all web development technologies.
</textarea>

<p>This textarea has 4 visible rows.</p>
<p>You can change that by changing the value of the "rows" attribute.</p>

</body>
</html>

Output should be:

How to add HTML <textarea> cols Attribute

How to add HTML <textarea> dirname Attribute

It is An HTML form where the field's text direction will be submitted.

index.html
Example: HTML
 <form action="/action_page.php">
  Text:
  <textarea name="explanation" dirname="explanation.dir"></textarea>
  <input type="submit" value="Submit">
</form> 

Output should be:

How to add HTML <textarea> dirname Attribute

How to disable HTML <textarea> Attribute

It is A disabled text area.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The textarea disabled attribute</h1>

<textarea disabled>
At horje.com you will learn how to make a website. We offer free tutorials in all web development technologies.
</textarea>

</body>
</html>

Output should be:

How to disable HTML <textarea> Attribute

How to add HTML <textarea> form Attribute

It is A text area located outside a form (but still a part of the form).

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The textarea form attribute</h1>

<form action="/action_page.php" id="usrform">
  Name: <input type="text" name="usrname">
  <input type="submit">
</form>
<br>
<textarea rows="4" cols="50" name="comment" form="usrform">
Enter text here...</textarea>

<p>The text area above is outside the form element, but should still be a part of the form.</p>

</body>
</html>

Output should be:

How to add HTML <textarea> form Attribute

How to add HTML <textarea> maxlength Attribute

It is A text area with a maximum length of 50 characters.

index.html
Example: HTML
 <textarea maxlength="50">
Enter text here...
</textarea> 

Output should be:

How to add HTML <textarea> maxlength Attribute

How to add HTML <textarea> name Attribute

It is A text area with a name attribute.

Definition and Usage

The name attribute specifies a name for a text area.

The name attribute is used to reference elements in a JavaScript, or to reference form data after a form is submitted.

Syntax

<textarea name="text">

Attribute Values

Value Description
text Specifies the name of the text area
index.html
Example: HTML
 <form action="/action_page.php">
  <textarea name="comment">Enter text here...</textarea>
  <input type="submit">
</form> 

Output should be:

How to add HTML <textarea> name Attribute

How to add HTML <textarea> placeholder Attribute

Definition and Usage

The placeholder attribute specifies a short hint that describes the expected value of a text area.

The short hint is displayed in the text area before the user enters a value.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<textarea placeholder="text">

Attribute Values

Value Description
text Specifies a short hint that describes the expected value of the text area

It is A text area with a placeholder text.

index.php
Example: HTML
 <textarea placeholder="Describe yourself here..."></textarea> 

Output should be:

How to add HTML <textarea> placeholder Attribute

How to add HTML <textarea> readonly Attribute

Definition and Usage

The readonly attribute is a boolean attribute.

When present, it specifies that a text area should be read-only.

In a read-only text area, the content cannot be changed, but a user can tab to it, highlight it and copy content from it.

The readonly attribute can be set to keep a user from using a text area until some other condition has been met (like selecting a checkbox, etc.). Then, a JavaScript is required to remove the readonly value, and make the text area editable.


Browser Support

Syntax

<textarea readonly>
index.html
Example: HTML
 <textarea readonly>
At w3schools.com you will learn how to make a website. We offer free tutorials in all web development technologies.
</textarea> 

Output should be:

How to add HTML <textarea> readonly Attribute

How to add HTML <textarea> required Attribute

It is A form with a required text area.

index.html
Example: HTML
 <form action="/action_page.php">
  <textarea name="comment" required></textarea>
  <input type="submit">
</form> 

Output should be:

How to add HTML <textarea> required Attribute

How to create HTML <textarea> rows Attribute

Definition and Usage

The rows attribute specifies the visible height of a text area, in lines.

Note: The size of a textarea can also be specified by the CSS height and width properties.


Browser Support

Syntax

<textarea rows="number">

Attribute Values

Value Description
number Specifies the height of the text area (in lines). Default value is 2
index.html
Example: HTML
 <textarea rows="4" cols="50">
At w3schools.com you will learn how to make a website. We offer free tutorials in all web development technologies.
</textarea> 

Output should be:

How to create HTML <textarea> rows Attribute

How to add HTML <textarea> wrap Attribute

Definition and Usage

The wrap attribute specifies how the text in a text area is to be wrapped when submitted in a form.


Browser Support

Syntax

<textarea wrap="soft|hard">

Attribute Values

Value Description
soft The text in the textarea is not wrapped when submitted in a form. This is default
hard The text in the textarea is wrapped (contains newlines) when submitted in a form. When "hard" is used, the cols attribute must be specified
index.html
Example: HTML
 <textarea rows="2" cols="20" wrap="hard">
At W3Schools you will find free Web-building tutorials.
</textarea> 

Output should be:

How to add HTML <textarea> wrap Attribute

How to add HTML <textarea> soft wrap Attribute

soft The text in the textarea is not wrapped when submitted in a form. This is default
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The textarea wrap attribute</h1>

<form action="/action_page.php">
<textarea rows="2" cols="20" name="usrtxt" wrap="soft">
At horje you will find free Web-building tutorials.
</textarea>
<input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <textarea> soft wrap Attribute

How to add HTML <textarea> hard wrap Attribute

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The textarea wrap attribute</h1>

<form action="/action_page.php">
<textarea rows="2" cols="20" name="usrtxt" wrap="hard">
At horje you will find free Web-building tutorials.
</textarea>
<input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <textarea> hard wrap Attribute

# Tips-111) What is HTML <tfoot> Tag

Definition and Usage

The <tfoot> tag is used to group footer content in an HTML table.

The <tfoot> element is used in conjunction with the <thead> and <tbody> elements to specify each part of a table (footer, header, body).

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.

Note: The <tfoot> element must have one or more <tr> tags inside.

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.

Tip: The <thead>, <tbody>, and <tfoot> elements will not affect the layout of the table by default. However, you can use CSS to style these elements (see example below)!


Browser Support

Global Attributes

The <tfoot> tag also supports the Global Attributes in HTML.


Event Attributes

The <tfoot> tag also supports the Event Attributes in HTML.

How to create HTML <tfoot> Tag

It is An HTML table with a <thead>, <tbody>, and a <tfoot> element.
index.html
Example: HTML
 <table>
  <thead>
    <tr>
      <th>Month</th>
      <th>Savings</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>January</td>
      <td>$100</td>
    </tr>
    <tr>
      <td>February</td>
      <td>$80</td>
    </tr>
  </tbody>
  <tfoot>
    <tr>
      <td>Sum</td>
      <td>$180</td>
    </tr>
  </tfoot>
</table> 

Output should be:

How to create HTML <tfoot> Tag

How to set Style <thead>, <tbody>, and <tfoot> with CSS

The thead, tbody, and tfoot elements - Styled with CSS.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
thead {color:green;}
tbody {color:blue;}
tfoot {color:red;}

table, th, td {
  border: 1px solid black;
}
</style>
</head>
<body>

<h1>The thead, tbody, and tfoot elements - Styled with CSS</h1>

<table>
  <thead>
    <tr>
      <th>Month</th>
      <th>Savings</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>January</td>
      <td>$100</td>
    </tr>
    <tr>
      <td>February</td>
      <td>$80</td>
    </tr>
  </tbody>
  <tfoot>
    <tr>
      <td>Sum</td>
      <td>$180</td>
    </tr>
  </tfoot>
</table>

</body>
</html>

Output should be:

How to set Style <thead>, <tbody>, and <tfoot> with CSS

How to align content inside <tfoot> (with CSS)

Center-align content in tfoot.

index.html
Example: HTML
<table style="width:100%">
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
  <tr>
    <td>February</td>
    <td>$80</td>
  </tr>
  <tfoot style="text-align:center">
    <tr>
      <td>Sum</td>
      <td>$180</td>
    </tr>
  </tfoot>  
</table>

Output should be:

How to align content inside <tfoot> (with CSS)

How to vertical align content inside <tfoot> (with CSS)

Vertical-align content in tfoot

index.html
Example: HTML
<table style="width:50%">
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
  <tr>
    <td>February</td>
    <td>$80</td>
  </tr>
  <tfoot style="vertical-align:bottom">
    <tr style="height:100px">
      <td>Sum</td>
      <td>$180</td>
    </tr>
  </tfoot>  
</table>

Output should be:

How to vertical align content inside <tfoot> (with CSS)

How to set Default CSS Settings for HTML <tfoot> Tag

Most browsers will display the <tfoot> element with the following default values:

index.html
Example: HTML
<style>
tfoot {
  display: table-footer-group;
  vertical-align: middle;
  border-color: inherit;
}
</style>
 <table>
  <thead>
    <tr>
      <th>Month</th>
      <th>Savings</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>January</td>
      <td>$100</td>
    </tr>
    <tr>
      <td>February</td>
      <td>$80</td>
    </tr>
  </tbody>
  <tfoot>
    <tr>
      <td>Sum</td>
      <td>$180</td>
    </tr>
  </tfoot>
</table> 

Output should be:

How to set Default CSS Settings for HTML <tfoot> Tag

# Tips-112) What is HTML <th> Tag

Definition and Usage

The <th> tag defines a header cell in an HTML table.

An HTML table has two kinds of cells:

  • Header cells - contains header information (created with the <th> element)
  • Data cells - contains data (created with the <td> element)

The text in <th> elements are bold and centered by default.

The text in <td> elements are regular and left-aligned by default.


Browser Support

Attributes

Attribute Value Description
abbr text Specifies an abbreviated version of the content in a header cell
colspan number Specifies the number of columns a header cell should span
headers header_id Specifies one or more header cells a cell is related to
rowspan number Specifies the number of rows a header cell should span
scope col
colgroup
row
rowgroup
Specifies whether a header cell is a header for a column, row, or group of columns or rows

Global Attributes

The <th> tag also supports the Global Attributes in HTML.


Event Attributes

The <th> tag also supports the Event Attributes in HTML.

How to create HTML <th> Tag

It is A simple HTML table with three rows, two header cells and four data cells.
index.html
Example: HTML
 <table>
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
  <tr>
    <td>February</td>
    <td>$80</td>
  </tr>
</table> 

Output should be:

How to create HTML <th> Tag

How to align content inside <th> (with CSS)

Left-align content in th.

index.html
Example: HTML
 <table style="width:100%">
  <tr>
    <th style="text-align:left">Month</th>
    <th style="text-align:left">Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
  <tr>
    <td>February</td>
    <td>$80</td>
  </tr>
</table> 

Output should be:

How to align content inside <th> (with CSS)

How to add background-color to table header cell (with CSS)

Add Background Color to th.

index.html
Example: HTML
 <table>
  <tr>
    <th style="background-color:#FF0000">Month</th>
    <th style="background-color:#00FF00">Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
 </table> 

Output should be:

How to add background-color to table header cell (with CSS)

How to set the height of a table header cell (with CSS)

Add Specific Height to th.

index.html
Example: HTML
 <table>
  <tr>
    <th style="height:100px">Month</th>
    <th style="height:100px">Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
</table> 

Output should be:

How to set the height of a table header cell (with CSS)

How to specify no word-wrapping in table header cell (with CSS)

Add Nowrap to th.

index.html
Example: HTML
 <table>
  <tr>
    <th>Month</th>
    <th style="white-space:nowrap">My Savings for a new car</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
</table> 

Output should be:

How to specify no word-wrapping in table header cell (with CSS)

How to vertical align content inside <th> (with CSS)

Vertical-align content in th.

index.html
Example: HTML
 <table style="width:50%;">
  <tr style="height:100px">
    <th style="vertical-align:bottom">Month</th>
    <th style="vertical-align:bottom">Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
</table> 

Output should be:

How to vertical align content inside <th> (with CSS)

How to set the width of a table header cell (with CSS)

Add a width i percent for ths.

index.html
Example: HTML
 <table style="width:100%">
  <tr>
    <th style="width:70%">Month</th>
    <th style="width:30%">Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
</table> 

Output should be:

How to set the width of a table header cell (with CSS)

How to create table headers with th

Table Headers
  1. Horizontal headers
  2. Vertical headers
index.html
Example: HTML
 <table>
  <tr>
    <th>Name</th>
    <th>Email</th>
    <th>Phone</th>
  </tr>
  <tr>
    <td>John Doe</td>
    <td>[email protected]</td>
    <td>123-45-678</td>
  </tr>
</table> 

Output should be:

How to create table headers with th

How to create a table with a caption with th

The caption element.

index.html
Example: HTML
 <table>
  <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>$80</td>
  </tr>
</table> 

Output should be:

How to create a table with a caption with th

How to define table cells that span more than one row or one column on th

Colspan and rowspan.

index.html
Example: HTML
 <table>
  <tr>
    <th>Name</th>
    <th>Email</th>
    <th colspan="2">Phone</th>
  </tr>
  <tr>
    <td>John Doe</td>
    <td>[email protected]</td>
    <td>123-45-678</td>
    <td>212-00-546</td>
  </tr>
</table> 

Output should be:

How to define table cells that span more than one row or one column on th

How to set Default CSS Settings on HTML th Tag

Most browsers will display the <th> element with the following default values.

index.html
Example: HTML
<style>
th {
  display: table-cell;
  vertical-align: inherit;
  font-weight: bold;
  text-align: center;
}
</style>
 <table>
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
  <tr>
    <td>February</td>
    <td>$80</td>
  </tr>
</table> 

Output should be:

How to set Default CSS Settings on HTML th Tag

How to add HTML <th> abbr Attribute

Use of the abbr attribute in an HTML table:

Definition and Usage

The abbr attribute specifies a shorter version of the content in a header cell.

Note: The abbr attribute has no visual effect in ordinary web browsers, but can be used by screen readers. 


Browser Support

Syntax

<th abbr="text">

Attribute Values

Value Description
text A short description of the header cell content
index.html
Example: HTML
 <table>
  <tr>
    <th abbr="Make">Toy manufacturer</th>
    <th abbr="Model">Vehicle model</th>
  </tr>
  <tr>
    <td>Bruder Toys</td>
    <td>Cross Country Vehicle</td>
  </tr>
  <tr>
    <td>Bruder Toys</td>
    <td>DHL Lorry</td>
  </tr>
</table> 

Output should be:

How to add HTML <th> abbr Attribute

How to add HTML <th> colspan Attribute

It is An HTML table with a header cell that spans two columns.

Definition and Usage

The colspan attribute defines the number of columns a header cell should span.


Browser Support

Note: Only Firefox supports colspan="0", which has a special meaning (look below in the "Attribute Values" table).


Syntax

<th colspan="number">

Attribute Values

Value Description
number Sets the number of columns a header cell should span. Note: colspan="0" tells the browser to span the cell to the last column of the column group (colgroup)
index.html
Example: HTML
 <table>
  <tr>
    <th colspan="2">Monthly Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
  <tr>
    <td>February</td>
    <td>$80</td>
  </tr>
</table> 

Output should be:

How to add HTML <th> colspan Attribute

How to add HTML <th> headers Attribute

It Specify the <th> element each header cell is related to.

Definition and Usage

The headers attribute specifies one or more header cells a header cell is related to.

Note: The headers attribute has no visual effect in ordinary web browsers, but can be used by screen readers. 


Browser Support

Syntax

<th headers="header_id">

Attribute Values

Value Description
header_id Specifies a space-separated list of id's to one or more header cells the header cell is related to
index.html
Example: HTML
 <table>
  <tr>
    <th id="name" colspan="2">Name</th>
  </tr>
  <tr>
    <th headers="name">Firsname</th>
    <th headers="name">Lastname</th>
  </tr>
</table> 

Output should be:

How to add HTML <th> headers Attribute

How to add HTML <th> rowspan Attribute

It is An HTML table with a header cell that spans three rows.

Definition and Usage

The rowspan attribute defines the number of rows a header cell should span.


Browser Support

Syntax

<th rowspan="number">

Attribute Values

Value Description
number Sets the number of rows a header cell should span. Note: rowspan="0" tells the browser to span the cell to the last row of the table section (thead, tbody, or tfoot)

 

index.html
Example: HTML
 <table>
  <tr>
    <th>Month</th>
    <th>Savings</th>
    <th rowspan="3">Savings for holiday!</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
  <tr>
    <td>February</td>
    <td>$80</td>
  </tr>
</table> 

Output should be:

How to add HTML <th> rowspan Attribute

How to add HTML <th> scope Attribute

It Specify that the two header cells are headers for columns.

Definition and Usage

The scope attribute specifies whether a header cell is a header for a column, row, or group of columns or rows.

Note: The scope attribute has no visual effect in ordinary web browsers, but can be used by screen readers. 


Browser Support

Syntax

<th scope="col|row|colgroup|rowgroup">

Attribute Values

Value Description
col Specifies that the cell is a header for a column
row Specifies that the cell is a header for a row
colgroup Specifies that the cell is a header for a group of columns
rowgroup Specifies that the cell is a header for a group of rows
index.html
Example: HTML
 <table>
  <tr>
    <th></th>
    <th scope="col">Month</th>
    <th scope="col">Savings</th>
  </tr>
  <tr>
    <td>1</td>
    <td>January</td>
    <td>$100</td>
  </tr>
  <tr>
    <td>2</td>
    <td>February</td>
    <td>$80</td>
  </tr>
</table> 

Output should be:

How to add HTML <th> scope Attribute

# Tips-113) What is HTML <thead> Tag

Definition and Usage

The <thead> tag is used to group header content in an HTML table.

The <thead> element is used in conjunction with the <tbody> and <tfoot> elements to specify each part of a table (header, body, footer).

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.

Note: The <thead> element must have one or more <tr> tags inside.

The <thead> tag must be used in the following context: As a child of a <table> element, after any <caption> and <colgroup> elements, and before any <tbody>, <tfoot>, and <tr> elements.

Tip: The <thead>, <tbody>, and <tfoot> elements will not affect the layout of the table by default. However, you can use CSS to style these elements (see example below)!


Browser Support

Global Attributes

The <thead> tag also supports the Global Attributes in HTML.


Event Attributes

The <thead> tag also supports the Event Attributes in HTML.

How to create HTML <thead> Tag

It is An HTML table with a <thead>, <tbody>, and a <tfoot> element.
index.html
Example: HTML
 <table>
  <thead>
    <tr>
      <th>Month</th>
      <th>Savings</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>January</td>
      <td>$100</td>
    </tr>
    <tr>
      <td>February</td>
      <td>$80</td>
    </tr>
  </tbody>
  <tfoot>
    <tr>
      <td>Sum</td>
      <td>$180</td>
    </tr>
  </tfoot>
</table> 

Output should be:

How to create HTML <thead> Tag

How to set Style <thead>, <tbody>, and <tfoot> with CSS on HTML <thead> Tag

The thead, tbody, and tfoot elements - Styled with CSS.

index.html
Example: HTML
 <html>
<head>
<style>
thead {color: green;}
tbody {color: blue;}
tfoot {color: red;}

table, th, td {
  border: 1px solid black;
}
</style>
</head>
<body>

<table>
  <thead>
    <tr>
      <th>Month</th>
      <th>Savings</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>January</td>
      <td>$100</td>
    </tr>
    <tr>
      <td>February</td>
      <td>$80</td>
    </tr>
  </tbody>
  <tfoot>
    <tr>
      <td>Sum</td>
      <td>$180</td>
    </tr>
  </tfoot>
</table> 

Output should be:

How to set Style <thead>, <tbody>, and <tfoot> with CSS on HTML <thead> Tag

How to align content inside <thead> (with CSS) on HTML <thead> Tag

Left-align content in thead.

index.html
Example: HTML
 <table style="width:100%">
  <thead style="text-align:left">
    <tr>
      <th>Month</th>
      <th>Savings</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>January</td>
      <td>$100</td>
    </tr>
    <tr>
      <td>February</td>
      <td>$80</td>
    </tr>
  </tbody>
</table> 

Output should be:

How to align content inside <thead> (with CSS) on HTML <thead> Tag

How to vertical align content inside <thead> (with CSS) on HTML <thead> Tag

Vertical-align content in thead.

index.html
Example: HTML
 <table style="width:50%;">
  <thead style="vertical-align:bottom">
    <tr style="height:100px">
      <th>Month</th>
      <th>Savings</th>
    </tr>
  </thead>
   <tbody>
    <tr>
      <td>January</td>
      <td>$100</td>
    </tr>
    <tr>
      <td>February</td>
      <td>$80</td>
    </tr>
  </tbody>
</table> 

Output should be:

How to vertical align content inside <thead> (with CSS) on HTML <thead> Tag

How to set Default CSS Settings on HTML <thead> Tag

Most browsers will display the <thead> element with the following default values.

index.html
Example: HTML
<style>
thead {
  display: table-header-group;
  vertical-align: middle;
  border-color: inherit;
}
</style>
 <table>
  <thead>
    <tr>
      <th>Month</th>
      <th>Savings</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>January</td>
      <td>$100</td>
    </tr>
    <tr>
      <td>February</td>
      <td>$80</td>
    </tr>
  </tbody>
  <tfoot>
    <tr>
      <td>Sum</td>
      <td>$180</td>
    </tr>
  </tfoot>
</table> 

Output should be:

How to set Default CSS Settings on HTML <thead> Tag

# Tips-114) What is HTML <time> Tag

Definition and Usage

The <time> tag defines a specific time (or datetime).

The datetime attribute of this element is used translate the time into a machine-readable format so that browsers can offer to add date reminders through the user's calendar, and search engines can produce smarter search results.


Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Attributes

Attribute Value Description
datetime datetime Represent a machine-readable format of the <time> element

Global Attributes

The <time> tag also supports the Global Attributes in HTML.


Event Attributes

The <time> tag also supports the Event Attributes in HTML.

How to create HTML <time> Tag

It will define a time and a date.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The time element</h1>

<p>Open from <time>10:00</time> to <time>21:00</time> every weekday.</p>

<p>I have a date on <time datetime="2008-02-14 20:00">Valentines day</time>.</p>

<p><b>Note:</b> The time element does not render as anything special in any of the major browsers.</p>

</body>
</html>

Output should be:

How to create HTML <time> Tag

How to add HTML <time> datetime Attribute

It is A time element with a machine-readable datetime attribute.

Definition and Usage.
The datetime attribute represent a machine-readable format of a <time> element.

Browser Support

Syntax

<time datetime="YYYY-MM-DDThh:mm:ssTZD">

Attribute Values

Value Description
YYYY-MM-DDThh:mm:ssTZD

or

PTDHMS
The date or time being specified. Explanation of components:
  • YYYY - year (e.g. 2011)
  • MM - month (e.g. 01 for January)
  • DD - day of the month (e.g. 08)
  • T or a space - a separator (required if time is also specified)
  • hh - hour (e.g. 22 for 10.00pm)
  • mm - minutes (e.g. 55)
  • ss - seconds (e.g. 03)
  • TZD - Time Zone Designator (Z denotes Zulu, also known as Greenwich Mean Time)
  • P - a prefix for "Period"
  • D - a prefix for "Days"
  • H - a prefix for "Hours"
  • M - a prefix for "Minutes"
  • S - a prefix for "Seconds"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The time datetime attribute</h1>

<p>I have a date on <time datetime="2017-02-14 20:00">Valentines day</time>.</p>

<p><b>Note:</b> The time element does not render as anything special in any of the major browsers.</p>

</body>
</html>

Output should be:

How to add HTML <time> datetime Attribute

How to add various date and time format in HTML

Examples of valid datetime values.

index.html
Example: HTML

Dates:
<time datetime="1914">  <!-- means the year 1914 -->
<time datetime="1914-12">  <!-- means December 1914 -->
<time datetime="1914-12-20">  <!-- means 20 December 1914 -->
<time datetime="12-20">  <!-- means 20 December any year -->
<time datetime="1914-W15">  <!-- means week 15 of year 1914 -->

Date and Times:
<time datetime="1914-12-20T08:00">  <!-- means 20 December 1914 at 8am -->
<time datetime="1914-12-20 08:00">  <!-- also means 20 December 1914 at 8am -->
<time datetime="1914-12-20 08:30:45">  <!-- with minutes and seconds -->
<time datetime="1914-12-20 08:30:45.687">  <!-- with minutes, seconds, and milliseconds -->

Times:
<time datetime="08:00">  <!-- means 8am -->
<time datetime="08:00-03:00">  <!-- means 8am in Rio de Janeiro (UTC-3 hours)  -->
<time datetime="08:00+03:00">  <!-- means 8am in Madagascar (UTC+3 hours)  -->

Durations:
<time datetime="P2D">  <!-- means a duration of 2 days -->
<time datetime="PT15H10M">  <!-- means a duration of 15 hours and 10 minutes --> 


# Tips-115) What is HTML <title> Tag

Definition and Usage

The <title> tag defines the title of the document. The title must be text-only, and it is shown in the browser's title bar or in the page's tab.

The <title> tag is required in HTML documents!

The contents of a page title is very important for search engine optimization (SEO)! The page title is used by search engine algorithms to decide the order when listing pages in search results.

The <title> element:

  • defines a title in the browser toolbar
  • provides a title for the page when it is added to favorites
  • displays a title for the page in search-engine results

Here are some tips for creating good titles:

  • Go for a longer, descriptive title (avoid one- or two-word titles)
  • Search engines will display about 50-60 characters of the title, so try not to have titles longer than that
  • Do not use just a list of words as the title (this may reduce the page's position in search results)

So, try to make the title as accurate and meaningful as possible!

Note: You can NOT have more than one <title> element in an HTML document.

Global Attributes

The <title> tag also supports the Global Attributes in HTML.

How to create HTML <title> Tag

It Defines a title for your HTML document. It will show a title of your HTML Page in Browser.
index.html
Example: HTML
<title>HTML Elements Reference</title>

Output should be:

How to create HTML <title> Tag

# Tips-116) What is HTML <tr> Tag

Definition and Usage

The <tr> tag defines a row in an HTML table.

A <tr> element contains one or more <th> or <td> elements.


Browser Support

Global Attributes

The <tr> tag also supports the Global Attributes in HTML.


Event Attributes

The <tr> tag also supports the Event Attributes in HTML.

How to create HTML <tr> Tag

It is A simple HTML table with three rows; one header row and two data rows.
index.html
Example: HTML
 <table>
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
  <tr>
    <td>February</td>
    <td>$80</td>
  </tr>
</table> 

Output should be:

How to create HTML <tr> Tag

How to align content inside <tr> (with CSS) on HTML <tr> Tag

Right-align content in second table row.

index.html
Example: HTML
 <table style="width:100%">
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr style="text-align:right">
    <td>January</td>
    <td>$100</td>
  </tr>
</table> 

Output should be:

How to align content inside <tr> (with CSS) on HTML <tr> Tag

How to add background-color to a table row (with CSS) on HTML <tr> Tag

Add background color to first table row.

index.html
Example: HTML
 <table>
  <tr style="background-color:#FF0000">
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
 </table> 

Output should be:

How to add background-color to a table row (with CSS) on HTML <tr> Tag

How to vertical align content inside <tr> (with CSS) on HTML <tr> Tag

Vertical align content in table rows.

index.html
Example: HTML
 <table style="height:200px">
  <tr  style="vertical-align:top">
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr style="vertical-align:bottom">
    <td>January</td>
    <td>$100</td>
  </tr>
</table> 

Output should be:

How to vertical align content inside <tr> (with CSS) on HTML <tr> Tag

How to create table headers on HTML <tr> Tag

Table Headers
  1. Horizontal headers
  2. Vertical headers
index.html
Example: HTML
 <table>
  <tr>
    <th>Name</th>
    <th>Email</th>
    <th>Phone</th>
  </tr>
  <tr>
    <td>John Doe</td>
    <td>[email protected]</td>
    <td>123-45-678</td>
  </tr>
</table> 

Output should be:

How to create table headers on HTML <tr> Tag

How to create a table with a caption on HTML <tr> Tag

The caption element.

index.html
Example: HTML
 <table>
  <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>$80</td>
  </tr>
</table> 

Output should be:

How to create a table with a caption on HTML <tr> Tag

How to define table cells that span more than one row or one column on HTML <tr> Tag

Colspan and rowspan
  1. Cell that spans two columns.
  2. Cell that spans two rows.
index.html
Example: HTML
 <table>
  <tr>
    <th>Name</th>
    <th>Email</th>
    <th colspan="2">Phone</th>
  </tr>
  <tr>
    <td>John Doe</td>
    <td>[email protected]</td>
    <td>123-45-678</td>
    <td>212-00-546</td>
  </tr>
</table> 

Output should be:

How to define table cells that span more than one row or one column on HTML <tr> Tag

How to set Default CSS Settings on HTML <tr> Tag

Most browsers will display the <tr> element with the following default values.

index.html
Example: HTML
<style>
tr {
  display: table-row;
  vertical-align: inherit;
  border-color: inherit;
}
</style>
 <table>
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
  <tr>
    <td>February</td>
    <td>$80</td>
  </tr>
</table> 


# Tips-117) What is HTML <track> Tag

Definition and Usage

The <track> tag specifies text tracks for <audio> or <video> elements.

This element is used to specify subtitles, caption files or other files containing text, that should be visible when the media is playing.

Tracks are formatted in WebVTT format (.vtt files).


Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Optional Attributes

Attribute Value Description
default default Specifies that the track is to be enabled if the user's preferences do not indicate that another track would be more appropriate
kind captions
chapters
descriptions
metadata
subtitles
Specifies the kind of text track
label text Specifies the title of the text track
src URL Required. Specifies the URL of the track file
srclang language_code Specifies the language of the track text data (required if kind="subtitles")

Global Attributes

The <track> tag also supports the Global Attributes in HTML.


Event Attributes

The <track> tag also supports the Event Attributes in HTML.

How to create HTML <track> Tag

It is A video with subtitle tracks for two languages.

index.html
Example: HTML
<video width="320" height="240" controls>
  <source src="forrest_gump.mp4" type="video/mp4">
  <source src="forrest_gump.ogg" type="video/ogg">
  <track src="fgsubtitles_en.vtt" kind="subtitles" srclang="en" label="English">
  <track src="fgsubtitles_no.vtt" kind="subtitles" srclang="no" label="Norwegian">
</video>

Output should be:

How to create HTML <track> Tag

How to add HTML <track> default Attribute on HTML <track> Tag

Definition and Usage

It is A video with two subtitle tracks. "English" subtitle is the default.

The default attribute is a boolean attribute.

When present, it specifies that the track is to be enabled if the user's preferences do not indicate that another track would be more appropriate.

Note: There must only be one <track> element with a default attribute per <media> element.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<track src="subtitles_en.vtt" default>
index.html
Example: HTML
 <video width="320" height="240" controls>
  <source src="https://www.sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4" type="video/mp4">
  <source src="https://upload.wikimedia.org/wikipedia/commons/c/c8/Example.ogg" type="video/ogg">
  <track src="fgsubtitles_en.vtt" kind="subtitles" srclang="en" label="English" default>
  <track src="fgsubtitles_no.vtt" kind="subtitles" srclang="no" label="Norwegian">
</video> 

Output should be:

How to add HTML <track> default Attribute on HTML <track> Tag

How to add HTML <track> kind Attribute on HTML <track> Tag

It is A video with two subtitle tracks.

index.html
Example: HTML
 <video width="320" height="240" controls>
  <source src="https://www.sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4" type="video/mp4">
  <source src="https://upload.wikimedia.org/wikipedia/commons/c/c8/Example.ogg" type="video/ogg">
  <track src="fgsubtitles_en.vtt" kind="subtitles" srclang="en" label="English">
  <track src="fgsubtitles_no.vtt" kind="subtitles" srclang="no" label="Norwegian">
</video>

Output should be:

How to add HTML <track> kind Attribute on HTML <track> Tag

How to add HTML <track> label Attribute on HTML <track> Tag

It is A video with two subtitle tracks, both with a label defined.

Definition and Usage

The label attribute specifies the title of the text track, and is used by the browser when listing available text tracks.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<track src="subtitles_en.vtt" kind="subtitles" srclang="en" label="English">

Attribute Values

Value Description
label Specifies the title of the text track
index.html
Example: HTML
 <video width="320" height="240" controls>
  <source src="https://www.sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4" type="video/mp4">
  <source src="https://upload.wikimedia.org/wikipedia/commons/c/c8/Example.ogg" type="video/ogg">
  <track src="fgsubtitles_en.vtt" kind="subtitles" srclang="en" label="English">
  <track src="fgsubtitles_no.vtt" kind="subtitles" srclang="no" label="Norwegian">
</video>

Output should be:

How to add HTML <track> label Attribute on HTML <track> Tag

How to add HTML <track> src Attribute on HTML <track> Tag

It is A video with two subtitle tracks.

Definition and Usage

The required src attribute specifies the URL of the track file.

Tracks are formatted in WebVTT format (.vtt files). 


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<track src=URL>

Attribute Values

Value Description
URL Specifies the URL of the track
index.html
Example: HTML
 <video width="320" height="240" controls>
  <source src="https://www.sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4" type="video/mp4">
  <source src="https://upload.wikimedia.org/wikipedia/commons/c/c8/Example.ogg" type="video/ogg">
  <track src="fgsubtitles_en.vtt" kind="subtitles" srclang="en" label="English">
  <track src="fgsubtitles_no.vtt" kind="subtitles" srclang="no" label="Norwegian">
</video>

Output should be:

How to add HTML <track> src Attribute on HTML <track> Tag

How to add HTML <track> srclang Attribute on HTML <track> Tag

It is A video with two subtitle tracks.

Definition and Usage

The srclang attribute specifies the language of the track text data.

This attribute is required if kind="subtitles".

Tip: To view all available language codes, go to our Language code reference.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<track src="subtitles_en.vtt" kind="subtitles" srclang="en">

Attribute Values

Value Description
language_code Specifies a two-letter language code that specifies the language of the track text data
index.html
Example: HTML
 <video width="320" height="240" controls>
  <source src="https://www.sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4" type="video/mp4">
  <source src="https://upload.wikimedia.org/wikipedia/commons/c/c8/Example.ogg" type="video/ogg">
  <track src="fgsubtitles_en.vtt" kind="subtitles" srclang="en" label="English">
  <track src="fgsubtitles_no.vtt" kind="subtitles" srclang="no" label="Norwegian">
</video>

Output should be:

How to add HTML <track> srclang Attribute on HTML <track> Tag

# Tips-118) What is HTML <tt> Tag

Not Supported in HTML5.

The <tt> tag was used in HTML 4 to define teletype text.


What to Use Instead?

Consider the <kbd> element (for keyboard input), the <var> element (for variables), the <code> element (for computer code), the <samp> element (for computer output), or use CSS instead.

What to Use Instead of HTML <tt> Tag?

It Defines a teletype/monospace font for a <p> element (with CSS).
index.html
Example: HTML
 <p style="font-family:'Lucida Console', monospace">This text is monospace text.</p> 

Output should be:

What to Use Instead of HTML <tt> Tag?

# Tips-119) What is HTML <u> Tag

Definition and Usage

The <u> tag represents some text that is unarticulated and styled differently from normal text, such as misspelled words or proper names in Chinese text. The content inside is typically displayed with an underline. You can change this with CSS (see example below). 

Tip: Avoid using the <u> element where it could be confused for a hyperlink!


Browser Support

Global Attributes

The <u> tag also supports the Global Attributes in HTML.


Event Attributes

The <u> tag also supports the Event Attributes in HTML.

How to create HTML <u> Tag

It is marked up a misspelled word with the <u> tag.
index.html
Example: HTML
 <p>This is some <u>mispeled</u> text.</p> 

Output should be:

How to create HTML <u> Tag

How to Use CSS to style misspelled text

The u element + CSS.  This is some mispeled text.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
.spelling-error {
  text-decoration-line: underline;
  text-decoration-style: wavy;
  text-decoration-color: red;
}
</style>
</head>
<body>

<h1>The u element + CSS</h1>

<p>This is some <u class="spelling-error">mispeled</u> text.</p>

</body>
</html>

Output should be:

How to Use CSS to style misspelled text

How to set Default CSS Settings on HTML <u> Tag

Most browsers will display the <u> element with the following default values,

A u element is displayed like this:

Some underlined text

Change the default CSS settings to see the effect.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
u { 
  text-decoration: underline;
}
</style>
</head>
<body>

<p>A u element is displayed like this:</p>

<u>Some underlined text</u>

<p>Change the default CSS settings to see the effect.</p>

</body>
</html>

Output should be:

How to set Default CSS Settings on HTML <u> Tag

# Tips-120) What is HTML <ul> Tag

Definition and Usage

The <ul> tag defines an unordered (bulleted) list.

Use the <ul> tag together with the <li> tag to create unordered lists.

Tip: Use CSS to style lists.

Tip: For ordered lists, use the <ol> tag. 


Browser Support

Global Attributes

The <ul> tag also supports the Global Attributes in HTML.


Event Attributes

The <ul> tag also supports the Event Attributes in HTML.

How to create HTML <ul> Tag

It is an An unordered HTML list.
index.html
Example: HTML
 <ul>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ul> 

Output should be:

How to create HTML <ul> Tag

How to Set the different list style types (with CSS) on HTML <ul> Tag

All the different list types for ul with CSS.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>All the different list types for ul with CSS</h1>

<ul style="list-style-type:circle">
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ul>

<ul style="list-style-type:disc">
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ul>

<ul style="list-style-type:square">
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ul>

</body>
</html>

Output should be:

How to Set the different list style types (with CSS) on HTML <ul> Tag

How to Expand and reduce line-height in lists (with CSS) on

Modify lineheight of lists with CSS.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>Modify lineheight of lists with CSS</h1>

<p>Expand line height in a list:</p>
<ul style="line-height:180%">
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ul>

<p>Reduce line height in a list:</p>
<ul style="line-height:80%">
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ul>

</body>
</html>

Output should be:

How to Expand and reduce line-height in lists (with CSS) on

How to Create a list inside a list (a nested list) on HTML <ul> Tag

A list inside another list.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>A list inside another list</h1>

<ul>
  <li>Coffee</li>
  <li>Tea
    <ul>
      <li>Black tea</li>
      <li>Green tea</li>
    </ul>
  </li>
  <li>Milk</li>
</ul>

</body>
</html>

Output should be:

How to Create a list inside a list (a nested list) on HTML <ul> Tag

How to Create a more complex nested list on

A list in a list in a list.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>A list in a list in a list</h1>

<ul>
  <li>Coffee</li>
  <li>Tea
    <ul>
      <li>Black tea</li>
      <li>Green tea
        <ul>
          <li>China</li>
          <li>Africa</li>
        </ul>
      </li>
    </ul>
  </li>
  <li>Milk</li>
</ul>

</body>
</html>

Output should be:

How to Create a more complex nested list on

How to create Create a more complex nested list on HTML <ul> Tag

A list in a list in a list..

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>A list in a list in a list</h1>

<ul>
  <li>Coffee</li>
  <li>Tea
    <ul>
      <li>Black tea</li>
      <li>Green tea
        <ul>
          <li>China</li>
          <li>Africa</li>
        </ul>
      </li>
    </ul>
  </li>
  <li>Milk</li>
</ul>

</body>
</html>

Output should be:

How to create Create a more complex nested list on HTML <ul> Tag

How to set Default CSS Settings on HTML <ul> Tag

Most browsers will display the <ul> element with the following default values.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
ul {
  display: block;
  list-style-type: disc;
  margin-top: 1em;
  margin-bottom: 1 em;
  margin-left: 0;
  margin-right: 0;
  padding-left: 40px;
}
</style>
</head>
<body>

<p>A ul element is displayed like this:</p>

<ul>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ul>

<p>Change the default CSS settings to see the effect.</p>

</body>
</html>

Output should be:

How to set Default CSS Settings on HTML <ul> Tag

# Tips-121) What is HTML <var> Tag

Definition and Usage

The <var> tag is used to defines a variable in programming or in a mathematical expression. The content inside is typically displayed in italic.

Tip: This tag is not deprecated. However, it is possible to achieve richer effect by using CSS.

Also look at:

Tag Description
<code> Defines a piece of computer code
<samp> Defines sample output from a computer program
<kbd> Defines keyboard input
<pre> Defines preformatted text

Browser Support

Global Attributes

The <var> tag also supports the Global Attributes in HTML.


Event Attributes

The <var> tag also supports the Event Attributes in HTML

How to create HTML <var> Tag

It Defines some text as variables in a document.
index.html
Example: HTML
<p>The area of a triangle is: 1/2 x <var>b</var> x <var>h</var>, where <var>b</var> is the base, and <var>h</var> is the vertical height.</p>

Output should be:

How to create HTML <var> Tag

How to set Default CSS Settings on HTML <var> Tag

Most browsers will display the <var> element with the following default values.

index.html
Example: HTML
<style>
var {
  font-style: italic;
}
</style>
<p>The area of a triangle is: 1/2 x <var>b</var> x <var>h</var>, where <var>b</var> is the base, and <var>h</var> is the vertical height.</p>

Output should be:

How to set Default CSS Settings on HTML <var> Tag

# Tips-122) What is HTML <video> Tag

Definition and Usage

The <video> tag is used to embed video content in a document, such as a movie clip or other video streams.

The <video> tag contains one or more <source> tags with different video sources. The browser will choose the first source it supports.

The text between the <video> and </video> tags will only be displayed in browsers that do not support the <video> element.

There are three supported video formats in HTML: MP4, WebM, and OGG.

Browser MP4 WebM Ogg
Edge YES YES YES
Chrome YES YES YES
Firefox YES YES YES
Safari YES YES NO
Opera YES YES YES

Tips and Notes

Tip: For audio files, look at the <audio> tag.

Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Optional Attributes

Attribute Value Description
autoplay autoplay Specifies that the video will start playing as soon as it is ready
controls controls Specifies that video controls should be displayed (such as a play/pause button etc).
height pixels Sets the height of the video player
loop loop Specifies that the video will start over again, every time it is finished
muted muted Specifies that the audio output of the video should be muted
poster URL Specifies an image to be shown while the video is downloading, or until the user hits the play button
preload auto
metadata
none
Specifies if and how the author thinks the video should be loaded when the page loads
src URL Specifies the URL of the video file
width pixels Sets the width of the video player

Global Attributes

The <video> tag also supports the Global Attributes in HTML.


Event Attributes

The <video> tag also supports the Event Attributes in HTML.


Related Pages

HTML DOM reference: HTML Audio/Video DOM Reference


Default CSS Settings

None.

How to create HTML <video> Tag

It will Play a video in HTML Page.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The video element</h1>

<video width="320" height="240" controls>
  <source src="https://www.sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4" type="video/mp4">
  <source src="https://www.sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4" type="video/ogg">
  Your browser does not support the video tag.
</video>

</body>
</html>

Output should be:

How to create HTML <video> Tag

How to add HTML <video> autoplay Attribute on HTML <video> Tag

Definition and Usage

The autoplay attribute is a boolean attribute.

When present, the video will automatically start playing.

Note: Chromium browsers do not allow autoplay in most cases. However, muted autoplay is always allowed.

Add muted after autoplay to let your video file start playing automatically (but muted). 


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<video autoplay>
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The video autoplay attribute</h1>

<video width="320" height="240" controls autoplay>
  <source src="https://www.sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4" type="video/mp4">
  <source src="https://www.sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4" type="video/ogg">
  Your browser does not support the video tag.
</video>

</body>
</html>

Output should be:

How to add HTML <video> autoplay Attribute on HTML <video> Tag

How to add HTML <video> controls Attribute on HTML <video> Tag

It is A <video> element with browser default controls.

Definition and Usage

The controls attribute is a boolean attribute.

When present, it specifies that video controls should be displayed.

Video controls should include:

  • Play
  • Pause
  • Seeking
  • Volume
  • Fullscreen toggle
  • Captions/Subtitles (when available)
  • Track (when available)

Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<video controls>

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The video controls attribute</h1>

<video width="320" height="240" controls>
  <source src="https://www.sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4" type="video/mp4">
  <source src="https://www.sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4" type="video/ogg">
  Your browser does not support the video tag.
</video>

</body>
</html>

Output should be:

How to add HTML <video> controls Attribute on HTML <video> Tag

How to add HTML <video> height Attribute on HTML <video> Tag

It is A video player with a specified height and width.

Definition and Usage

The height attribute specifies the height of a video player, in pixels.

Tip: Always specify both the height and width attributes for videos. If these attributes are set, the required space for the video is reserved when the page is loaded. However, without these attributes, the browser does not know the size of the video, and cannot reserve the appropriate space to it. The effect will be that the page layout will change during loading (while the video loads).

Note: Do not rescale video with the height and width attributes! Downsizing a large video with these attributes forces a user to download the original video (even if it looks small on the page). The correct way to rescale a video is with a program, before using it on a web page.


Browser Support

Syntax

<video height="pixels">

Attribute Values

Value Description
pixels The height of the video, in pixels (i.e. height="100")
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The video width and height attributes</h1>

<video width="320" height="240" controls>
  <source src="https://www.sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4" type="video/mp4">
  <source src="https://www.sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4" type="video/ogg">
  Your browser does not support the video tag.
</video>

</body>
</html>

Output should be:

How to add HTML <video> height Attribute on HTML <video> Tag

How to add HTML <video> loop Attribute in HTML <video> Tag

It is A video that will start over again, every time it is finished.

Definition and Usage

The loop attribute is a boolean attribute.

When present, it specifies that the video will start over again, every time it is finished.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<video loop>
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The video loop attribute</h1>

<video width="320" height="240" controls loop>
  <source src="https://www.sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4" type="video/mp4">
  <source src="https://www.sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4" type="video/ogg">
  Your browser does not support the video tag.
</video>

</body>
</html>

Output should be:

How to add HTML <video> loop Attribute in HTML <video> Tag

How to add HTML <video> muted Attribute in

Definition and Usage

The muted attribute is a boolean attribute.

When present, it specifies that the audio output of the video should be muted.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<video muted>
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The video muted attribute</h1>

<video width="320" height="240" controls muted>
  <source src="https://www.sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4" type="video/mp4">
  <source src="https://www.sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4" type="video/ogg">
  Your browser does not support the video tag.
</video>

</body>
</html>

Output should be:

How to add HTML <video> muted Attribute in

How to add HTML <video> poster Attribute in HTML <video> Tag

It is A video player with a poster image.

Before playing video, It will show a default image.

Definition and Usage

The poster attribute specifies an image to be shown while the video is downloading, or until the user hits the play button. If this is not included, the first frame of the video will be used instead.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<video poster="URL">

Attribute Values

Value Description
URL Specifies the URL of the image file.

Possible values:

  • An absolute URL - points to another web site (like href="http://www.example.com/poster.jpg")
  • A relative URL - points to a file within a web site (like href="poster.jpg")
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The video poster attribute</h1>

<video width="320" height="240" poster="https://horje.com/avatar.png" controls>
   <source src="https://www.sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4" type="video/mp4">
   <source src="https://www.sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4" type="video/ogg">
   Your browser does not support the video tag.
</video>

</body>
</html>

Output should be:

How to add HTML <video> poster Attribute in HTML <video> Tag

How to add HTML <video> preload Attribute in HTML <video> Tag

Author thinks that the video should NOT be loaded when the page loads.

Definition and Usage

The preload attribute specifies if and how the author thinks that the video should be loaded when the page loads.

The preload attribute allows the author to provide a hint to the browser about what he/she thinks will lead to the best user experience. This attribute may be ignored in some instances.

Note: The preload attribute is ignored if autoplay is present.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<video preload="auto|metadata|none">

Attribute Values

Value Description
auto The author thinks that the browser should load the entire video when the page loads
metadata The author thinks that the browser should load only metadata when the page loads
none The author thinks that the browser should NOT load the video when the page loads
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The video preload attribute</h1>

<video width="320" height="240" controls preload="none">
  <source src="https://www.sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4" type="video/mp4">
  <source src="https://www.sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4" type="video/ogg">
  Your browser does not support the video tag.
</video>

</body>
</html>

Output should be:

How to add HTML <video> preload Attribute in HTML <video> Tag

How to add HTML <video> src Attribute in HTML <video> Tag

It will Play a video.

Definition and Usage

The src attribute specifies the location (URL) of the video file.

The example above uses an Ogg file, and will work in Chrome, Edge, Firefox and Opera.

To play the video in old Internet Explorer and Safari, we must use an MPEG4 file.

To make it work in all browsers - add several <source> elements inside the <video> element. Each <source> elements can link to different video files. The browser will use the first recognized format:

Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

The src attribute is supported in all of the major browsers, however, the file format defined may not be supported in all browsers.


Syntax

<video src="URL">

Attribute Values

Value Description
URL The URL of the video file.

Possible values:

  • An absolute URL - points to another web site (like src="http://www.example.com/movie.ogg")
  • A relative URL - points to a file within a web site (like src="movie.ogg")
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The video src attribute</h1>

<video width="320" height="240" controls src="https://www.sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4">
  Your browser does not support the video tag.
</video>

<p><b>Note:</b> The .ogg fileformat is not supported in old IE and Safari.</p>

</body>
</html>

Output should be:

How to add HTML <video> src Attribute in HTML <video> Tag

More Example of HTML <video> src

Play a video simple.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<video width="320" height="240" controls>
  <source src="https://www.sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4" type="video/mp4">
  <source src="https://www.sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4" type="video/ogg">
  Your browser does not support the video tag.
</video>

</body>
</html>

Output should be:

How to add HTML <video> width Attribute in HTML <video> Tag

This is A video player with a specified width and height.

Definition and Usage

The width attribute specifies the width of a video player, in pixels.

Tip: Always specify both the height and width attributes for videos. If these attributes are set, the required space for the video is reserved when the page is loaded. However, without these attributes, the browser does not know the size of the video, and cannot reserve the appropriate space to it. The effect will be that the page layout will change during loading (while the video loads).

Note: Do not rescale video with the height and width attributes! Downsizing a large video with these attributes forces a user to download the original video (even if it looks small on the page). The correct way to rescale a video is with a program, before using it on a web page.


Browser Support

Syntax

<video width="pixels">

Attribute Values

Value Description
pixels The width of the video, in pixels (i.e. width="100")
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The video width and height attributes</h1>

<video width="320" height="240" controls>
  <source src="https://www.sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4" type="video/mp4">
  <source src="https://www.sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4" type="video/ogg">
  Your browser does not support the video tag.
</video>

</body>
</html>

Output should be:

How to add HTML <video> width Attribute in HTML <video> Tag

# Tips-123) How to add HTML <wbr> Tag

Definition and Usage

The <wbr> (Word Break Opportunity) tag specifies where in a text it would be ok to add a line-break.

Tip: When a word is too long, the browser might break it at the wrong place. You can use the <wbr> element to add word break opportunities.


Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Global Attributes

The <wbr> tag also supports the Global Attributes in HTML.


Event Attributes

The <wbr> tag also supports the Event Attributes in HTML.

How to add HTML <wbr> Tag

This is A text with word break opportunities.
index.html
Example: HTML
 <p>To learn AJAX, you must be familiar with the XML<wbr>Http<wbr>Request Object.</p> 

Output should be:

How to add HTML <wbr> Tag


Share on: