Categories
HTML

How to include a CSS in an HTML file

Below is my sample style sheet created, with a name say style.css

Style.css

body
{
    background-color:#d0e4fe;
}

h1
{
    color:orange;
    text-align:center;
}

p
{
    font-family:"Times New Roman";
    font-size:14px;
}

HTML

To include the above CSS file in an HTML file, you need to use the link tag. In the link tag using the HREF attribute you can specify the path and the name of the style sheet which you want to inlcude, and the type attribute here has a value of “text/css” .

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