0

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?

Sinal
  • 1,155
  • 5
  • 17
  • 35

4 Answers4

3

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.

slikts
  • 8,020
  • 1
  • 27
  • 47
2

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
  • 369
  • 2
  • 7
1

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
  • 14,746
  • 28
  • 47
  • 65
0

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
  • 11,957
  • 7
  • 46
  • 68