Lesson 6: HTML Styles
Applying Inline Styles
The style attribute allows you to add CSS styling—such as colors, fonts, and sizes—directly to an HTML element.
<p style="color: blue; font-size: 18px;">Styling text directly.</p>
Why & How to Use:
Inline styles are useful for applying quick, unique design changes to single elements without writing an external CSS stylesheet.
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>HTML Styles</title></head><body style="background-color: #f4f4f4;"> <h1 style="color: green;">Styled Heading</h1> <p style="color: darkred; font-size: 20px;">This text has custom font color and size.</p></body></html>