CSS tutorial - Inline style

Navigation

Skip navigation.

Site search

Site navigation

CSS tutorial

Printing

Other tutorials

Inline style

An element can be given its own style by using the style attribute. This means that irrespective of what is specified in the stylesheets, it will always use these styles. That is not strictly true, since it is possible to make a selector that is considered more specific, but for most purposes, inline styles override stylesheets.

Using an inline style means that you largely lose control from stylesheets, meaning that if you decide to restyle your pages, you will be unable to restyle that part. It is generally not a good idea to use inline style attributes. They are best suited to scripting that creates animation effects, where there is a need to apply certain styles (usually positioning) irrespective of the style.

<div style="position: absolute; left: 10px; top: 100px;">

Last modified: 4 September 2008

  1. Previous
  2. Next
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.