Introduction
Linking CSS to HTML lets you style your web page by connecting a separate CSS file to your HTML file.
Jump into concepts and practice - no test required
<link rel="stylesheet" href="styles.css">
<head> <link rel="stylesheet" href="styles.css"> </head>
<head> <link rel="stylesheet" href="css/main.css"> </head>
<head> <link rel="stylesheet" href="https://example.com/style.css"> </head>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Link CSS Example</title> <link rel="stylesheet" href="styles.css"> </head> <body> <h1>Welcome to My Website</h1> <p>This paragraph will be styled by CSS.</p> </body> </html> /* styles.css */ h1 { color: darkblue; font-family: Arial, sans-serif; } p { color: darkgreen; font-size: 1.2rem; }
<head> <link rel="stylesheet" href="styles.css"> </head> <body> <p>Hello World!</p> </body>
styles.css contains:p { color: blue; }<head> <link rel="stylesheet" href="main.css"> </head> <body> <h1>Welcome</h1> </body>