The HTML DOM Attribute Object

The Attr Object In the HTML DOM, the Attr object represents an HTML attribute. An HTML attribute always belongs to an HTML element. The NamedNodeMap Object In the HTML DOM, the NamedNodeMap object represents an unordered collection of an elements attribute nodes. Nodes in a NamedNodeMap can be accessed by name or by index (number). Properties and Methods Property […]

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

Example Two header cells with a predefined height: <table> <tr> <th height=”100″>Month</th> <th height=”100″>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 height attribute specifies the height of a header cell. If no height attribute is set, a header cell takes up the space it needs to […]

HTML <th> headers Attribute

Example Specify the <th> element each header cell is related to: <table> <tr> <th id=”name” colspan=”2″>Name</th> </tr> <tr> <th headers=”name”>Firsname</th> <th headers=”name”>Lastname</th> </tr> </table> Try it Yourself » Definition and Usage The headers attribute specifies one or more header cells a header cell is related to. Browser Support Attribute headers Yes Yes Yes Yes Yes The headers attribute has […]

HTML <th> char Attribute

Example Align the content of the first header cell to the “M” character: <table> <tr> <th align=”char” char=”M”>Month</th> <th>Savings</th> </tr> <tr> <td>January</td> <td>$100.00</td> </tr> <tr> <td>February</td> <td>$10.00</td> </tr> </table> Try it Yourself » Definition and Usage The <th> char attribute is not supported in HTML5. The char attribute specifies the alignment of the content in a header […]

HTML <th> bgcolor Attribute

Example Add a background color to header cells: <table> <tr> <th bgcolor=”#FF0000″>Month</th> <th bgcolor=”#00FF00″>Savings</th> </tr> <tr> <td>January</td> <td>$100</td> </tr> </table> Try it Yourself » Definition and Usage The bgcolor attribute specifies the background color of a header cell. Browser Support Attribute bgcolor Yes Yes Yes Yes Yes Compatibility Notes The bgcolor attribute of <th> is not supported […]

HTML <th> abbr Attribute

Example Use of the abbr attribute in an HTML table: <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> Try it Yourself » Definition and Usage The abbr attribute specifies a shorter version of the content in a header cell. Browser Support Attribute […]

HTML <thead> charoff Attribute

Example Align the content inside the <thead> two characters to the right from the “M” character: <table> <thead align=”char” char=”M” charoff=”2″> <tr> <th>Month</th> <th>Savings</th> </tr> </thead> <tr> <td>January</td> <td>$100</td> </tr> <tr> <td>February</td> <td>$80</td> </tr> </table> Try it Yourself » Definition and Usage The <thead> charoff attribute is not supported in HTML5. The charoff attribute sets the number of […]

HTML <track> kind Attribute

Example A video with two subtitle tracks: <video width=”320″ height=”240″ controls> <source src=”forrest.mp4″ type=”video/mp4″> <track src=”subtitles_en.vtt” kind=”subtitles” srclang=”en” label=”English”> <track src=”subtitles_no.vtt” kind=”subtitles” srclang=”no” label=”Norwegian”> </video> Definition and Usage The kind attribute specifies the kind of text track. Browser Support The numbers in the table specify the first browser version that fully supports the attribute. Attribute kind 18.0 10.0 31.0 6.0 15.0 Differences Between HTML 4.01 and HTML5 The […]

HTML <embed> type Attribute

Example An embedded flash animation with a specified media type: <embed src=”DW.mp4″ type=”video/mp4″> Try it Yourself » Definition and Usage The type attribute specifies the Internet media type (formerly known as MIME type) of the embedded content. Browser Support Attribute type Yes Yes Yes Yes Yes Differences Between HTML 4.01 and HTML5 The <embed> tag is new […]

HTML <embed> height Attribute

Example A flash animation with a height and width of 200 pixels: <embed src=”helloworld.swf” width=”200″ height=”200″> Try it Yourself » 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 Attribute height Yes Yes Yes Yes Yes Differences Between HTML 4.01 […]

HTML <embed> width Attribute

Example A flash animation with a height and width of 200 pixels: <embed src=”helloworld.swf” width=”200″ height=”200″> Try it Yourself » 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 Attribute width Yes Yes Yes Yes Yes Differences Between HTML 4.01 […]

HTML <video> width Attribute

Example A video player with a specified width and height: <video width=”320″ height=”240″ controls> <source src=”movie.mp4″ type=”video/mp4″> Your browser does not support the video tag. </video> Try it Yourself » 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 height and width are […]

HTML <video> src Attribute

Example Play a video: <video src=”movie.ogg” controls> Your browser does not support the video tag. </video> Try it Yourself » 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 Firefox, Opera and Chrome. To play the video in Internet Explorer and […]

HTML <video> loop Attribute

Example A video that will start over again, every time it is finished: <video controls loop> <source src=”movie.mp4″ type=”video/mp4″> Your browser does not support the video tag. </video> Try it Yourself » 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. […]

HTML <video> height Attribute

Example A video player with a specified height and width: <video width=”320″ height=”240″ controls> <source src=”movie.mp4″ type=”video/mp4″> Your browser does not support the video tag. </video> Try it Yourself » 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 height and width are […]