CSS can be added to an HTML document in several ways:
-
Inline CSS: You can apply styles directly to an HTML element using the
styleattribute. For example:<h1 style="color: blue;">Hello World</h1> -
Internal CSS: You can include CSS within a
<style>tag in the<head>section of your HTML document. For example:<head> <style> body { background-color: lightgray; } </style> </head> -
External CSS: As you've mentioned, you can link to an external CSS file using the
<link>tag, like this:<link rel="stylesheet" href="styles.css" /> -
CSS Frameworks: You can also use CSS frameworks (like Bootstrap or Tailwind CSS) by linking to their CDN in the
<head>section. For example:<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
Each method has its use cases, with external CSS being the most common for larger projects due to better organization and reusability. If you have more questions or need examples, feel free to ask!
