Body HTML and CSS | Inline CSS

Placing CSS definitions inside the HTML BODY tag is frowned upon by designers (it's not even validated by W3C), but there are certain scenarios where you simply have to do it:

  • HTML emails. Since the HEAD tag is stripped by all web-based email services (and some desktop clients as well) so that it doesn't interfere with the HEAD tag on their own page, you have to embed your CSS in the BODY tag.
  • Content that will be displayed inside aggregators (remote sites that grab a URL and display it with their own header).

Place your CSS inside a STYLE tag.

HTML Example:



This is a paragraph with CSS defined inside the BODY tag

Result:

This is a paragraph with CSS defined inside the BODY tag

Again, this is not to be used unless you really have to. Under normal circumstances, always place your CSS definitions inside the HEAD tag.

Share

Learn how to design amazing websites