How to use the tag to define a relationship to an external resource?

The <link> tag is used in HTML to define a relationship to an external resource. It is used to link external style sheets. It gets added inside the <head>…<head> tag, but does not have a closing tag. Define your external CSS file in it.

The CSS file created separately will have all the CSS code inside it. The href attribute adds the css file link.

You can try to run the following code to include external CSS in HTML. The HTML file is here, with a link to CSS file style.css


Live Demo

<!DOCTYPE html>
      <link rel="stylesheet" href="mystyles.css">
      <p>This is demo content.</p>

The CSS file mystyles.css, with the CSS code,

 { color: green; }
 { font-size: 14px; }

Updated on: 04-Oct-2019


Kickstart Your Career

Get certified by completing the course

Get Started