SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: css question

  1. #1
    SitePoint Addict
    Join Date
    May 2006
    Location
    Ljubljana
    Posts
    241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    css question

    Hello

    I've been looking through some CSS codes, and I came to:

    Code:
    ul#navlist li a.active
    {
    	color: #fff;
    	font-weight: bold;
    }
    This format isnt clear to me.. Why is there ul in front of #navlist?
    Could someone explain the code please?

  2. #2
    SitePoint Wizard rbutler's Avatar
    Join Date
    Jul 2003
    Location
    Springfield, MO
    Posts
    1,867
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why is there a ul in front of #navlist?
    The developer probably found it useful to distinguish which rules belonged to which element in a length style sheet or for specificity reasons.

    Code:
     
    ul#navlist li a.active
    {
    color: #fff;
    font-weight: bold;
    }
    The code says this: Look for an anchor tag with a class of active which resides inside a list item tag which is inside an unordered list with an ID of navlist and apply the following styles.
    Ryan Butler

    Midwest Web Design

  3. #3
    SitePoint Addict
    Join Date
    May 2006
    Location
    Ljubljana
    Posts
    241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by rbutler View Post
    The developer probably found it useful to distinguish which rules belonged to which element in a length style sheet or for specificity reasons.

    Code:
     
    ul#navlist li a.active
    {
    color: #fff;
    font-weight: bold;
    }
    The code says this: Look for an anchor tag with a class of active which resides inside a list item tag which is inside an unordered list with an ID of navlist and apply the following styles.
    Thanks for this explanation..
    How is it possible to write this other way?

  4. #4
    SitePoint Wizard rbutler's Avatar
    Join Date
    Jul 2003
    Location
    Springfield, MO
    Posts
    1,867
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How is it possible to write this other way?
    I'm not sure I follow you. You could omit the ul selector which precedes the hash mark (#) if specificity didn't come into play. It would really depend on the layout and what exactly you're trying to achieve with regard to how else you could write this rule or others. There's no magic bullet when it comes to CSS.
    Ryan Butler

    Midwest Web Design


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
  •