SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Mar 2009
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy CSS unable to adjust font-size and font-weight

    Hi. I'm working my way through Ian Lloyd's "Build Your Own Website the Right Way" book, and I've hit a snag on page 195.

    I added this to my html page:
    <div class="galleryphoto">
    <img src="gallery/turtle-bite.jpg" width="400" height="258"
    alt="A turtle swims comfortably among the coral, despite its old injury - a large shark bite on one side"/>
    <p>This turtle was spotted swimming around the Great Barrier Reef (Queensland, Australia) quite gracefully, despite having had a large chunk taken out of its right side, presumably in a shark attack.<span class="photocredit">[Photographer: Ian Lloyd]</span></p>
    </div>

    I added this to my CSS page:
    .gallerphoto p {
    font-size: 65%;
    font-weight: bold;
    width: 430px
    line-height: 1.4em;
    }

    The browser reads the width and line-height correctly, but ignores the font-size and font-weight. As far as I can tell, I followed the instructions in the book correctly. Any ideas what I'm doing wrong?

  2. #2
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The reason is most likely that you have another rule in your style sheet that affects the same paragraph. And that rule either has a more specific selector or has an equally specific selector but is specified later in the style sheet.
    Birnam wood is come to Dunsinane

  3. #3
    SitePoint Member
    Join Date
    Sep 2008
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    AutisticCuckoo is correct!
    Another css rule will be overriding that one.

  4. #4
    SitePoint Member
    Join Date
    Mar 2009
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

    Thanks for your help! I shifted some things around and it worked.

  5. #5
    SitePoint Enthusiast
    Join Date
    Jan 2009
    Location
    India
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    !important would have also worked.

  6. #6
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, but using !important directives to override specificity can easily lead to style sheets that are very difficult to maintain. I wouldn't recommend it.
    Birnam wood is come to Dunsinane

  7. #7
    SitePoint Addict g1siberia's Avatar
    Join Date
    Dec 2008
    Posts
    236
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    always also check a books official website for erratum & errors


Tags for this Thread

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
  •