HTML DOM Link type Property

The Link type property sets/returns the type of a linked document.


Following is the syntax −

  • Returning type attribute value
  • Setting type to a valid value
linkObject.type = value

NOTE  − valid values include "text/javascript", "text/css", "image/gif", etc.


Let us see an example for Link type property −

<!DOCTYPE html>
<title>Link type</title>
<link id="extStyle" rel="stylesheet" href="style.css" type="myStyle">
<input type="button" value="Correct Type" onclick="correctType()">
<div id="divDisplay"></div>
   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';

In the above example ‘style.css’ contains −

form {
   margin: 0 auto;
   text-align: center;
* {
   padding: 2px;
input[type="button"] {
   border-radius: 10px;


This will produce the following output −

Before clicking ‘Correct Type’ button −

After clicking ‘Correct Type’ button −