HTML <form> accept Attribute

Example Specify that the server accepts only gif and jpeg files in the file upload: <form action=”/action_page.php” accept=”image/gif,image/jpeg”> First name: <input type=”text” name=”fname”><br> Last name: <input type=”text” name=”lname”><br> Your image: <input type=”file” name=”pic” id=”pic”><br> <input type=”submit” value=”Submit”> </form> Try it Yourself » Definition and Usage The <form> accept attribute is not supported in HTML5. The accept attribute specifies the types of files that the server accepts (that can be […]

HTML <input> accept Attribute

Example Specify that the server accepts only image files in the file upload: <form action=”/action_page.php”> <input type=”file” name=”pic” accept=”image/*”> <input type=”submit”> </form> Try it Yourself » Definition and Usage The accept attribute specifies the types of files that the server accepts (that can be submitted through a file upload). Note: The accept attribute can only be used with <input type=”file”>. Tip: Do […]

HTML <select> Tag

Example Create a drop-down list with four options: <select> <option value=”volvo”>Volvo</option> <option value=”saab”>Saab</option> <option value=”mercedes”>Mercedes</option> <option value=”audi”>Audi</option> </select> Try it Yourself » Definition and Usage The <select> element is used to create a drop-down list. The <option> tags inside the <select> element define the available options in the list. Browser Support Element <select> Yes Yes Yes Yes Yes Tips and Notes […]

HTML <option> Tag

Example A drop-down list with four options: <select> <option value=”volvo”>Volvo</option> <option value=”saab”>Saab</option> <option value=”opel”>Opel</option> <option value=”audi”>Audi</option> </select> Try it Yourself » Definition and Usage The <option> tag defines an option in a select list. <option> elements go inside a <select> or <datalist> element. Browser Support Element <option> Yes Yes Yes Yes Yes Tips and Notes Note: The <option> tag can be used without any […]

HTML <optgroup> Tag

Example Group related options with <optgroup> tags: <select> <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> Try it Yourself » Definition and Usage The <optgroup> is used to group related options in a drop-down list. If you have a long list of options, groups of related options are easier to handle for […]

HTML <label> Tag

Example Three radio buttons with labels: <form action=”/action_page.php”> <label for=”male”>Male</label> <input type=”radio” name=”gender” id=”male” value=”male”><br> <label for=”female”>Female</label> <input type=”radio” name=”gender” id=”female” value=”female”><br> <label for=”other”>Other</label> <input type=”radio” name=”gender” id=”other” value=”other”><br><br> <input type=”submit” value=”Submit”> </form> Try it Yourself » Definition and Usage The <label> tag defines a label for an <input> element. The <label> element does not render as anything special for the user. However, it provides a usability improvement for mouse users, because if […]

HTML <textarea> Tag

Example An HTML text area: <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> Try it Yourself » Definition and Usage The <textarea> tag defines a multi-line text input control. A text area can hold an unlimited number of characters, and the text […]

HTML <font> Tag

Not Supported in HTML5. Example Specify the font size, font face and color of text: <font size=”3″ color=”red”>This is some text!</font> <font size=”2″ color=”blue”>This is some text!</font> <font face=”verdana” color=”green”>This is some text!</font> Try it Yourself » Definition and Usage The <font> tag is not supported in HTML5. Use CSS instead. The <font> tag specifies the font face, font size, and […]

HTML <figcaption> Tag

Example Use a <figure> element to mark up a photo in a document. The <figure> element can also contain a <figcaption>: <figure> <img src=”pic_trulli.jpg” alt=”Trulli” style=”width:100%”> <figcaption>Fig.1 – Trulli, Puglia, Italy.</figcaption> </figure> Try it Yourself » Definition and Usage The <figcaption> tag defines a caption for a <figure> element. The <figcaption> element can be placed as the first or last […]

HTML <figure> Tag

Example Use a <figure> element to mark up a photo in a document: <figure> <img src=”img_pulpit.jpg” alt=”The Pulpit Rock” width=”304″ height=”228″> </figure> Try it Yourself » Definition and Usage 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 […]

HTML <fieldset> Tag

Example Group related elements in a form: <form> <fieldset> <legend>Personalia:</legend> Name: <input type=”text”><br> Email: <input type=”text”><br> Date of birth: <input type=”text”> </fieldset> </form> Try it Yourself » Definition and Usage The <fieldset> tag is used to group related elements in a form. The <fieldset> tag draws a box around the related elements. Browser Support Element <fieldset> Yes Yes Yes Yes Yes […]

HTML <fieldset> name Attribute

Example A <fieldset> with a name attribute: <fieldset name=”personalia”> Name: <input type=”text”><br> Email: <input type=”text”><br> </fieldset> Try it Yourself » 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 Attribute name Yes Not supported […]

HTML <fieldset> form Attribute

Example A <fieldset> element located outside a form (but still a part of the form): <form action=”/action_page.php” method=”get” id=”form1″> What is your favorite color? <input type=”text” name=”fav_color”><br> <input type=”submit”> </form> <fieldset form=”form1″> Name: <input type=”text” name=”username”><br> Email: <input type=”text” name=”usermail”><br> </fieldset> Try it Yourself » Definition and Usage The form attribute specifies one or more forms the fieldset belongs to. Browser Support Attribute form Not supported Not supported Not […]

HTML <fieldset> disabled Attribute

Example Disable a group of related form elements: <fieldset disabled> <legend>Personalia:</legend> Name: <input type=”text”><br> Email: <input type=”text”><br> Date of birth: <input type=”text”> </fieldset> Try it Yourself » 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 […]

HTML <legend> Tag

Example Group related elements in a form: <form> <fieldset> <legend>Personalia:</legend> Name: <input type=”text” size=”30″><br> Email: <input type=”text” size=”30″><br> Date of birth: <input type=”text” size=”10″> </fieldset> </form> Try it Yourself » Definition and Usage The <legend> tag defines a caption for the <fieldset> element. Browser Support Element <legend> Yes Yes Yes Yes Yes Differences Between HTML 4.01 and HTML5 The “align” attribute is not supported in HTML5. […]

HTML <th> scope Attribute

Example Specify that the two header cells are headers for columns: <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> Try it Yourself » Definition and Usage The scope attribute specifies whether a header cell is a header for a column, row, or group of columns or […]

HTML <th> valign Attribute

Example Vertical align the content inside <th> elements: <table> <tr> <th valign=”bottom”>Month</th> <th valign=”bottom”>Savings</th> </tr> <tr> <td>January</td> <td>$100</td> </tr> </table> Try it Yourself » Definition and Usage The valign attribute specifies the vertical alignment of the content in a header cell. Browser Support Attribute valign Yes Yes Yes Yes Yes Compatibility Notes The valign attribute of <th> […]

HTML <th> width Attribute

Example Header cells with a predefined width: <table> <tr> <th width=”70%”>Month</th> <th width=”30%”>Savings</th> </tr> <tr> <td>January</td> <td>$100</td> </tr> <tr> <td>February</td> <td>$80</td> </tr> </table> Try it Yourself » Definition and Usage The width attribute specifies the width of a table header cell. Normally, a cell takes up the space it needs to display the content. The width attribute […]

HTML <th> rowspan Attribute

Example An HTML table with a header cell that spans three rows: <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> Try it Yourself » More “Try it Yourself” examples below. Definition and Usage The rowspan attribute defines the number of rows a header cell should span. […]

HTML <th> nowrap Attribute

Example A header cell with a nowrap attribute: <table> <tr> <th>Month</th> <th nowrap>My Savings for a new car</th> </tr> <tr> <td>January</td> <td>$100</td> </tr> <tr> <td>February</td> <td>$80</td> </tr> </table> Try it Yourself » Definition and Usage The nowrap attribute is a boolean attribute. When present, it specifies that the content inside a header cell should not wrap. […]