CodesJava

Easy learning with example program codes

link HTML

HTML <link> Tag

To link an external source to the current document, the HTML <link> tag is used. It can also be used with link site icons. It is placed within the <head> tag of the HTML document.

Syntax:

<link rel="stylesheet" type="text/css" href="">

Example:

<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<h1>HELLO WORLD!!</h1>
<p>Today is a Great Day..</p>
</body>
</html>

Style.css:

h1 {background-color: crimson;
    color: white;}
p {color: crimson;
font-size: 30px;}

Output:

Explanation:

In the above example, we are using the HTML <link> tag to link an external CSS file to an HTML document.

Tag Specific Attributes:

AttributeValueUses
charsetchar_encodingUsed to specify the character encoding of linked source.Not supported in HTML5.
hrefURLUsed to determine the location of the linked document.
hreflanglanguage_codeUsed to determine the text language of the linked source.
mediamedia_queryUsed to define the media, for which linked source is applied.
relalternate

author

dns-prefetch

help

icon

license

next

pingback

preconnect

prefetch

preload

prerender

prev

search

stylesheet

Used to specify the relationship between the current and the linked document. It is a required attribute of the HTML <link> tag.
revreversed

relationship

Used to specify the relationship between the linked and the current document.Not supported in HTML5.
sizesHeight* weightUsed to determine the size of the linked source, and is used with rel=”icon.”
target_blank

_self

_top

_parent

frame_name

Used to specify where to load the linked document.
typemedia_typeUsed to determine the media type of document.

Global Attributes:

The HTML Global attributes are supported by the HTML <link> tag.

Event Attributes:

The HTML Event attributes are supported by the HTML <link> tag.

Supporting Browsers:

Chrome, IE, Firefox, Opera and Safari.

Please follow and like us:
error
Posted in HTML   









Copyright © 2019 CodesJava DMCA.com Protection Status