SitePoint Sponsor

User Tag List

Results 1 to 18 of 18
  1. #1
    SitePoint Wizard johnn's Avatar
    Join Date
    Mar 2001
    Location
    Southern California, USA
    Posts
    1,181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    font-size declare in body

    Hi,

    I declare

    body {
    font-size: 16px;
    font-family: verdana, helvetica, sans-serif
    line-height: 1.5;
    color: #000;
    margin: 0px;
    padding: 0px;
    background-color: #fff;
    }


    it does not work. The text stays the same even if I change
    font-size to have larger or lower values. I tried this:


    body, div {
    font-size: 16px;
    font-family: verdana, helvetica, sans-serif
    line-height: 1.5;
    color: #000;
    margin: 0px;
    padding: 0px;
    background-color: #fff;
    }

    it doesn't work either. I don't declare any font size in div or <p>. What's the problem?
    Thanks.

  2. #2
    SitePoint Wizard
    Join Date
    Oct 2001
    Location
    Tucson, Arizona
    Posts
    1,858
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This worked fine for me...
    Code:
    body {
        background-color: #ffffff;
        color: #000000;
        font-family: verdana, helvetica, sans-serif;
        font-size: 16px;
        line-height: 1.5;
        margin: 0px;
        padding: 0px;
    }

  3. #3
    SitePoint Wizard johnn's Avatar
    Join Date
    Mar 2001
    Location
    Southern California, USA
    Posts
    1,181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I use your code, but no success, not sure what I do wrong.

  4. #4
    SitePoint Addict psychedelic's Avatar
    Join Date
    Feb 2002
    Location
    Boston
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what's the URL?
    It works fine for me too.
    The Internet is prettier on a Mac.

  5. #5
    SitePoint Wizard iTec's Avatar
    Join Date
    May 2001
    Location
    Sydney, Australia
    Posts
    2,243
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    body div p td{
        background-color: #ffffff;
        color: #000000;
        font-family: verdana, helvetica, sans-serif;
        font-size: 16px;
        line-height: 1.5;
        margin: 0px;
        padding: 0px;
    }
    also what browser are you testing it in?

  6. #6
    Robert Wellock silver trophybronze trophy xhtmlcoder's Avatar
    Join Date
    Apr 2002
    Location
    A Maze of Twisty Little Passages
    Posts
    6,316
    Mentioned
    60 Post(s)
    Tagged
    0 Thread(s)
    Another question is are you using an external CSS file, or have you the CSS within the HTML page for example you could have something like this between <head>...</head> for example:

    <style type="text/css">
    <!--
    p {
    font-size : 10px;
    font-family : verdana, helvetica, sans-serif;
    color : black;
    background : white;
    }
    -->
    </style>

    I assume your browser might be having problems with; line-height 1.5
    Last edited by xhtmlcoder; Jul 5, 2002 at 02:42.

  7. #7
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You weren't closing your font-family attribute both times.

    This is probably 'breaking' the set including those attributes that have already been specified.

    Remember to always specify units when the attribute value is something *other than* 0.
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature

  8. #8
    SitePoint Wizard
    Join Date
    Oct 2001
    Location
    Tucson, Arizona
    Posts
    1,858
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Bill Posters
    You weren't closing your font-family attribute both times.
    Yeah, but then I fixed it, and he said that the new code still didn't work.

  9. #9
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you sure you';re looking at the correct file. As embarassing as it sounds, I sometimes will reload the page multiple times before realizing that I'm looking at the wrong file or that I uploaded the new file to the wrong directory.
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  10. #10
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Trust me already

    I just ran your first example through the W3C online CSS validator adding only a closing ; to the font-family attribute

    "No error or warning found

    Congratulations!

    This document validates as CSS!"
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature

  11. #11
    SitePoint Zealot
    Join Date
    Jul 2002
    Posts
    168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: font-size declare in body

    I have the exact same problem.

    Using IE 6 and an external sheet:

    All font specifications declared in the body tag (of external css) work perfectly for text WHICH IS NOT IN A TABLE. For text in a table, only the 'font-family' changes according to the css...

    So I work around it declaring everything seperately, still, this is strange behaviour...


    Ps, by now, I'm very sure I'm using the correct syntax, linked the correct css, etc etc, so it's not something silly like that...

    /* external css */
    BODY {background-color: black;
    font-family: Courier;
    font-style: normal;
    font-weight: normal;
    font-size: 50px;
    color: #669999;}
    Last edited by Guest; Jul 10, 2002 at 12:40.

  12. #12
    SitePoint Wizard johnn's Avatar
    Join Date
    Mar 2001
    Location
    Southern California, USA
    Posts
    1,181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, I'm too busy I didn't reply early. I've solved my problem. The problem is I'm put this at top of external style sheet file:
    "style/css"
    Before I declare body{ } which is a no-no, I removed it and it's ok now. Crazy dumb mistake

    Guess,
    I think we are not allowed to put comment in css. It looks like css doesn't like any comment.

  13. #13
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by johnn
    I think we are not allowed to put comment in css. It looks like css doesn't like any comment.
    No, it's fine.

    As Guest did it..

    /* This is a comment */

    ...is the correct format for a CSS comment.

    It can be anywhere amongst the css, even on the end of a line of css code

    /* This is a comment */
    p {
    text-align: center;
    /* This is another comment */
    color: #000
    font-family: arial /* and another comment */
    }



    Johnn, where did you get the style/css from?
    I don't recognise it.
    It for sure isn't a valid css comment and it doesn't look like any style tag property I've seen.

    Perhaps you were thinking of type="text/css"?

    If so, then it's worth noting that you don't need any tags in external css files, just the css itself and the .css suffix for the file itself.
    Last edited by Bill Posters; Jul 14, 2002 at 01:29.
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature

  14. #14
    SitePoint Wizard johnn's Avatar
    Join Date
    Mar 2001
    Location
    Southern California, USA
    Posts
    1,181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Bill,
    Thanks for correcting me... I'm learning.

  15. #15
    SitePoint Zealot
    Join Date
    Jul 2002
    Posts
    168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm wondering whether my IE 6.0 is buggy (even though I reinstalled).

    Here follows a sample html file; on my system the text in the table is not the right font size but some sort of default.

    <HTML>
    <BODY STYLE="font-family: Verdana; font-size: 50px; color: blue">

    This text is 50px.

    <TABLE BORDER="1">
    <TR><TD>This text is the same font & color but should also be the same px size which it isn't.</TD></TR>
    </TABLE>

    </BODY>
    </HTML>

  16. #16
    SitePoint Zealot ChrisOSX's Avatar
    Join Date
    May 2002
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    GUest,

    Add this somewhere in your stylesheet or in the head of your document if you only want it to be page specific.

    Code:
    td {
      font-size: 50px;
    }
    (Although, I really don't think you want 50px fonts!)

    Now every table cell will use whatever font size you specify in the declaration as above. Most browsers follow the body declaration and you don't have to do this. Not sure why you are having trouble, but perhaps this will fix it?

    Also, instead of

    Code:
    <body style="font-size:50px;">
    You should do

    Code:
    body {
      font-size: 50px;
    }
    Your method does work, but the method I'm suggestion is preferred. Just stick it in the head of your document between <style type="text/css"></style> tags.
    Last edited by ChrisOSX; Jul 18, 2002 at 18:29.

  17. #17
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Firstly, it's not specifically your copy of IE that is the problem.
    It is a known IE problem with the CSS inheritance that has existed since version 4 and, evidently, is yet to be corrected. (How much time do they need?)

    --

    FYI, you can also avoid repeating the CSS code for the td by simply adding td to the same CSS declaration as the body...

    Code:
    body, td {
    font-family: Verdana;
    font-size: 50px;
    color: blue
    }
    Fwiw, you can reduce it even further by using the CSS 'shorthand' equivalent- font: ...

    Code:
    body, td {
    font: 50px Verdana;
    color: blue
    }
    Last edited by Bill Posters; Jul 19, 2002 at 02:27.
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature

  18. #18
    SitePoint Zealot
    Join Date
    Jul 2002
    Posts
    168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ChrisOSX, Bill Posters, thanks for replying;
    The sample I gave was just the most simplified html file I could think of to show what exactly it is that's not working...
    As a matter of fact, the suggestions you made I already applied...
    All style declarations work perfectly, as long as I don't set them on the body tag, be it inline or an external css.
    So this is not really a big problem, it is just very weird. The body tag would be the ideal place to declare for example default fonts and font sizes for the whole site (in ext. css), though IE seems to disagree with that...
    If this is really a bug in IE I'm flabbergasted, flummoxed, mindboggled ...


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
  •