Help me validate this code!

Discussion in 'CSS' started by viperxx, Feb 22, 2009.

  1. #1
    The code is the following:
    * html .postcol img {width:expression(this.width > 260? "260px" : this.width);} 
    Code (markup):
    [​IMG]

    Can't seem to validate this piece of code!
     
    viperxx, Feb 22, 2009 IP
  2. devnl

    devnl Guest

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    As far as I know CSS expressions will never validate.
     
    devnl, Feb 23, 2009 IP
  3. drhowarddrfine

    drhowarddrfine Peon

    Messages:
    5,428
    Likes Received:
    95
    Best Answers:
    7
    Trophy Points:
    0
    #3
    There is no such thing as "expression". It's a Microsoft only thing you should never use because it will only work in IE.
     
    drhowarddrfine, Feb 23, 2009 IP
  4. 007c

    007c Peon

    Messages:
    611
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Just use conditional iexplorer statements in your html. Of course that makes the validator look the other way. Otherwise don't use em ;)
     
    007c, Feb 23, 2009 IP
  5. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #5
    Wrong. You then contradict yourself -

    Correct.

    Bullshit. You use it BECAUSE it only works in IE, to make up for things that are MISSING from IE - in this case Max-width. That is the REALITY of writing cross browser code with a third of the users at large still using IE6.

    CSS validation in combination with working cross browser is usually going to fail. If you know WHY it is failing, as in 'expression' does not validate, then you can skip that line - if it's a problem on a project, document WHY it is used.

    This:
    * html .postcol img {width:expression(this.width > 260? "260px" : this.width);}

    Is the IE6/earlier version of THIS:

    .postcol img {max-width:260px;}

    Though I'd have written it:

    * html .postcol img {
    width:expression(this.width>260 ? "260px" : "auto");
    }

    Just to avoid the extra variable reference...

    While I am a huge stickler for valid markup as there is NO excuse for invalid HTML/XHTML - Valid CSS on the other hand is a pipedream if you want certain things to work quickly and easily in legacy IE. You need min-width and max-width in IE, an expression is a hell of a lot simpler than a parsing script - and since both are going to tie you to javascript, use the one that's less code.

    I wouldn't sweat that line not validating... Just as I would not sweat using zoom:1; to trip haslayout, -moz-inline-block and -moz-inline-box making up for firefux still (even in 3, even when they allege that it works properly) being a ***tard about inline-block, the use of -moz-opacity and filter:alpha(opacity=xx) to make up for gecko and IE being ****tards about opacity, etc, etc...

    Any coder worth their salt should take one look at that and go "Oh, IE min-width. Yeah, that won't validate - don't worry about it. It's the price we pay to support the majority of users who don't even know what a browser is, and have no interest in learning. Duuuuh... I just click the big blue E!"

    When it comes to CSS if you know WHY it doesn't validate (like say... and IE only property) then don't worry about it... Just be sure the stuff that SHOULD validate does so.
     
    deathshadow, Feb 23, 2009 IP