Horje
HTML name Attribute

Definition and Usage

The name attribute specifies a name for an HTML element.

This name attribute can be used to reference the element in a JavaScript.

For a <form> element, the name attribute is  used as a reference when the data is submitted.

For an <iframe> element, the name attribute can be used to target a form submission.

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

For a <meta> element, the name attribute specifies a name for the information/value of the content attribute.

For a <param> element, the name attribute is used together with the value attribute to specify parameters for the plugin specified with the <object> tag.


Applies to

The name attribute can be used on the following elements:

Elements Attribute
<button> name
<fieldset> name
<form> name
<iframe> name
<input> name
<map> name
<meta> name
<object> name
<output> name
<param> name
<select> name
<textarea> name

Browser Support

The name attribute has the following browser support for each element.


How to add Two buttons with equal names, that submit different values when clicked

The button name attribute.
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 Two buttons with equal names, that submit different values when clicked

How to add A <fieldset> with a name attribute

Fieldset Example.
index.html
Example: HTML
 <fieldset name="personalia">
  Name: <input type="text"><br>
  Email: <input type="text"><br>
</fieldset> 

Output should be:

How to add A <fieldset> with a name attribute

How to add An HTML form with a name attribute

Form Example.
index.html
Example: HTML
 <form action="/action_page.php" method="get" name="myForm">
  First name: <input type="text" name="fname"><br>
  Last name: <input type="text" name="lname"><br>
  <input type="button" onclick="formSubmit()" value="Send form data!">
</form> 

Output should be:

How to add An HTML form with a name attribute

How to add An <iframe> that act as a target for a link

Iframe Example.
index.html
Example: HTML
<iframe src="https://horje.com/" name="iframe_a">
<p>Your browser does not support iframes.</p>
</iframe>
</br>
<a href="https://horje.com/" target="iframe_a">Horje.com</a>

Output should be:

How to add An <iframe> that act as a target for a link

How to add An HTML form with three input fields; two text fields and one submit button

Input Example.
index.html
Example: HTML
 <form action="/action_page.php">
  Name: <input type="text" name="fullname"><br>
  Email: <input type="text" name="email"><br>
  <input type="submit" value="Submit">
</form> 

Output should be:

How to add An HTML form with three input fields; two text fields and one submit button

How to add An image map, with clickable areas - HTML name

Map Example.
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>

Output should be:

How to add An image map, with clickable areas - HTML name

How to Use the name attribute to define a description, keywords, and the author of an HTML document

Meta Example.
index.html
Example: HTML
 <head>
<meta name="description" content="Free Web tutorials">
<meta name="keywords" content="HTML,CSS,JavaScript">
<meta name="author" content="Hege Refsnes">
</head> 

Output should be:

How to Use the name attribute to define a description, keywords, and the author of an HTML document

How to add An <object> element with a name attribute with Image

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

Output should be:

How to add An <object> element with a name attribute with Image

How to add Perform a calculation and show the result in an <output> element

Output Example.
index.html
Example: HTML
 <form oninput="x.value=parseInt(a.value)+parseInt(b.value)">0
  <input type="range" id="a" value="50">100
  +<input type="number" id="b" value="50">
  =<output name="x" for="a b"></output>
</form> 

Output should be:

How to add Perform a calculation and show the result in an <output> element

How to Set the "autoplay" parameter to "true", so the sound will start playing as soon as the page loads

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

<h1>The param element</h1>

<object data="https://download.samplelib.com/wav/sample-3s.wav">
<param name="autoplay" value="true">
</object>

</body>
</html>

Output should be:

How to Set the "autoplay" parameter to "true", so the sound will start playing as soon as the page loads

How to add A drop-down list with a name attribute

Select .Example
index.html
Example: HTML
 <select name="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 A drop-down list with a name attribute

How to add A text area with a name attribute

Textarea Example.
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 A text area with a name attribute





