HTML <samp> Tag

Example Format text in a document: <samp>Sample output from a computer program</samp> Try it Yourself » Definition and Usage The <samp> tag is a phrase tag. It defines sample output from a computer program. Tip: This tag is not deprecated, but it is possible to achieve richer effect with CSS. All phrase tags: Tag Description <em> […]

HTML <code> Tag

Example Format text in a document: <code>A piece of computer code</code> Try it Yourself » Definition and Usage The <code> tag is a phrase tag. It defines a piece of computer code. Tip: This tag is not deprecated, but it is possible to achieve richer effect with CSS. All phrase tags: Tag Description <em> Renders as […]

HTML <cite> Tag

Example Define the title of a work with the <cite> tag: <p><cite>The Scream</cite> by Edward Munch. Painted in 1893.</p> Try it Yourself » Definition and Usage The <cite> tag defines the title of a work (e.g. a book, a song, a movie, a TV show, a painting, a sculpture, etc.). Note: A person’s name is not the […]

HTML <center> Tag

Not Supported in HTML5. Example Center-align text in an HTML page: <center>This text will be center-aligned.</center> Try it Yourself » Definition and Usage The <center> tag is not supported in HTML5. Use CSS instead. The <center> tag is used to center-align text. Browser Support Element <center> Yes Yes Yes Yes Yes Differences Between HTML 4.01 […]

HTML <caption> Tag

Example A table with a caption: <table> <caption>Monthly savings</caption> <tr> <th>Month</th> <th>Savings</th> </tr> <tr> <td>January</td> <td>$100</td> </tr> </table> Try it Yourself » Definition and Usage The <caption> tag defines a table caption. The <caption> tag must be inserted immediately after the <table> tag. Note: You can specify only one caption per table. Tip: By default, a table […]

HTML <canvas> Tag

Example Draw a red square, on the fly, and show it inside the <canvas> element: <canvas id=”myCanvas”></canvas> <script> var canvas = document.getElementById(“myCanvas”); var ctx = canvas.getContext(“2d”); ctx.fillStyle = “#FF0000”; ctx.fillRect(0, 0, 80, 80); </script> Try it Yourself » Definition and Usage The <canvas> tag is used to draw graphics, on the fly, via scripting (usually JavaScript). The <canvas> tag is only a container […]

HTML <button> formmethod Attribute

Example 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”: <form action=”/action_page.php” method=”get”> First name: <input type=”text” name=”fname”><br> Last name: <input type=”text” name=”lname”><br> <button type=”submit”>Submit</button> <button type=”submit” formmethod=”post”>Submit using POST</button> </form> Try it Yourself » Definition and Usage The formmethod attribute specifies which HTTP method to use when sending the […]

HTML <form> method Attribute

Example Submit a form using the “get” method: <form action=”/action_page.php” method=”get”> First name: <input type=”text” name=”fname”><br> Last name: <input type=”text” name=”lname”><br> <input type=”submit” value=”Submit”> </form> Try it Yourself » More “Try it Yourself” examples below. 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 […]

HTML <form> novalidate Attribute

Example Indicate that the form is not to be validated on submit: <form action=”/action_page.php” novalidate> E-mail: <input type=”email” name=”user_email”> <input type=”submit”> </form> Try it Yourself » 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 […]

HTML <button> formnovalidate Attribute

Example 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: <form action=”/action_page.php” method=”get”> E-mail: <input type=”email” name=”userid”><br> <button type=”submit”>Submit</button><br> <button type=”submit” formnovalidate>Submit without validation</button> </form> Try it Yourself » Definition and Usage The formnovalidate attribute is a boolean attribute. When present, it specifies that the form-data […]

HTML <button> formtarget Attribute

Example 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”): <form action=”/action_page.php” method=”get”> First name: <input type=”text” name=”fname”><br> Last name: <input type=”text” name=”lname”><br> <button type=”submit” >Submit</button> <button type=”submit” formtarget=”_blank”>Submit to a new window</button> </form> Try it Yourself » Definition and Usage The formtarget attribute specifies where […]

HTML <form> target Attribute

Example Display the response received in a new window or tab: <form action=”/action_page.php” method=”get” target=”_blank”> First name: <input type=”text” name=”fname”><br> Last name: <input type=”text” name=”lname”><br> <input type=”submit” value=”Submit”> </form> Try it Yourself » 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, […]

HTML <button> name Attribute

Example Two buttons with equal names, that submit different values when clicked: <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> Try it Yourself » 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 […]

HTML <button> type Attribute

Example Two button elements that act as one submit button and one reset button (in a form): <form action=”/action_page.php” method=”get”> First name: <input type=”text” name=”fname”><br> Last name: <input type=”text” name=”lname”><br> <button type=”submit” value=”Submit”>Submit</button> <button type=”reset” value=”Reset”>Reset</button> </form> Try it Yourself » 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 […]

HTML <button> value Attribute

Example Two buttons with equal names, that submit different values when clicked: <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> Try it Yourself » Definition and Usage The value attribute specifies the initial value for a <button> in a <form>. Note: In a form, the button and its value is only submitted if the button itself […]

HTML <button> formenctype Attribute

Example 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: <form action=”/action_page_binary.asp” method=”post”> Name: <input type=”text” name=”fname” value=”Ståle Refsnes”><br> <button type=”submit”>Submit with character encoding</button> <button type=”submit” formenctype=”text/plain”>Submit without character encoding</button> </form> Try it Yourself » Definition and Usage The formenctype attribute specifies how form-data should […]

HTML <form> enctype Attribute

Example Send form-data encoded as “multipart/form-data”: <form action=”/action_page_binary.asp” method=”post” enctype=”multipart/form-data”> First name: <input type=”text” name=”fname”><br> Last name: <input type=”text” name=”lname”><br> <input type=”submit” value=”Submit”> </form> Try it Yourself » 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 Attribute enctype Yes Yes Yes Yes Yes Differences […]

HTML <button> formaction Attribute

Example 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”: <form action=”/action_page.php” method=”get”> First name: <input type=”text” name=”fname”><br> Last name: <input type=”text” name=”lname”><br> <button type=”submit”>Submit</button><br> <button type=”submit” formaction=”/action_page2.php“>Submit to another page</button> </form> Try it Yourself » Definition and Usage The formaction attribute specifies where to send the form-data when a form is submitted. […]

HTML <form> action Attribute

Example On submit, send the form-data to a file named “/action_page.php” (to process the input): <form action=”/action_page.php” method=”get”> First name: <input type=”text” name=”fname”><br> Last name: <input type=”text” name=”lname”><br> <input type=”submit” value=”Submit”> </form> Try it Yourself » Definition and Usage The action attribute specifies where to send the form-data when a form is submitted. Browser Support Attribute action Yes Yes Yes Yes Yes Differences Between HTML […]

HTML <button> disabled Attribute

Example A disabled button: <button type=”button” disabled>Click Me!</button> Try it Yourself » 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 […]