1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

CSS does not work after adding DOCTYPE at top of the page

Discussion in 'CSS' started by greatlogix, Sep 23, 2011.

  1. #1
    If i add DOCTYPE at top of the html document, some css does not work.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    HTML:
     <td class="leftmenu"  style="padding-left:12;">
    HTML:
    style="padding-left:12; does not work.

    What is the problem. what i am doing wrong here.

    Please help
     
    greatlogix, Sep 23, 2011 IP
  2. NLZ13

    NLZ13 Well-Known Member

    Messages:
    166
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    113
    #2
    Don't know if it is the problem but shouldn't the unit be in a unit of measure.
    I mean shouldn't padding-left: 12; be padding-left: 12px;
     
    NLZ13, Sep 23, 2011 IP
    greatlogix likes this.
  3. workingsmart

    workingsmart Well-Known Member

    Messages:
    411
    Likes Received:
    12
    Best Answers:
    9
    Trophy Points:
    120
    #3
    As stated above - there needs to be a unit of measuer ==> 12px / 12% / 12em
     
    workingsmart, Sep 23, 2011 IP
    greatlogix likes this.
  4. Wpisolutions

    Wpisolutions Peon

    Messages:
    10
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    <td class="leftmenu"  style="padding-left:12px;">
    HTML:
    is correct. you must declare px for pixels in css.
    This would not be correct in html
    <td width="300px">
    HTML:
     
    Wpisolutions, Sep 23, 2011 IP
    greatlogix likes this.
  5. drhowarddrfine

    drhowarddrfine Peon

    Messages:
    5,428
    Likes Received:
    95
    Best Answers:
    7
    Trophy Points:
    0
    #5
    Doctypes are NEVER to be added as an afterthought but the very first thing to go on a page before anything else.
    Also, new web pages have NO need for transitional. ALWAYS use strict.
     
    drhowarddrfine, Sep 23, 2011 IP
  6. greatlogix

    greatlogix Active Member

    Messages:
    664
    Likes Received:
    13
    Best Answers:
    1
    Trophy Points:
    85
    #6
    Thanks friends for quick reply. adding 'px' fixed the problem. so if you add doctype must add 'px'
     
    greatlogix, Sep 23, 2011 IP
  7. workingsmart

    workingsmart Well-Known Member

    Messages:
    411
    Likes Received:
    12
    Best Answers:
    9
    Trophy Points:
    120
    #7
    OMG!!! The "px" had NOTHING to do with your DOCTYPE... All pages should have a WELL THOUGHT OUT DOCTYPE.

    LISTEN TO THE DOCTOR!! ^^^^^^^^^^^^^
     
    workingsmart, Sep 23, 2011 IP
  8. Anonymous Hackers

    Anonymous Hackers Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    U need Edit Your Code

    <td width="300px">
    HTML:
     
    Anonymous Hackers, Sep 23, 2011 IP
  9. Wpisolutions

    Wpisolutions Peon

    Messages:
    10
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Read underlined statement. nothing wrong with my code
     
    Wpisolutions, Sep 24, 2011 IP
  10. Thomasan

    Thomasan Active Member

    Messages:
    310
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #10
    Add PX , problem resolve. Use the px in the Css.
     
    Thomasan, Sep 26, 2011 IP
  11. drhowarddrfine

    drhowarddrfine Peon

    Messages:
    5,428
    Likes Received:
    95
    Best Answers:
    7
    Trophy Points:
    0
    #11
    I think he needs to add px to the css. Problem solved!!!!!!
     
    drhowarddrfine, Sep 27, 2011 IP
  12. ethikz

    ethikz Peon

    Messages:
    92
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #12
    As stated before, I'm just reiterating to beat a dead horse. Doctype had nothing to do with why CSS wasn't working, css wasn't working because no unit of measurement was declared.

    Doctype is used for validation purposes. It tells the browser what version of coding you are using, that is all.
     
    ethikz, Sep 27, 2011 IP
  13. drhowarddrfine

    drhowarddrfine Peon

    Messages:
    5,428
    Likes Received:
    95
    Best Answers:
    7
    Trophy Points:
    0
    #13
    Actually, yes it does! In quirks mode, when you aren't using a doctype (and no one should ever be in quirks mode), lack of a dimensional unit always meant px.
     
    drhowarddrfine, Sep 27, 2011 IP
  14. ethikz

    ethikz Peon

    Messages:
    92
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #14
    Hey you learn something knew everyday.

    Thanks for that info. So common place now days to include doctype, quirks mode fell off the wayside.
     
    ethikz, Sep 27, 2011 IP
  15. drhowarddrfine

    drhowarddrfine Peon

    Messages:
    5,428
    Likes Received:
    95
    Best Answers:
    7
    Trophy Points:
    0
    #15
    Quirks mode came about because Microsoft screwed up Internet Explorer and didn't implement the box model properly. It's the ONLY reason we have to use doctypes at all! So the browser can tell whether you're trying to implement layout properly and not Microsoft's way. Without Microsoft's F-up, there would be no quirks mode and no need for doctypes.
     
    drhowarddrfine, Sep 27, 2011 IP
  16. ethikz

    ethikz Peon

    Messages:
    92
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #16
    Without Microsoft there wouldn't be a need for a lot of the crap that we have to do for it to display properly
     
    ethikz, Sep 28, 2011 IP
  17. drhowarddrfine

    drhowarddrfine Peon

    Messages:
    5,428
    Likes Received:
    95
    Best Answers:
    7
    Trophy Points:
    0
    #17
    Then you'll understand this.
     
    drhowarddrfine, Sep 28, 2011 IP
  18. ethikz

    ethikz Peon

    Messages:
    92
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #18
    Very funny and unfortunately true. Good read, thanks for that
     
    ethikz, Sep 28, 2011 IP