
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
HTML DOM Link type Property
The Link type property sets/returns the type of a linked document.
Syntax
Following is the syntax −
- Returning type attribute value
linkObject.type
- Setting type to a valid value
linkObject.type = value
NOTE − valid values include "text/javascript", "text/css", "image/gif", etc.
Example
Let us see an example for Link type property −
<!DOCTYPE html> <html> <head> <title>Link type</title> <link id="extStyle" rel="stylesheet" href="style.css" type="myStyle"> </head> <body> <form> <fieldset> <legend>Link-type</legend> <input type="button" value="Correct Type" onclick="correctType()"> <div id="divDisplay"></div> </fieldset> </form> <script> var divDisplay = document.getElementById("divDisplay"); var extStyle = document.getElementById("extStyle"); divDisplay.textContent = 'The linked document type: '+extStyle.type+' is not compatible'; function correctType(){ extStyle.type = 'text/css'; divDisplay.textContent = 'Congrats! The linked document type: '+extStyle.type+' is compatible'; } </script> </body> </html>
In the above example ‘style.css’ contains −
form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin:5px; } input[type="button"] { border-radius: 10px; }
Output
This will produce the following output −
Before clicking ‘Correct Type’ button −
After clicking ‘Correct Type’ button −
- Related Articles
- HTML DOM Link disabled Property
- HTML DOM Link href Property
- HTML DOM Link hreflang Property
- HTML DOM Link rel Property
- HTML DOM Link sizes Property
- HTML DOM Ol type Property
- HTML DOM Event type Property
- HTML DOM Object type Property
- HTML DOM Anchor type Property
- HTML DOM Button type Property
- HTML DOM Select type Property
- HTML DOM Fieldset type property
- HTML DOM Input Button type Property
- HTML DOM Input FileUpload type Property
- HTML DOM Input Hidden type Property

Advertisements