Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Help with CSS id select and class

Posted on 2012-03-30
1
Medium Priority
?
134 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …
Suggested Courses

715 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