Welcome to Dream.In.Code
Getting Help is Easy!

Join 132,605 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 923 people online right now. Registration is fast and FREE... Join Now!




Ul-LI CSS questions

 
Reply to this topicStart new topic

Ul-LI CSS questions

TrueDego
post 10 Jul, 2008 - 09:20 PM
Post #1


New D.I.C Head

*
Joined: 3 Nov, 2007
Posts: 10


My Contributions


Ok Ive been making crappy web pages for about 10 years now using just old basic HTML. Ive seen and I like the idea behind CSS, and on how to make clean pages without tables. I just purchased a book called Beginning CSS Web development: from novice to professional and it told me about the heirachary, how the last code in the css gets priority first. Ive been previewing this while in creation of my own BS code while reading, and the ULs in the css are underlined, but LIs are becoming underlined even when I tell it text-decoration: none. Can someone tell me what I'm missing or what im not seeing? Thank you.



CODE
/*Start of code
--------------------------------*/
  h1 {
    color: #333;
    font-style: bold;
  }

  p {
    color: #f00;
    font-size: 12px:
  }
  
  h2 {
    color: red;
    font-style: italic;
  }
    
  ul {
    color: green;
    text-decoration: underline;
  }

  li {
    color: blue;
    font-style: italic;
    text-decoration: overline;
  }
  
  .test {
    text-decoration: underline;
  }

  .test2 {
    color: red;
  }

  .test3 {
    text-decoration: none;
    color: gray;
  }

  h3 {
    color: blue;
    text-decoration: underline;
  }

<html>
<head>
<title> Test Site </title>
<style type="text/css">@import url(test1.css);</style>
<center><h1> Hello everyone </h1></center>
</head>
<body>
<p> <h3>Test sentance one. </h3>
<p> <h2> Test Sentance two. </h2>
<ul class="wtf">This is awesome!
  <li class="test">Is this amazing?</li>
  <li class="test2">Could this be amazing?</li>
  <li class="test3">is this right</li>
</ul>
</body>
</html>

User is offlineProfile CardPM

Go to the top of the page

girasquid
post 10 Jul, 2008 - 09:27 PM
Post #2


Barbarbar

Group Icon
Joined: 3 Oct, 2006
Posts: 1,256



Thanked 14 times

Dream Kudos: 650
My Contributions


While it's true that the last thing works, that's only true for the exact same declaration:
CODE

ul {
color:green;
text-decoration:underline;
}
ul {
color:blue;
}

Will end up with a blue ul. If you wanted to make sure that your li had different attributes, you would want to set up a more specific rule - the more specific a rule is, the higher priority it gets:
CODE

ul {
color:green;
text-decoration:underline;
}
ul li {
color:red;
}

Has that cleared it up for you, or do you need me to explain a little more?
User is offlineProfile CardPM

Go to the top of the page

TrueDego
post 10 Jul, 2008 - 09:33 PM
Post #3


New D.I.C Head

*
Joined: 3 Nov, 2007
Posts: 10


My Contributions


QUOTE(girasquid @ 10 Jul, 2008 - 10:27 PM) *

While it's true that the last thing works, that's only true for the exact same declaration:
CODE

ul {
color:green;
text-decoration:underline;
}
ul {
color:blue;
}

Will end up with a blue ul. If you wanted to make sure that your li had different attributes, you would want to set up a more specific rule - the more specific a rule is, the higher priority it gets:
CODE

ul {
color:green;
text-decoration:underline;
}
ul li {
color:red;
}

Has that cleared it up for you, or do you need me to explain a little more?



Actualy i remember something about when you double specify, like in your example where you typed " ul li { " but would I still be able to comment on a second or third li down for an underlined li and still leave the others intact?
User is offlineProfile CardPM

Go to the top of the page

girasquid
post 11 Jul, 2008 - 06:45 AM
Post #4


Barbarbar

Group Icon
Joined: 3 Oct, 2006
Posts: 1,256



Thanked 14 times

Dream Kudos: 650
My Contributions


In that case, you would want to use a class:
CODE

ul li.highlighted {text-decoration:underline}
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 02:20AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month