This can be done using the tag within the section of an HTML file. The tag includes the attributes
rel
, type
, and href
, which define the relationship of the external CSS file to the HTML document:
<!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" type="text/css" href="styles.css"> </head> <body> <h1>Hello World!</h1> </body> </html>
The rel="stylesheet"
attribute indicates that the file is a stylesheet, type="text/css"
specifies the file type (
though this is default and optional), and href="styles.css"
provides the path to the CSS file.