Solved

Help with CSS id select and class

Posted on 2012-03-30
1
129 Views
Last Modified: 2012-04-04
Hi All -  I need some CSS help here.

In my stylesheet I have an ID selector like this.

    #newVisitors { ... stuff }

I assigned this ID selector a class

    #newVisitors .cbBlurb{ ....stuff}

Now what I need to do is style a <h2> element within the cbBlurb class that's within #newVisitors

I tried this

    #newVisitors .cbBlurb h2{ ....stuff}

and this

    #newVisitors h2.cbBlurb{ ....stuff}

and this

    #newVisitors .cbBlurb.h2{ ....stuff}

but none of them work.  

What do I need to do in order to get this to work?

Thanks
0
Comment
Question by:cdemott33
1 Comment
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 500 total points
ID: 37789335
The first one you tried is correct but alternatively you can use the second one and apply class cbBlurb to the h2 element as well as its parent element.

using the first notation here is some html that shows how to use it:

<!DOCTYPE html>
<html>
 <head>
  <title> Q_27656397 </title>
  <style type="text/css">
	#newVisitors { border: solid 3px black; background-color: green; }
	#newVisitors .cbBlurb { background-color: silver; }
	#newVisitors .cbBlurb h2 { color: red; }
  </style>
 </head>
 <body>
	<h2> standard black h2 </h2>
  <div id="newVisitors">
		<h2> black h2 on green in #newVisitors </h2>
		<div class="cbBlurb">
			other text in .cbBlurb
			<h2> red h2 </h2>
		</div>
  </div>
 </body>
</html>

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How can I expand text with explaination 5 30
Hovering effect 9 45
Put upload button on your image and change it 2 59
Error in JQuery 5 34
CSS3 Custom checkboxes This article shows how to style the checkbox form element using only CSS. Works in: Chrome, FF, Safari, Opera, IE9+ Uses modernizr.js to check for :checked pseudo class, falling back to plain old checkboxes (IE8 and bel…
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now