Css in HTML
? CSS in HTML
CSS (Cascading Style Sheets) is the language used to style HTML elements — controlling colors, layouts, fonts, spacing, and more.
How to Use CSS in HTML
1. Inline CSS
Directly inside an HTML tag using the style attribute.
<p style="color: blue; font-size: 18px;">This is blue text.</p>2. Internal CSS
Within a <style> tag inside the <head> section.
<head> <style> p { color: green; font-size: 20px; } </style></head><body> <p>This is green text.</p></body>3. External CSS
Link to a separate .css file with the <link> tag.
<head> <link rel="stylesheet" href="styles.css"></head>And in styles.css:
p { color: red; font-size: 22px;}Why Use CSS?
Separate content (HTML) from style (CSS)
Style multiple pages easily with one CSS file
Control layout, colors, fonts, responsiveness
Add animations and transitions
Basic CSS Syntax Example
selector { property: value;}Example:
h1 { color: navy; text-align: center;}Would you like me to show you how to write CSS for common elements, or explain CSS selectors and properties?