HTML Styles

Inline Styles

Inline styles are added directly to HTML elements using the style attribute.

<p style="color: red; font-size: 20px;">This text is styled inline.</p>

Using the <style> Tag

The <style> tag allows you to write internal CSS within the <head> section.

<head>
  <style>
    p { color: blue; }
    .highlight { background: yellow; }
  </style>
</head>

Best Practices for Styling

  • Use external CSS for maintainability.
  • Avoid inline styles when possible.
  • Group related styles together and use classes.