Page 1 of 1
Really quick question about XHTML.
Posted: Mon Oct 08, 2007 8:18 pm
by JellyFish
Is this illegal in XHTML?:
As long as it's an empty element right?
Posted: Mon Oct 08, 2007 8:47 pm
by Luke
There is a really easy way to tell...
http://validator.w3.org/check
(it's not valid that I know of)
Posted: Tue Oct 09, 2007 1:13 am
by matthijs
http://www.w3.org/TR/xhtml1/#C_2
Doesn't explicitly say anything about the div, but I assume it's invalid.
But it also wouldn't make any sense. Why would you need an empty div? A <hr />, <img /> or <br /> means and does something, a <div /> wouldn't.
Posted: Tue Oct 09, 2007 3:04 am
by JellyFish
matthijs wrote:http://www.w3.org/TR/xhtml1/#C_2
Doesn't explicitly say anything about the div, but I assume it's invalid.
But it also wouldn't make any sense. Why would you need an empty div? A <hr />, <img /> or <br /> means and does something, a <div /> wouldn't.
A empty div for the purpose to have a class of either
clearLeft,
clearRight or
clearBoth. I assume you know what these could mean.
Posted: Tue Oct 09, 2007 3:36 am
by matthijs
Ok, I get what you want. But I wouldn't consider that an elegant solution. There are other solutions to clear floats.
If you really are absolutely sure there is no other option then to insert a meaningless element just for the sake of clearing something, I would use a br or hr. Then use css to hide them (br class="hidden or hr class="hidden"). A hr would somehow make a little sense. When you would view the document unstyled, a hr displays as a kind of section separator.
Posted: Tue Oct 09, 2007 2:33 pm
by JellyFish
matthijs wrote:Ok, I get what you want. But I wouldn't consider that an elegant solution. There are other solutions to clear floats.
If you really are absolutely sure there is no other option then to insert a meaningless element just for the sake of clearing something, I would use a br or hr. Then use css to hide them (br class="hidden or hr class="hidden"). A hr would somehow make a little sense. When you would view the document unstyled, a hr displays as a kind of section separator.
I like the idea of hr, but I can't seem to get rid of the border or height in IE.
I just set border:none; and height:0px. And it left a gray horizontal line in IE.
Although br makes sense to, and it works. But I'd like to get rid of all the default behaviors that br has.
Posted: Tue Oct 09, 2007 3:49 pm
by matthijs
And are you absolutely sure you can't use the existing elements? Or can you self-clear the elements you want to clear?
Posted: Tue Oct 09, 2007 3:58 pm
by JellyFish
matthijs wrote:And are you absolutely sure you can't use the existing elements? Or can you self-clear the elements you want to clear?
Your absolutely right. I can do such things.
Thank you so much for the epiphany! But I'll still use <br class="clear[Left,Right,Both]"/> if all else fails.
To keep the concepts clear, is there a good article you'd recommend me reading, about clears?
Posted: Tue Oct 09, 2007 4:39 pm
by Kieran Huggins
ewe - class soup...
Stay semantic and strong, brother!
Posted: Wed Oct 10, 2007 1:13 am
by matthijs
This article sums it up very nicely:
Methods for Containing Floats
In most cases when I want a containing element to clear I float it as well. Say you'd have a layout with 3 horizontal boxes wrapped in a div, and below that again a wrapper div with a few boxes. You float the little boxes. Then to have the wrapper divs
not collapse I float them as well and just give them a width of 100% (no margin or padding horizontally to prevent box-model problems).