New home page

Stephan Soller stephan.soller at helionweb.de
Thu Oct 14 08:00:10 PDT 2010


On 14.10.2010 13:03, Bruno Medeiros wrote:
> On 14/10/2010 09:09, Stephan Soller wrote:
>>>
>>> There is no confusion, I know "the "position" property does not
>>> influence how large an element is". I don't care how big or small the
>>> inner div is, I just want it to be contained in the parent div. I just
>>> mentioned the 'position' property because if position is 'fixed', it
>>> does make sense for that div not to be considered as contained in the
>>> parent div. But not so for other values of position (at least for the
>>> default one).
>>>
>>
>> Sorry, look like I got confused then. :)
>>
>> I'm still not sure if I understand your point correctly. Do you mean
>> that it's inconsistent that some positioning models take the element out
>> of the document flow?
>>
>
> Not exactly. My problem is that when an element is taken out of the flow
> (such as with "float:left"), it means the element no longer needs to be
> contained in the parent div. I think that model is very unhelpful.
> Although I'm no expert in HTML coding, I would venture that in at least
> 90% of the cases that's what you want (for the element to be contained
> in the parent, if its position is not 'fixed').
> Otherwise this brings up several problems: it messes up the layout of
> the elements right after the parent div. Or it messes up the area for
> the background/border colors of the parent div.
> However if a clearer div works without additional problems, I'm probably
> happy with that, even if its more verbose.
>

In the context of using floats for multi column layout I agree with you. 
It just doesn't make sense for the parent element to not contain any 
floating child elements. I looked in the CSS 2.1 spec to figure out why 
they defined it this way and the third example in the [section about 
floats][1] makes it pretty clear. Basically if you float an image in a 
paragraph you want the next paragraph to float around it, too. If you 
don't want it set the "clear" property of the next element (e.g. 
headlines). Therefore the "cross border of parent box" default is a good 
choice in such situations.

When using floats for layout I would rather like the default to be that 
floats are contained in their parent boxes. But that is not what floats 
were made for so the decision is ok IMHO.

[1]: http://www.w3.org/TR/CSS21/visuren.html#floats

>>>> But all this does not change the fact that
>>>> using floats for column layouts is still nothing else than a workaround
>>>> for the missing column layout model in the early days.
>>>>
>>>> For many page layouts this actually isn't needed but especially people
>>>> used to use tables for layouts often try to use this technique because
>>>> it mimics tables more or less. With CSS tables you don't have to use
>>>> floats any more since you have all the power of tables in CSS now (with
>>>> less markup in most cases). These however only work with IE 8 or newer
>>>> (I'm not sure if not already in IE 7) and I don't know about FF 2. If
>>>> you have to make pages that work in IE 6 and 7 you still have to use
>>>> floats though.
>>>>
>>>
>>> Well I would say some sort of "column layout model" (if understood your
>>> term correctly) is pretty essential. You need something like that, or
>>> something that can do the same job nearly as easily. So are you saying
>>> its ok to use CSS tables now? (disregarding the issue with old browsers)
>>> Because when I first learned about CSS and div layouts, the mantra was
>>> "tables are evil, don't use tables".
>>>
>>
>> I also heard/read that a lot when learning CSS. Using table _elements_
>> for layout is bad stuff since the table element in HTML indicates
>> tabular data. If you use it for layout the abstract content (or data) of
>> the page gets totally screwed up just for it to look right.
>>
>> However the layout rules of tables are quite useful and so they found
>> their way into CSS. If you can properly separate data from presentation
>> you can use whatever layout rules you want. ;)
>>
>> Basically don't use table _data_ to push elements around in HTML. Using
>> table layout rules in CSS is ok since it does not interfere with the
>> data of the page.
>>
>
> Ok, so it is as I thought, is is still "wrong"/unrecommended to use
> tables for layout. The recommended way to do column layouts is still
> with divs, right? By "column layouts" I don't mean tables, but stuff
> like a sidebar of any kind (the typical two or tree column layout).
>

Yes, in HTML4 and XHTML 1 you would use div elements for each "column". 
I actually don't like that very much because it usually ends with a lot 
of div elements that don't add any useful information to the document. 
It's still better than tables though because table elements have a 
meaning that isn't met. But that's a problem of these two HTML versions 
(they lack structural block level elements). HTML5 adds more meaningful 
elements for that purpose (section, aside, header, footer, …) but that's 
a different story.

Happy programming
Stephan


More information about the Digitalmars-d-announce mailing list