HTML DOM Link sizes Property


The HTML DOM Link sizes property returns the value of the sizes attribute of link element.

NOTE − The sizes property is used only when rel property is set to ‘icon’

Syntax

Following is the syntax −

Returning sizes attribute value

linkObject.sizes

Example

Let us see an example for Link rel property −

 Live Demo

<!DOCTYPE html>
<html>
<head>
<title>Link sizes</title>
<link id="extStyle" rel="icon" href="new.gif" sizes="10x10">
</head>
<body>
<form>
<fieldset>
<legend>Link-sizes</legend>
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
   var divDisplay = document.getElementById("divDisplay");
   var extStyle = document.getElementById("extStyle");
   if(extStyle.sizes == '10x10')
      divDisplay.textContent = 'The linked icon size: '+extStyle.sizes+' is not compatible';
   else
      divDisplay.textContent = 'Congrats! The linked icon size 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 −

Updated on: 30-Jul-2019

98 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements