Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: Basic Css Help

  1. #1
    New Coder
    Join Date
    Aug 2006
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Basic Css Help

    Hello friends

    I have 2 questions regarding the same problem. Are basic questions what I can test myself, but I wish know if in the specifications how it is resolved and if the browsers follow correctly.

    (1) Imagine what I have my file called styles.css. I have these style:

    .test { font-family: verdana; }
    .test { color: blue; }


    in the html document, I have
    <div class="test">My sample text</div>

    "My sample text" will render formatted with "Verdana" font and "Blue" color?

    (2) Now in the styles.css . I have these style:

    .test { color: red; }
    .test { color: blue; }


    "My sample text" will render formatted with red or blue color?

    Regards
    Last edited by ClickList; 09-20-2006 at 11:06 PM. Reason: changed font-color to color

  • #2
    Senior Coder
    Join Date
    Dec 2004
    Location
    Essex, UK
    Posts
    2,636
    Thanks
    0
    Thanked 0 Times in 0 Posts
    There's no attribute font-color, I assume you meant color. It'd take the last value given (blue).

  • #3
    New Coder
    Join Date
    Aug 2006
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mark87 View Post
    There's no attribute font-color, I assume you meant color. It'd take the last value given (blue).
    Thank you, do you talked about the item (2). And (1)?

  • #4
    Senior Coder
    Join Date
    Dec 2004
    Location
    Essex, UK
    Posts
    2,636
    Thanks
    0
    Thanked 0 Times in 0 Posts
    In example 1, yes it would be blue and have a font-family of Verdana; in example 2, it would be blue.

    You don't need to specify the element twice though, .test { font-family: Verdana; color: #00F } would work fine.

  • #5
    Regular Coder Graft-Creative's Avatar
    Join Date
    Aug 2004
    Location
    Web Designer - North East Lancashire U.K.
    Posts
    842
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by ClickList View Post

    .test { color: red; }
    .test { color: blue; }
    You can't have the same class with different attributes, well, you can, but the last one would simply cancel out the first, thus rendering the first style redundant - fine (if pointless) if using inline styles, but not if linking to an external stylsheet.

    Better to use two different classes, and name them in a contextual way i.e.

    Code:
    .highlight { color: red; }
    .lowlight { color: blue; }
    Kind regards,

    Gary

  • #6
    New Coder
    Join Date
    Aug 2006
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you, I understood.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •