User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the HTML and CSS section within the Web Development category of DaniWeb, a massive community of 392,068 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,271 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our HTML and CSS advertiser: Lunarpages Web Hosting
Views: 1136 | Replies: 1
Reply
Join Date: Aug 2004
Posts: 1
Reputation: raja is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
raja raja is offline Offline
Newbie Poster

Solution css help plzz

  #1  
Oct 1st, 2005
Hey Friends iam a novice in css and i just started using it . does any one can explain abt the class selectors and id selectors and when to use them with clear exapmples plz. Thanks in advance.
cheers
Raja
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2004
Posts: 1,589
Reputation: tgreer is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 34
Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: css help plzz

  #2  
Oct 1st, 2005
Hello, welcome to the forum. Please do us all the favor of using complete sentences with proper spelling and punctuation. "Abbreviated" speech is strongly discouraged.

An "id selector" will apply to a specific element, the element with that id. They start with a "#" sign.

So in this style declaration, the second paragraph would apply the style.

<html>
<head>
  <title>ID selector</title>
  <style type="text/css">
    #myStyle { letter-spacing: 0.3em }
  </style>
</head>
<body>
   <p id="noStyle">Normal width</p>
   <p id="myStyle">Wide text</p>
</body>
</html>
A class selector on the other hand, is generic, and can be applied to multiple elements of differing types. Class declaractions begin with a ".", and are applied using an element's "class" attribute:

 <html>
<head>
  <title>ID selector</title>
  <style type="text/css">
    #myStyle { letter-spacing: 0.3em };
    .greenStyle { color: green };
  </style>
</head>
<body>
   <h1 class="greenStyle">Everything is Green</h1>
   <p id="noStyle" class="greenStyle">Normal width</p>
   <p id="myStyle" class="greenStyle">Wide text</p>
</body>
</html>
Note that ID selectors are more specific in the cascading hierarchy. Thus if the "myStyle" declaration also specified a color, the "myStyle" paragraph would be that color rather than green.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb HTML and CSS Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the HTML and CSS Forum

All times are GMT -4. The time now is 11:56 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC