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 DOM Head Object

Head Object The Head object represents an HTML <head> element. Access a Head Object You can access a <head> element by using getElementsByTagName(): var x = document.getElementsByTagName(“HEAD”)[0]; Create a Head Object You can create a <head> element by using the document.createElement() method: var x = document.createElement(“HEAD”); Standard Properties and Events The Anchor object also supports the standard properties and events.

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

Example A <video> element with browser default controls: <video controls> <source src=”movie.mp4″ type=”video/mp4″> Your browser does not support the video tag. </video> Try it Yourself » Definition and Usage The controls attribute is a boolean attribute. When present, it specifies that video controls should be displayed. Video controls should include: Play Pause Seeking Volume Fullscreen toggle Captions/Subtitles (when […]

HTML <colgroup> valign Attribute

Example An HTML table with different vertical-aligned columns: <table style=”height:200px”> <colgroup valign=”top”> <colgroup valign=”bottom”> <tr> <th>Month</th> <th>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 column group. Browser Support Attribute valign Not supported Yes Not supported Not supported Not supported The […]

HTML <colgroup> align Attribute

Example Two <colgroup> elements that specify different alignment for the three columns in the table (notice that the first <colgroup> element spans two columns): <table style=”width:100%”> <colgroup span=”2″ align=”left”></colgroup> <colgroup align=”right”></colgroup> <tr> <th>ISBN</th> <th>Title</th> <th>Price</th> </tr> <tr> <td>3476896</td> <td>My first HTML</td> <td>$53</td> </tr> </table> Try it Yourself » Definition and Usage The align attribute specifies the horizontal alignment of […]

HTML <col> align Attribute

Example Specify the alignment for the three columns in the table: <table style=”width:100%”> <col align=”left”> <col align=”left”> <col align=”right”> <tr> <th>ISBN</th> <th>Title</th> <th>Price</th> </tr> <tr> <td>3476896</td> <td>My first HTML</td> <td>$53</td> </tr> </table> Try it Yourself » Definition and Usage The align attribute specifies the horizontal alignment of the content related to a <col> element. Browser Support Attribute align Not […]

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 <body> vlink Attribute

Example Set the visited link color to “red” in an HTML document: <html> <body vlink=”red”> <p><a href=”https://www.w3schools.com”>W3Schools.com</a></p> <p><a href=”https://www.w3schools.com/html/”>HTML Tutorial</a></p> </body> </html> Try it Yourself » Definition and Usage The vlink attribute specifies the color of visited links in a document. Browser Support Attribute vlink Yes Yes Yes Yes Yes Compatibility Notes The <body> vlink attribute is not […]

HTML <body> text Attribute

Example Specify the color of text in an HTML document: <html> <body text=”green”> <h1>Hello world!</h1> <p><a href=”https://www.w3schools.com”>Visit W3Schools.com!</a></p> </body> </html> Try it Yourself » Definition and Usage The text attribute specifies the color of the text in a document. Browser Support Attribute text Yes Yes Yes Yes Yes Compatibility Notes The <body> text attribute is not supported […]

HTML DOM Bdo Object

Bdo Object The Bdo object represents an HTML <bdo> element. Access a Bdo Object You can access a <bdo> element by using getElementById(): Example var x = document.getElementById(“myBdo”); Try it Yourself » Create a Bdo Object You can create a <bdo> element by using the document.createElement() method: Example var x = document.createElement(“BDO”); Try it Yourself » Bdo […]

HTML <basefont> size Attribute

Example Specify the default font-size for text on page: <head> <basefont size=”7″> </head> <body> <h1>This is a heading</h1> <p>This is a paragraph.</p> </body> Try it Yourself » Definition and Usage The size attribute specifies the default font-size for the text in a document. Browser Support Attribute size Not supported Not supported Not supported Not supported Not […]