Advertisement
Home Open Editor ❯

HTML name Attribute

Example

<form action="action3.html" method="get">
  Click the button.
  <button name="subject" type="submit" value="HTML">HTML</button>
  <button name="subject" type="submit" value="CSS">CSS</button>
  <button name="subject" type="submit" value="JavaScript">JavaScript</button>
</form>

Try this code ❯

Meaning

The name attribute is used to define a name for the element so that it can be scripted by
older browsers or used to provide a name for submit buttons when a page has more than
one. The id attribute is preferred for scripting purposes.

Note: Unlimited number of <button> elements can share the same name.


Standard Syntax

<element name="name">


Applies to:

The name attribute can be used on the following element:


Advertisement

Attribute Values

Value Description
name The name of the elements.

More Examples

<fieldset> Example

<form action="elements/action3.html" method="get">
  <fieldset name="userinfo">
    <legend>User Info:</legend>
    <label for="fname">First name:</label>
    <input type="text" id="fname" name="fname">
  </fieldset>
  <br>
  <button type="button" onclick="form.userinfo.style.backgroundColor='tomato'"> Change background color of fieldset</button>
  <input type="submit" value="submit">
</form>

Try this code ❯


<form> Example

<form name="myForm" action="action.html" method="get">
  <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>
  <input type="submit" value="Submit">
</form>

Try this code ❯


<iframe> Example

<iframe src="demo/demo.html" name="iframe_demo">
Your browser does not support frame element.
</iframe>
<a href="demo/demo2.html" target="iframe_demo">Demo 2 HTML page.</a>

Try this code ❯


<input> Example

<form action="action.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>

Try this code ❯


<map> Example

<img src="demo/desk.jpg" usemap="#image-map">

<map name="image-map">
    <area target="_blank" alt="Mobile" title="Mobil" href="demo/mobile.png" coords="174,432,285,626" shape="rect">
    <area target="_blank" alt="computer" title="computer" href="demo/computer.png" coords="409,369,856,657" shape="rect">
    <area target="_blank" alt="clock" title="clock" href="demo/clock.png" coords="1158,203,58" shape="circle">
</map>

Try this code ❯


<meta> Example

<head>
  <meta name="language" content="EN">
  <meta name="description" content="add up to 160 characters">
  <meta name="keywords" content="your, keywords">
  <meta name="robots" content="index, follow">
  <meta name="copyright"content="company">
  <meta name="author" content="John Doe, email@domain.com">
  <meta name="distribution" content="Global">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>

Try this code ❯


<object> Example

<object name="object1" data="demo/image.jpg" width="300" height="150"></object>

Try this code ❯


<output> Example

<form oninput="result.value=parseInt(a.value)+parseInt(b.value)">
  <input type="range" id="b" name="b" value="50" /> +
  <input type="number" id="a" name="a" value="10" /> =
  <output name="result" for="a b">50</output>
</form>

Try this code ❯


<param> Example

<object data="demo/video.mp4">
  <param name="videplay" value="true">
</object>

Try this code ❯


<select> Example

<label for="lang">Choose your option:</label>

<select name="language" id="lang">
  <option value="HTML">HTML</option>
  <option value="CSS">CSS</option>
  <option value="JavaScript">JavaScript</option>
</select>

Try this code ❯


<textarea> Example

Example

<form action="action.php">
  <label for="demo">textarea demo:</label>
  <textarea id="demo" name="textareaText">Hello world!</textarea>
  <br><br>
  <input type="submit" value="Submit">
</form>

Try this code ❯

Home Open Editor ❯
Advertisement