Reputation: 111
I have a file containing both html and css code.How it is possible to separate the html code in some files and css in some other files??
Upvotes: 6
Views: 14823
Reputation: 15619
Yes. You can save the css in a .css
file. Then in your HTML head tags, you can do <link rel='stylesheet' href='yourcssfile.css'>
<html>
<head>
<link rel='stylesheet' type='text/css' href='yourcssfile.css'>
</head>
<body>
<p>Test</p>
</body>
</html>
In yourcssfile.css
p {
color:red;
}
This will make the paragraph text red and your CSS is within a different file.
Upvotes: 5
Reputation: 1832
Simply put the CSS code into a file.css
and include it in your HTML file.
<head>
<link rel="stylesheet" type="text/css" href="file.css">
</head>
Upvotes: 1