SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru Todd Temple's Avatar
    Join Date
    Mar 2005
    Location
    Tennessee
    Posts
    797
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Float Added To Divs Not Working

    I am trying to have three columns of text inside the DIV main-content. I added a class named "3col" with the properties of float: left; width: 200px; but it doesn't work. Any ideas why?


    LINK-
    http://www.securehostserver.info/smokies/
    Todd Temple > T2 Design

  2. #2
    Community Advisor silver trophybronze trophy
    dresden_phoenix's Avatar
    Join Date
    Jun 2008
    Location
    Madison, WI
    Posts
    2,804
    Mentioned
    34 Post(s)
    Tagged
    2 Thread(s)
    Simple. CSS identfiers( classes or IDs) may NOT begin with numbers. change your class name to "cols_3" and you will see it work, for example. Hope that helps.

  3. #3
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Sorry to butt in, but any idea why that is dresden? It's not just CSS either, it seems to be in other scripting languages as well. I wanted to reference my 3D maze by "3d" but came up with so many errors that I changed it to "threed"

    Why does a string not work if it starts with an int but will if it contains one? Is there a reason?
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if

  4. #4
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,367
    Mentioned
    180 Post(s)
    Tagged
    6 Thread(s)
    Quote Originally Posted by Markdidj View Post
    Sorry to butt in, but any idea why that is dresden? It's not just CSS either, it seems to be in other scripting languages as well. I wanted to reference my 3D maze by "3d" but came up with so many errors that I changed it to "threed"

    Why does a string not work if it starts with an int but will if it contains one? Is there a reason?
    HTML5 allows ids to start with an integer although in css you would need to escape them to make it work.

    As a matter of interest presently classnames in html can begin with a digit and you can do something like this which is valid html and cssa and works back to IE6.

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Untitled Document</title>
    <style>
    div.\31{background:red}
    div.\32{background:blue}
    div.\33{background:yellow}
    div.\34{background:green}
    </style>
    </head>
    
    <body>
    <div class="1">test</div>
    <div class="2">test</div>
    <div class="3">test</div>
    <div class="4">test</div>
    </body>
    </html>
    More info on escaping css.

  5. #5
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Wow, thanks Paul

    I did have a think why. I suppose it's quicker to interpret and throw an error rather than check the following characters to make sure it's either an int or string.
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if


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
  •