Style your HTML with CSS using different methods to control colors, fonts, layouts, and more.
CSS (Cascading Style Sheets) separates content (HTML) from presentation (styles).
Applied directly to the HTML elementdirectly to the HTML element using the style attribute
This is a blue paragraph.
Added inside the <head> using the <style> tag
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Internal CSS Example</title> <style> p { color: green; font-size: 16px; } </style> </head> <body> <p>This paragraph is styled with internal CSS.</p> </body> </html>
Stored in a separate .css file and linked with <link>
styles.css
index.html
<head> <link rel="stylesheet" href="styles.css"> </head> <body> <p>This paragraph is styled with external CSS.</p> </body>
| Method | Syntax Location | Pros | Cons |
|---|---|---|---|
|
Inline |
Inside HTML element |
Quick, overrides other styles |
Hard to maintain, not reusable |
|
Internal |
<style> in <head> |
Good for single-page styling |
Not reusable across pages |
|
External |
Separate .css file |
Reusable, maintainable |
Extra HTTP request |