2. How do you link a CSS file to an HTML page?

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.

devFlipCards 2024

Do you accept cookies?

Cookies are small amounts of data saved locally on you device, which helps our website - it saves your settings like theme or language. It helps in adjusting ads and in traffic analysis. By using this site, you consent cookies usage.