469,636 Members | 1,544 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,636 developers. It's quick & easy.

position:absolute implementation seems to contradict W3C definition

In the W3C document about CSS2, I read at

http://www.w3.org/TR/REC-CSS2/visure...hoose-position

the following:
absolute
The box's position (and possibly size) is specified with the
'left', 'right', 'top', and 'bottom' properties. These properties
specify offsets with respect to the box's containing block.

The implementation in firefox/mozilla as well as examples
and tutorials on the web say that position:absolute positions
HTML elements with respect to "the document", which seems
to be the root <html> element.

In contrast, I thought that "containing blocks" are generated
also by other elements than <html>, e.g. by <div> or <p>. As
such I would expect e.g. style="top:0px" refer to the edges
of these elements rather than to the edge of the document.

Is the implementation wrong (doubt it), is my understanding
of "containing block" wrong, or is there a special rule for
"containing block" in HTML which says that only the document
root creates a containing block?

Thanks,
Harald.
Jul 20 '05 #1
6 4686
Harald Kirsch wrote:
Is the implementation wrong (doubt it), is my understanding
of "containing block" wrong, or is there a special rule for
"containing block" in HTML which says that only the document
root creates a containing block?


See position: relative;

--
Mark.
http://tranchant.plus.com/
Jul 20 '05 #2
On 17 Sep 2004 02:26:59 -0700, Harald Kirsch <pi*******@gmx.de> wrote:
Is the implementation wrong (doubt it), is my understanding
of "containing block" wrong, or is there a special rule for
"containing block" in HTML which says that only the document
root creates a containing block?


In many documents the containing block is the viewport. But if a parent
element has position set to relative, absolute or fixed, it is now a
containing block for what lies within.

Ex.

.... content ...
<div>
... content ...
<div style="position: absolute; top: 1em;">...</div>
<div>

The inner div will be 1em from the top of the viewport.

.... content ...
<div style="position: relative;">
... content ...
<div style="position: absolute; top: 1em;">...</div>
<div>

The inner div is 1em from the parent div.
Jul 20 '05 #3
In article <16**************************@posting.google.com >,
pi*******@gmx.de says...
In the W3C document about CSS2, I read at
http://www.w3.org/TR/REC-CSS2/visure...hoose-position absolute
The implementation in firefox/mozilla as well as examples
and tutorials on the web say that position:absolute positions
HTML elements with respect to "the document", which seems
to be the root <html> element.
As mozilla don't relly speak, you most likely didn't see all.
No tutorial or example in internet is flawless...
In contrast, I thought that "containing blocks" are generated
also by other elements than <html>, e.g. by <div> or <p>. As
such I would expect e.g. style="top:0px" refer to the edges
of these elements rather than to the edge of the document.
No, that is clarly defined, absolute positioning is outside normal flow.
Look relations between absolute and relative and static positioning.
Is the implementation wrong (doubt it), is my understanding
of "containing block" wrong, or is there a special rule for
"containing block" in HTML which says that only the document
root creates a containing block?


There is "initial containing block", to which absolute elements are
positioned. There is no "the way" to render absolute position - that is
because how initial containing block is defined, or rather, isn't
defined. But it is not very often you ran to problems because this,
unless you do something really advanced.

--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Jul 20 '05 #4
Neal <ne*****@yahoo.com> wrote in message news:<op**************@news.individual.net>...
On 17 Sep 2004 02:26:59 -0700, Harald Kirsch <pi*******@gmx.de> wrote:
Is the implementation wrong (doubt it), is my understanding
of "containing block" wrong, or is there a special rule for
"containing block" in HTML which says that only the document
root creates a containing block?


In many documents the containing block is the viewport. But if a parent
element has position set to relative, absolute or fixed, it is now a
containing block for what lies within.


Thanks, that is exactly the information I was missing. Is this
true only for HTML or also for XML?

Harald.
Jul 20 '05 #5
On 20 Sep 2004 02:33:11 -0700, Harald Kirsch <pi*******@gmx.de> wrote:
Neal <ne*****@yahoo.com> wrote in message
news:<op**************@news.individual.net>...
On 17 Sep 2004 02:26:59 -0700, Harald Kirsch <pi*******@gmx.de> wrote:
> Is the implementation wrong (doubt it), is my understanding
> of "containing block" wrong, or is there a special rule for
> "containing block" in HTML which says that only the document
> root creates a containing block?


In many documents the containing block is the viewport. But if a parent
element has position set to relative, absolute or fixed, it is now a
containing block for what lies within.


Thanks, that is exactly the information I was missing. Is this
true only for HTML or also for XML?

Harald.


It certainly applies to HTML and XHTML. I'm not familiar enough with
general XML to address the other point.
Jul 20 '05 #6
Neal <ne*****@yahoo.com> writes:
It certainly applies to HTML and XHTML. I'm not familiar enough with
general XML to address the other point.


Well, you can apply a CSS stylesheet to an XML document - and if you
view it in something capable of dealing with both, you can get any
rendering you'd normally be able to with CSS.

Every element defaults to display inline, normal text, which is
usually useful. As a way of making an XML document (more) human
readable, it's quite good (especially if you can view it in something
that supports CSS-generated content to display attribute values). For
use on the web it's not particularly useful due to lack of support and
lack of standard semantics.

--
Chris
Jul 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Alexander Fischer | last post: by
4 posts views Thread by Peter Pfannenschmid | last post: by
4 posts views Thread by KiwiBrian | last post: by
6 posts views Thread by alex | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.