HTML DOM Link Object

The HTML DOM Link Object in HTML represents the <link> element.


Following is the syntax −

Creating a <link> element

var linkObject = document.createElement(“LINK”)


Here, “LinkObject” can have the following properties −

crossOriginIt sets/returns the the CORS settings of the linked document
disabledIt sets/returns whether the linked document is disabled, or not
hrefIt sets/returns the URL of the linked document
hreflangIt sets/returns the language code of the linked document
mediaIt sets/returns the media type for the link element tag
relIt sets/returns the relationship between the current and the linked document
sizesIt returns the value of the sizes attribute of the linked document
typeIt sets/returns the content type of the linked document


Let us see an example for Link disabled property −

 Live Demo

<!DOCTYPE html>
<title>Link Disabled</title>
<link id="extStyle" rel="stylesheet" type="text/css" href="style.css">
<label for="WeekSelect">Sales Target Week:
<input type="week" id="WeekSelect" value="2020-W13" disabled>
<input type="button" onclick="enableWeekInput()" value="Change Sales Target Week">
<input type="button" onclick="beautify()" value="Disable Styling">
<div id="divDisplay"></div>
   var divDisplay = document.getElementById("divDisplay");
   var inputWeek = document.getElementById("WeekSelect");
   var extStyle = document.getElementById("extStyle");
   divDisplay.textContent = 'Week Input disabled: '+inputWeek.disabled;
   function enableWeekInput() {
      inputWeek.disabled = false;
      divDisplay.textContent = 'Week Input disabled: '+inputWeek.disabled;
   function beautify(){
      extStyle.disabled = true;

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 ‘Disable Styling’ button −

After clicking ‘Disable Styling’ button −

Updated on: 30-Jul-2019


Kickstart Your Career

Get certified by completing the course

Get Started