To link a CSS file to an HTML file, you can follow these steps:
Create a new CSS file
Create a new file in a text editor, and save it with a .css extension, such as “style.css”.
Add CSS code
Add the CSS code that you want to apply to your HTML elements in the CSS file. For example, you could set the font size and color of your text:
body {
font-size: 16px;
color: #333;
}
Link the CSS file to the HTML file
In the head section of your HTML file, add a link to the CSS file using the <link>
element. Make sure to replace “style.css” with the filename of your CSS file:
<!DOCTYPE html>
<html>
<head>
<link rel=”stylesheet” type=”text/css” href=”style.css”>
</head>
<body>
<h1>Welcome to my website</h1>
<p>This is some example text.</p>
</body>
</html>