body vs. .body and em vs. px

Discussion in 'HTML & Website Design' started by iyoung, Nov 16, 2009.

  1. #1
    Hello,

    What is the difference (CSS) between body and .body in CSS?

    Also this code worked for me

    ul, ol { margin-left:1.8em; padding-left:0px; }

    but I don't know how to interpret it. What is the difference between padding-left and margin-left? I thought those are the same thing. Also, why would we display padding in px, but margin in em?

    How do I specify that I want this appearance for the ul and ol items only within the body of the page (not a footer or nav. bar)?

    thank you!!
     
    iyoung, Nov 16, 2009 IP
  2. drhowarddrfine

    drhowarddrfine Peon

    Messages:
    5,428
    Likes Received:
    95
    Best Answers:
    7
    Trophy Points:
    0
    #2
    drhowarddrfine, Nov 16, 2009 IP
  3. Diputs

    Diputs Greenhorn

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #3
    a "px" is a static value where as an "em" is a dynamic value. (dynamic meaning it can change depending on other values)

    to answer your other question, you would take the parent element and put it infront of the ul/ol

    example html would look like :
    
    <body>
     <div id="main_content">
       <ul>
           <li>Example 1</li>
           <li>Example 2</li>
       <ul>
      </div>
    
      <div id="footer">
            footer content here
      </div>
    </body>
    Code (markup):
    and your css would look like:

    #main_content ul {
    margin: 0px;
    padding: 0px;
    }
    Code (markup):
    This however would make ALL unordered lists in the container #main_paragraph have those attributes

    Hope this helps!
     
    Diputs, Nov 16, 2009 IP