This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 154 - Warn for floated elements without intrinsic width
Summary: Warn for floated elements without intrinsic width
Status: RESOLVED FIXED
Alias: None
Product: CSSValidator
Classification: Unclassified
Component: CSS 1.0 (show other bugs)
Version: CSS Validator
Hardware: Other other
: P5 enhancement
Target Milestone: ---
Assignee: This bug has no owner yet - up for the taking
QA Contact: qa-dev tracking
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-02-27 16:38 UTC by Philippe Le Hegaret
Modified: 2009-02-04 15:05 UTC (History)
1 user (show)

See Also:


Attachments
test case (191 bytes, text/css)
2009-02-04 14:50 UTC, Olivier Thereaux
Details

Description Philippe Le Hegaret 2003-02-27 16:38:36 UTC
One thing you'll need to fix is that floated elements must have a width
> declared:
> 
>     <http://www.w3.org/TR/REC-CSS2/visuren.html#floats>
> 
elements with intrinsic width include:
html, img, input, textarea, select, and object.

so the following should NOT create a warning:

img
{
  float: right;
}

for non-replaced elements (i.e. elements with no intrinsic width),
could we please issue a warning if no width is given?

for example, the following paragraph rule set SHOULD create a
missing width warning:

p
{
  float: right;
}
Comment 1 Olivier Thereaux 2007-07-19 09:11:29 UTC
Related discussion:
http://lists.w3.org/Archives/Public/www-validator-css/2007Jul/0016.html
«The problem I see is that the css validator is not tied to HTML. How do we know if img is the html's img tag or something else? We could issue warnings only if we know that a CSS is linked from an HTML document»

Fair question, although we do know that the main usage of CSS is to style HTML and SVG, and that could remain a  decent assumption. Do we still have a list of html elements?
Comment 2 Olivier Thereaux 2009-02-03 20:04:25 UTC
I somewhat miraculously managed to add the warning for the general case, but have not yet found how/where I can determine which element selector is applicable. Any pointer?

For reference, the code is in http://dev.w3.org/cvsweb/2002/css-validator/org/w3c/css/properties/css1/Css1Style.java (look for findConflicts )
Comment 3 Olivier Thereaux 2009-02-04 14:50:21 UTC
Created attachment 624 [details]
test case
Comment 4 Olivier Thereaux 2009-02-04 15:05:36 UTC
http://lists.w3.org/Archives/Public/www-validator-cvs/2009Feb/0050.html 
seems to have done the trick - the test case validates with a single warning for the <p> but not the <img> selector, which has intrinsic width.