There are 3 main ways to include CSS in HTML:
1. Inline CSS: Add CSS directly to an HTML element using the style
attribute
Inline CSS Example:
<p style="color: blue; font-size: 18px;">Welcome to W3Studies</p>
Try It yourself
2. Internal CSS: Place CSS within a <style> tag inside the
<head>
section of your HTML file. This method is
useful for applying styles to a single HTML page.
Internal CSS Example:
<head> <style> p { color: blue; font-size: 18px; } </style></head>
Try It yourself
3. External CSS: Link to an external CSS
file (e.g., styles.css
) using the
<link>
tag in the <head> section.
This is ideal for larger projects, as you can style multiple pages with
one CSS file.
External CSS Example:
<head> <link rel="stylesheet" href="styles.css"></head>