SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2004
    Location
    London
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    CSS 2.1 validation of properties with _ or *

    Hi All,

    Im currently trying to get the css for this site to validate but some of css properties containing _ and * at the start of the properties name
    example
    HTML Code:
    Property _margin-bottom doesn't exist : 10px
    Property _border doesn't exist : 1px solid #cebda5
    Property _height doesn't exist : 2em
    validation css countrylife.co.uk

    I currently presuming that this is correct and that the css validation service does not allow any properties starting with _ or * when using the default CSS 2.1 validation, i have had some people say that these properties are valid and that the validation service is broken.

    I have looked at the W3C CSS21 spec and have found a reference to using properties with - _ or *

    Vendor specific extensions
    quote "An initial dash or underscore is guaranteed never to be used in a property or keyword by any current or future level of CSS. Thus typical CSS implementations may not recognize such properties and may ignore them according to the rules for handling parsing errors. However, because the initial dash or underscore is part of the grammar, CSS 2.1 implementers should always be able to use a CSS-conforming parser, whether or not they support any vendor-specific extensions. Authors should avoid vendor-specific extensions"

    So basically these vendor properties are not valid and never will be. So these vendor hacks should be seperated into vendor specfic css files ?

    Please note i am far from a css guru.
    David Stevens, create-inspire
    PHP London, www.phplondon.org

  2. #2
    SitePoint Addict
    Join Date
    Jun 2007
    Location
    Sydney, Australia
    Posts
    253
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes they are not valid CSS

    but whether that matters to you or not is a different question

  3. #3
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by davro View Post
    So basically these vendor properties are not valid and never will be. So these vendor hacks should be seperated into vendor specfic css files ?
    Vendor-specific extension aren't valid, since they are by definition extensions to the CSS specification. They are permitted to use, but they won't validate.

    Preceding a property name with '*' is invalid and should definitely be avoided. Not to be confused with the legitimate (and valid) Tan hack (* html), of course.

    Valid vendor-specific properties may be kept in the normal CSS file, if you don't mind the validation errors.

    Invalid hacks should always be kept in separate CSS files (or, better yet, avoid them altogether).
    Birnam wood is come to Dunsinane

  4. #4
    SitePoint Enthusiast
    Join Date
    Jun 2004
    Location
    London
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the input,

    Invalid hacks should always be kept in separate CSS files (or, better yet, avoid them altogether).
    Separating CSS hacks into browser specfic files is ok apart from the maintaince lots more files for frontend developers to manage. Avoiding vendor related properties is simply not possable and generally causes bad semantic html to accommodate vendor related quirks.

    The problem i have is that the W3C CSS21 spec is contradicting it self because the initial dash or underscore is part of the CSS21 grammar, but anything that uses CSS, identifiers are actually invalid even though it is syntactically correct, surely it would be better for the jigsaww service to seperate vendor related properties into a seperate section and validate the rest.

    In a nut shell: Whats the point in having a spec that says you can do something, then on the other hand say that what you have done is invalid, would be better to raise it as a warning ?
    David Stevens, create-inspire
    PHP London, www.phplondon.org

  5. #5
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by davro View Post
    Avoiding vendor related properties is simply not possable
    Funny. I've been using CSS for almost 8 years and never used a vendor-specific property.

    Quote Originally Posted by davro View Post
    The problem i have is that the W3C CSS21 spec is contradicting it self because the initial dash or underscore is part of the CSS21 grammar, but anything that uses CSS, identifiers are actually invalid
    It's syntactically correct, but those properties aren't part of the CSS specification and are therefore invalid. W3C have no control over these properties and can't be expected to know which properties different vendors decide to invent.
    Birnam wood is come to Dunsinane

  6. #6
    SitePoint Enthusiast
    Join Date
    Jun 2004
    Location
    London
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dude, i have been developing for 12 years if that matters at and have never seen a site with valid css and decent semantic html.


    What is said was.
    Avoiding vendor related properties is simply not possable and generally causes bad semantic html to accommodate vendor related quirks.
    If you going to quote me then quote the whole sentance !!!!


    UNSUBSCRIBE "AutisticCuckoo"
    David Stevens, create-inspire
    PHP London, www.phplondon.org

  7. #7
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by davro View Post
    Dude, i have been developing for 12 years if that matters at and have never seen a site with valid css and decent semantic html.
    Look at my blog, then. Valid CSS2.1 (there are 47 warnings, but they can be safely ignored). The markup is as semantic as I can make it, too. Feel free to suggest improvements, if you like.

    The site I maintain in my job (bolagsverket.se) is also valid and semantic HTML 4.01 Strict and valid CSS2.1 (with warnings that can be ignored).

    Okay, so two sites isn't much after 12 years, but I promise you there are others.


    Quote Originally Posted by davro View Post
    If you going to quote me then quote the whole sentance !!!!
    I'm sorry, but I don't see how the second part of that statement qualifies the first. My apologies if you feel hard done by.

    In the first part you say that avoiding vendor-related properties isn't possible.
    In the second part you say that avoiding vendor-related properties causes 'bad semantic html', which I intrepret as 'unsemantic HTML'.

    So let me rephrase my previous statement:
    I've been using HTML since 1993 and CSS since 2000 and I have never used a vendor-specific CSS property and I still consider myself able to write semantically correct HTML.

    There, I've countered both parts of your statement and included a reference to my markup experience in the process.
    Birnam wood is come to Dunsinane

  8. #8
    SitePoint Zealot
    Join Date
    Feb 2006
    Posts
    184
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Since property hacks are targeted at IE, you can use hacks that validates by either:

    - Putting them into a separate .css file and including them with an IE conditional (HTML conditional comment) so the validation tool doesn't see invalid CSS.

    or

    - Using a hack that validates, such as:
    * html #some div.element { ... }

    Separating CSS hacks into browser specfic files is ok apart from the maintaince lots more files for frontend developers to manage.
    Generally speaking you only need one extra CSS file for IE hacks, if you choose to go that route. Large sites already have several CSS files that separate layout, typography, etc. Just make sure you put all of the CSS files into a single folder and have them well named and documented, and it shouldn't be hard to manage the files at all.

    Avoiding vendor related properties is simply not possable and generally causes bad semantic html to accommodate vendor related quirks.
    I'm sorry but that's just not true. Honestly it sounds like you're under the impression that property hacks are the only way to specifically target IE6. There are other hacks and methods available, which pass validation.

  9. #9
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,283
    Mentioned
    51 Post(s)
    Tagged
    2 Thread(s)
    The Tan hack/Holly hack is valid? I have one site where I used it to add something to IE6 and that was the only thing that did not validate. It said something like, "expected { or (something else I forget) but found 'html' instead."

    However, the star hack is so far the only hack I've used to get around IE6. I don't write for IE5.5, but Paul O'B does and I think he uses the w/idth thing or whatever to get around the broken box model. But if it's only IE6 that you're writing for, you can try going the other way-- using selectors IE6 doesn't understand AFTER the IE version. For instance, I am building a site where I have semi-transparent PNGs and I didn't feel like adding some crazy JS for that-- screw it, I made a gif in GIMP and I feed that to IE6.
    Code:
    #mainmenu li a {
      blah blah menu stuff;
      background-image: url(menubackground.gif);
    }
    #imgmenu>#mainmenu li a {
      background-image: url(menubackground.png);
    }
    I guess it's hacking of a sort, but it's not actually a hack. Totally valid. This doesn't always work but after I thought of it, I was able to replace a lot of * html's in my CSS : )

  10. #10
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Stomme poes View Post
    The Tan hack/Holly hack is valid? I have one site where I used it to add something to IE6 and that was the only thing that did not validate. It said something like, "expected { or (something else I forget) but found 'html' instead."
    It sounds as if you omitted the descendant combinator (blank space), using *html instead of * html.
    Birnam wood is come to Dunsinane


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •