CSS Links
CSS (Cascading Style Sheets) is a styling language used to control the presentation of HTML documents. CSS links are used to include external CSS files in an HTML document, allowing you to separate the style from the content.
To include a CSS file in an HTML document, you can use the <link>
element within the <head>
section of your HTML code. Here’s an example of how you can add a CSS link:
html
<!DOCTYPE html>
<html>
<head>
<title>My Web Page</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<!-- Content of your web page goes here -->
</body>
</html>
In the example above, the <link>
element is used to include an external CSS file named “styles.css”. The href
attribute specifies the path to the CSS file relative to the HTML document. Make sure to replace “styles.css” with the actual file name and path.
You can also use an absolute URL to link to a CSS file hosted on a different server. For example:
html
<link rel="stylesheet" href="https://example.com/styles.css">
In this case, the href
attribute contains the complete URL to the CSS file.
By linking your HTML document to an external CSS file, you can define styles in that CSS file and apply them to elements in your HTML. This separation of concerns makes your code more maintainable and allows for easy reuse of styles across multiple pages.