SitePoint Sponsor

User Tag List

Results 1 to 14 of 14
  1. #1
    SitePoint Zealot akohl's Avatar
    Join Date
    Jun 2001
    Location
    Israel
    Posts
    184
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    commenting out lines in a style sheet and ie5.5

    I commnented out the first line of a style sheet like this;

    'h1 { style_property: value; }

    h2 { style_property: value; }

    h3 { style_property: value;}

    Opera 6 and Netscape 4.5 were fine. Bit ie5.5 lost style for h2 and h3 elements as well. What gives? Is there a better way to comment on style sheets?

    Andy

  2. #2
    + platinum's Avatar
    Join Date
    Jun 2001
    Location
    Adelaide, Australia
    Posts
    6,441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well.. i'm not sure if the old <!-- coment --> will work... it should, because thats how older browsers 'dont' detect you sheet...

  3. #3
    Anyone seen my cypher? OneChance's Avatar
    Join Date
    Apr 2001
    Location
    Seattle
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You commented out a line of your stylesheet using a single quote? I've never seen that done before. But you should use <!-- and --> as platinum suggested, although I think Opera 3.6 has problems with it. You could also try using /* and */ but RichInStyle.com says it might cause problems in some browsers.

  4. #4
    SitePoint Zealot akohl's Avatar
    Join Date
    Jun 2001
    Location
    Israel
    Posts
    184
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    better not to comment

    So we could conclude that any way you comment, it might cause problems with some browsers. I think we have enough possible problems with style sheets. So maybe its just better to comment in a seperate file and keep the style sheet clean of comments.

    Anybody agree with this approach?

  5. #5
    .net install meltdown
    Join Date
    May 2001
    Location
    View Ridge
    Posts
    692
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this:

    /* CSS comment */

  6. #6
    SitePoint Wizard Aes's Avatar
    Join Date
    Jun 2001
    Location
    Oklahoma
    Posts
    3,392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by isotope235
    Try this:

    /* CSS comment */
    Originally posted by OneChance
    ... You could also try using /* and */ but RichInStyle.com says it might cause problems in some browsers.
    Just use <!-- and -->; the problems will be less prevalent. You should not have to worry about display problems unless your visitors are using Opera 3.x, Netscape 3.x, or Internet Explorer 3.x; which is highly unlikely.
    Colin Anderson
    Ambition is a poor excuse for those without
    sense enough to be lazy.

  7. #7
    Typo Negative brokenvoice's Avatar
    Join Date
    Dec 2001
    Location
    Scotland
    Posts
    227
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's worth linking to an external style sheet to be honest. You can take care of a lot of style changes throughout your site by just changing the one file.
    In which case use:

    /* CSS comments */

  8. #8
    SitePoint Wizard Ian Glass's Avatar
    Join Date
    Oct 2001
    Location
    Beyond yonder
    Posts
    2,384
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The only valid CSS comment are the C style ones (/* and */). HTML comments are permitted to hide the style sheet from older browsers. And, what you did with the VB style comment didn't comment out the line, but rather told the browser to look for the 'h1 element in your document. Since that obviously doesn't exist, the CSS parser should ignore the rule.

    ~~Hope This Helps

  9. #9
    SitePoint Zealot akohl's Avatar
    Join Date
    Jun 2001
    Location
    Israel
    Posts
    184
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks!

  10. #10
    SitePoint Wizard
    Join Date
    Oct 2001
    Location
    Tucson, Arizona
    Posts
    1,858
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm going to have to agree with Ian on this one. You can use an HTML comment after the <style> tag and before the closing <style> tag, but not to comment out rules in the sheet itself.

  11. #11
    <C²: web standards /> cybercodeur's Avatar
    Join Date
    Dec 2001
    Location
    Montréal
    Posts
    729
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've always commented using /* blah */ in my CSS and I've never encountered problems in any of the major browsers.

    Richinstyle is a great ressource for CSS, but I wonder about what they're saying on such way to comment. As far as I've experienced, it works perfectly.
    Denis Boudreau <C²/> - Web Standards & Accessibility
    [+] ICQ number: 115649885 || Email: denis@cybercodeur.net
    [+] Daily Weblog on Web standards and accessibility : CYBERcodeur.net

  12. #12
    Tenacious T Tyhe's Avatar
    Join Date
    May 2001
    Location
    Hilversum
    Posts
    651
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have to admit that I never build a site that was quite large, but I was wondering why it is handy/important to put comments in an HTML or CSS file.

    Could someone tell me why they use it and what would happen if they didn't?

    Greetz.
    That's all folks...

  13. #13
    <C²: web standards /> cybercodeur's Avatar
    Join Date
    Dec 2001
    Location
    Montréal
    Posts
    729
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Let me give you this exemple. Last march, my team and I revamped Bombardier's website (www.bombardier.com). This site is huge. When I say huge, I mean about 17,000 pages. We were 6 people actively working on it. There were main CSS files to control general sections of the site and smaller CSS files to control other smaller aspects of it.

    Now, can you imagine just how many selectors and classes that can make?

    Over a thousand. Easily.

    Without comments to tell other developers that come across it what they're for and where they're used, they never would have been able to use the CSS to build any new portion of the site. Hell, even I who built them couldn't remember half of them. That's how many there were.

    Selectors had to be re-used. We didn't want to duplicate selectors when it was already created and fully available.

    When your CSS files is 600 lines long and you have 7 of them, you're happy they are commented when you're looking for that specific verdana gray bold in font-size 10.

    It saved us from a lot of headaches (which we still had plenty of either way... but that's another story).
    Denis Boudreau <C²/> - Web Standards & Accessibility
    [+] ICQ number: 115649885 || Email: denis@cybercodeur.net
    [+] Daily Weblog on Web standards and accessibility : CYBERcodeur.net

  14. #14
    SitePoint Enthusiast Crockett's Avatar
    Join Date
    Jan 2002
    Location
    Miami FLA
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Comments in Style Sheets
    According to CSS1, you can use textual comments in your style sheets that are similar to the comments used in the C programming language. C language comments begin with "/*" and end with "*/." With earlier versions of Internet Explorer, you can use either C language comments or HTML comments in your style sheets. HTML comments begin with "<!--" and end with "-->."

    The following example shows the difference between C language comments and HTML comments.

    /* Use C language comment blocks like this in your style sheets. */
    <!-- Do not use HTML comments like this in your style sheets. -->

    FROM: http://www.msdn.microsoft.com/librar...hancements.asp


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
  •