views:

66

answers:

4

I try to pass my css valiation yet I still have a few warnings like the following:

In (x)HTML+CSS, floated elements need to have a width declared. Only elements with an intrinsic width (html, img, input, textarea, select, or object) are not affected

In fact, I don't understand very well what it relly means. Anyone can explain?

+2  A: 

It means that if you want to apply a float: property on an element, you also have to apply a width: property to that same element

James Cassell
+3  A: 

It just means that if you set the float property on an element that doesn't have an intrinsic width, you need to also set the width property.

Edit: Also, that requirement has been stricken from the W3C standard. Seems to me like the validation engine you're using could be outdated.

Reinis I.
A: 

In a sense that isn't a validation error, not like you typed "funt" instead of "font" or forgot to close a bracket. It's just telling you that your CSS doesn't really make sense.

What's the point in floating something if it's going to take up 100% of the width of the container anyway, as block elements do by default?

AmbroseChapel
+1  A: 

The reason for adding width to elements with no declared or built-in width (intrinsic) is because the floated element will then expand to full width of the parent and you lose what you wanted to gain by floating it.

Rob