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 <input> Type Attribute Values

HTML <input type=”button”> Example A push button that activates a JavaScript when it is clicked: <input type=”button” value=”Click me” onclick=”msg()”> Try it Yourself HTML <input type=”checkbox”> Example Let the user select one or more options of a limited number of choices: <input type=”checkbox” name=”vehicle1″ value=”Bike”> I have a bike<br> <input type=”checkbox” name=”vehicle2″ value=”Car”> I have a car<br> <input type=”checkbox” name=”vehicle3″ value=”Boat” checked> I have a boat<br> Try it Yourself » HTML <input type=”color”> Example […]

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> 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> 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> 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> 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. […]

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

Example An HTML table with a header cell that spans two columns: <table> <tr> <th colspan=”2″>Monthly 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 colspan attribute defines the number of columns a header cell should span. Browser Support Attribute colspan Yes Yes Yes Yes Yes […]

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 <tr> bgcolor Attribute

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

HTML <tr> align Attribute

Example Right-align the content of all the cells in the second table row: <table> <tr> <th>Month</th> <th>Savings</th> </tr> <tr align=”right”> <td>January</td> <td>$100</td> </tr> </table> Try it Yourself » Definition and Usage The align attribute specifies the horizontal alignment of the content in a table row. Browser Support Attribute align Yes Yes Yes Yes Yes Note: None 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> src Attribute

Example An embedded flash animation: <embed src=”helloworld.swf”> Try it Yourself » Definition and Usage The src attribute specifies the address of the external file to embed. Browser Support Attribute src Yes Yes Yes Yes Yes Differences Between HTML 4.01 and HTML5 The <embed> tag is new in HTML5. Syntax <embed src=”URL“> Attribute Values Value Description URL […]

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> Tag

Example Play a video: <video width=”320″ height=”240″ controls> <source src=”movie.mp4″ type=”video/mp4″> <source src=”movie.ogg” type=”video/ogg”> Your browser does not support the video tag. </video> Try it Yourself » Definition and Usage The <video> tag specifies video, such as a movie clip or other video streams. Currently, there are 3 supported video formats for the <video> element: MP4, WebM, and Ogg: Browser MP4 WebM […]

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

Example A muted video: <video controls muted> <source src=”movie.mp4″ type=”video/mp4″> Your browser does not support the video tag. </video> Try it Yourself » Definition and Usage The muted attribute is a boolean attribute. When present, it specifies that the audio output of the video should be muted. Browser Support The numbers in the table specify the first browser […]