Related Articles
HTML accept Attribute HTML Input HTML Attribute
HTML accept-charset Attribute HTML Attribute
HTML accesskey Attribute HTML Attribute
HTML action Attribute HTML Attribute
HTML alt Attribute HTML Attribute
HTML async Attribute HTML Attribute
HTML autocomplete Attribute in HTML HTML Attribute
HTML autofocus Attribute HTML Attribute
HTML autoplay Attribute HTML Attribute
HTML charset Attribute HTML Attribute
HTML checked Attribute HTML Attribute
HTML cite Attribute HTML Attribute
HTML class Attribute HTML Attribute
HTML cols Attribute HTML Attribute
HTML colspan Attribute HTML Attribute
HTML content Attribute HTML Attribute
HTML contenteditable Attribute HTML Attribute
HTML controls Attribute HTML Attribute
HTML coords Attribute HTML Attribute
HTML data Attribute HTML Attribute
HTML data-* Attribute HTML Attribute
HTML datetime Attribute HTML Attribute
HTML controls Attribute HTML Attribute
HTML default Attribute HTML Attribute
HTML defer Attribute HTML Attribute
HTML dir Attribute HTML Attribute
HTML dirname Attribute HTML Attribute
HTML disabled Attribute HTML Attribute
HTML download Attribute HTML Attribute
HTML draggable Attribute HTML Attribute
HTML enctype Attribute HTML Attribute
HTML enterkeyhint Attribute HTML Attribute
HTML for Attribute HTML Attribute
HTML form Attribute HTML Attribute
HTML formaction Attribute HTML Attribute
HTML headers Attribute HTML Attribute
HTML height Attribute HTML Attribute
HTML hidden Attribute HTML Attribute
HTML high Attribute HTML Attribute
HTML href Attribute HTML Attribute
HTML hreflang Attribute HTML Attribute
HTML http-equiv Attribute HTML Attribute
HTML id Attribute HTML Attribute
HTML inert Attribute HTML Attribute
HTML inputmode Attribute HTML Attribute
HTML ismap Attribute HTML Attribute
HTML kind Attribute HTML Attribute
HTML label Attribute HTML Attribute
HTML lang Attribute HTML Attribute
HTML list Attribute HTML Attribute
HTML loop Attribute HTML Attribute
HTML low Attribute HTML Attribute
HTML max Attribute HTML Attribute
HTML maxlength Attribute HTML Attribute
HTML media Attribute HTML Attribute
HTML method Attribute HTML Attribute
HTML min Attribute HTML Attribute
HTML multiple Attribute HTML Attribute
HTML muted Attribute HTML Attribute
HTML name Attribute HTML Attribute
HTML novalidate Attribute HTML Attribute
HTML onabort Attribute HTML Attribute
HTML onafterprint Attribute HTML Attribute
HTML onbeforeprint Attribute HTML Attribute
HTML onbeforeunload Attribute HTML Attribute
HTML onblur Attribute HTML Attribute
HTML oncanplay Attribute HTML Attribute
HTML oncanplaythrough Attribute HTML Attribute
HTML onchange Attribute HTML Attribute
HTML onclick Attribute HTML Attribute
HTML oncontextmenu Attribute HTML Attribute
HTML oncopy Attribute HTML Attribute
HTML oncuechange Attribute HTML Attribute
HTML oncut Attribute HTML Attribute
HTML ondblclick Attribute HTML Attribute
HTML ondrag Attribute HTML Attribute
HTML ondragend Attribute HTML Attribute
HTML ondragenter Attribute HTML Attribute
HTML ondragleave Attribute HTML Attribute
HTML ondragover Attribute HTML Attribute
How to add HTML ondragstart Attribute HTML Attribute
HTML ondrop Attribute HTML Attribute
HTML ondurationchange Attribute HTML Attribute
HTML onemptied Attribute HTML Attribute
HTML onended Attribute HTML Attribute
HTML onerror Attribute HTML Attribute
HTML onfocus Attribute HTML Attribute
HTML onhashchange Attribute HTML Attribute
HTML oninput Attribute HTML Attribute
HTML oninvalid Attribute HTML Attribute
HTML onkeydown Attribute HTML Attribute
HTML onkeypress Attribute HTML Attribute
HTML onkeyup Attribute HTML Attribute
HTML onload Attribute HTML Attribute
HTML onloadeddata Attribute HTML Attribute
HTML onloadedmetadata Attribute HTML Attribute
HTML onloadstart Attribute HTML Attribute
HTML onmousedown Attribute HTML Attribute
HTML onmousemove Attribute HTML Attribute
HTML onmouseout Attribute HTML Attribute
HTML onmouseover Attribute HTML Attribute
HTML onmouseup Attribute HTML Attribute
HTML onmousewheel Attribute HTML Attribute
HTML onoffline Attribute HTML Attribute
HTML ononline Attribute HTML Attribute
HTML onpageshow Attribute HTML Attribute
HTML onpaste Attribute HTML Attribute
HTML onpause Attribute HTML Attribute
HTML onplay Attribute HTML Attribute
HTML onplaying Attribute HTML Attribute
HTML onprogress Attribute HTML Attribute
HTML onratechange Attribute HTML Attribute
HTML onreset Attribute HTML Attribute
HTML onresize Attribute HTML Attribute
HTML onscroll Attribute HTML Attribute
HTML onsearch Attribute HTML Attribute
HTML onseeked Attribute HTML Attribute
HTML onseeking Attribute HTML Attribute
HTML onstalled Attribute HTML Attribute
HTML onsubmit Attribute HTML Attribute
HTML onsuspend Attribute HTML Attribute
HTML ontimeupdate Attribute HTML Attribute
HTML ontoggle Attribute HTML Attribute
HTML onunload Attribute HTML Attribute
HTML onvolumechange Attribute HTML Attribute
HTML onwaiting Attribute HTML Attribute
HTML onwheel Attribute HTML Attribute
HTML open Attribute HTML Attribute
HTML optimum Attribute HTML Attribute
HTML pattern Attribute HTML Attribute
HTML placeholder Attribute HTML Attribute
HTML popover Attribute HTML Attribute
HTML popovertarget Attribute HTML Attribute
HTML popovertargetaction Attribute HTML Attribute
HTML poster Attribute HTML Attribute
HTML preload Attribute HTML Attribute
HTML readonly Attribute HTML Attribute
HTML rel Attribute HTML Attribute
HTML required Attribute HTML Attribute
HTML reversed Attribute HTML Attribute
HTML rows Attribute HTML Attribute
HTML rowspan Attribute HTML Attribute
HTML sandbox Attribute HTML Attribute
HTML scope Attribute HTML Attribute
HTML selected Attribute HTML Attribute
HTML shape Attribute HTML Attribute
HTML size Attribute HTML Attribute
HTML sizes Attribute HTML Attribute
HTML span Attribute HTML Attribute
HTML spellcheck Attribute HTML Attribute
HTML src Attribute HTML Attribute
HTML srcdoc Attribute HTML Attribute
HTML srclang Attribute HTML Attribute
HTML <source> srcset Attribute HTML Attribute
HTML start Attribute HTML Attribute
HTML step Attribute HTML Attribute
HTML style Attribute HTML Attribute
HTML tabindex Attribute HTML Attribute
HTML target Attribute HTML Attribute
HTML title Attribute HTML Attribute
HTML translate Attribute HTML Attribute
HTML type Attribute HTML Attribute
HTML usemap Attribute HTML Attribute
HTML value Attribute HTML Attribute
HTML width Attribute HTML Attribute
HTML wrap Attribute HTML Attribute

Single Articles
How to add Two buttons with equal names, that submit different values when clickedHTML Attribute
How to add A <fieldset> with a name attributeHTML Attribute
How to add An HTML form with a name attributeHTML Attribute
How to add An <iframe> that act as a target for a linkHTML Attribute
How to add An HTML form with three input fields; two text fields and one submit buttonHTML Attribute
How to add An image map, with clickable areas - HTML nameHTML Attribute
How to Use the name attribute to define a description, keywords, and the author of an HTML documentHTML Attribute
How to add An <object> element with a name attribute with ImageHTML Attribute
How to add Perform a calculation and show the result in an <output> elementHTML Attribute
How to Set the "autoplay" parameter to "true", so the sound will start playing as soon as the page loadsHTML Attribute
How to add A drop-down list with a name attributeHTML Attribute
How to add A text area with a name attributeHTML Attribute

Type:
Develop
Category:
Web Tutorial
Sub Category:
HTML Attribute
Uploaded by:
Admin


Reffered: https://www.w3schools.com/tags/att_name.asp