Pablo Fernandez
Pablo Fernandez

Reputation: 287410

Are static and relative with no other attributes always rendered in the same place?

I understand that an element with position relative will be used as the fixed for elements inside it with positioning absolute, and that with relative I can push the element around, but if I don't add any other attributes, will an element with this style:

.element1 {
   position: relative;
}

always render the same as one with:

.element2 {
  position: static;
}

If not, when would they differ?

Upvotes: 1

Views: 39

Answers (2)

Shawn Taylor
Shawn Taylor

Reputation: 3969

It will appear same because you are saying that I am going to position you and not instructing where to position so unless you position it will remain at same place.

Upvotes: 3

Zsolt Schäfer
Zsolt Schäfer

Reputation: 286

I've found a wiki entry dealing exactly with this topic:

http://www.w3.org/wiki/CSS_static_and_relative_positioning

According to this, it makes only a difference, if there is also some positioning, as you said, and other elements around, which might then be overlapped by your relative positioned one.

Upvotes: 1

Related Questions