CSS tutorial - Dependence

Navigation

Skip navigation.

Site search

Site navigation

CSS tutorial

Printing

Other tutorials

Dependence

Some attributes are dependent on others. An example of this is would be the 'left' and 'top' attributes. These will only be used if the 'position' attribute has been set to absolute, relative, or fixed. For example:

div {
  position: absolute;
  left: 10px;
  top: 100px;
}

The Clip and z-index styles can also only be applied to absolutely positioned or fixed positioned elements.

If you fail to specify the styles that these others are dependent on, the browser will simply ignore those styles. As a result, you can specify the left and top positions of any element, but it will not have any effect. If a script later adds the required style, then suddenly all of the styles come into effect together.

There are also a few styles that will force certain other styles to be applied without you specifying them. Examples would be the float or position styles. Applying these to any element will immediately also apply the display:block; style, even if you never apply that style yourself.

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.