How do I use an external stylesheet in an HTML document?
Asked on Aug 21, 2025
Answer
To use an external stylesheet in an HTML document, you need to link the CSS file within the `` section of your HTML using the `` tag. This allows you to separate your styling from your HTML structure.
<!-- BEGIN COPY / PASTE -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>Hello, World!</h1>
</body>
</html>
<!-- END COPY / PASTE -->Additional Comment:
- The `` tag should be placed inside the `` section of your HTML document.
- Ensure the `href` attribute points to the correct path of your CSS file.
- Using an external stylesheet helps maintain a clean separation between content (HTML) and presentation (CSS).
- Multiple stylesheets can be linked by using multiple `` tags.
Recommended Links: