Need to clarify something up

Discussion in 'CSS' started by codyturk, Jan 30, 2009.

  1. #1
    I need to know the difference between these two. I'll show you the way that I do it, and the way someone else does it. Just need to know which way is correct and why.

    My way
    margin:0;

    They're way
    margin:0px;

    Also here is another example

    My way
    margin:0; display:block; background:transparent;

    They're way
    margin:0;display:block;background:transparent;

    They're way in another way
    margin: 0;display: block;background: transparent;
     
    codyturk, Jan 30, 2009 IP
  2. qwertuiop

    qwertuiop Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    your way works but the reason they put px is that the margin can be site in different kinds of ways cm, piexls, or like how to do it blank just with the number.

    when the server reads the web site sometimes the spaces help read the css or html code thta you are using and after every ; must people do put a space there but ur website should still work they way that you are doing it but when you arer doing margins usually it is a good idea to but the tye of spacing you wan to use so the computer does not get the number mixed up
     
    qwertuiop, Feb 2, 2009 IP
  3. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #3
    you put the px in there in case you have to come back and make it a positive #. if you're 100% sure you won't, just slap the 0 up there. spacing isn't really relevant except for readability. do what you are comfortable with or what the boss tells you. Some go to extremes with this, *shrug* I do it the way I like and skip the rest.

    I usually space it out like crazy something like
    margin: 0px ; background: transparent ;
    why? so its pretty obvious when I forget a ; or if I cut n paste over it. And I put 0px since it makes it easier if I need to quickly add space to an element to debug.
     
    shallowink, Feb 2, 2009 IP
  4. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Shallowink is right.

    You should see some of the stuff my husband's boss puts out:

    
    
    #blah {
              position  :  relative;
              float     :  right;
              text-align:  left;
              background:  
                    #f00
                    url(blah.gif)
                    0 0 
                    no-repeat;
    }
    
    Code (markup):
    The extensive spacing should tip you off that it was written by a programmer and not a CSSer.

    The reason 0 = 0px/cm/pt/whatever is because zero is zero, regardless what it is you have zero of. 0apples is also still zero. I personally don't have units sitting on my zeros unless I removed a number and forget to take them out too.
     
    Stomme poes, Feb 3, 2009 IP
    eric.r likes this.