Solved

Help with CSS id select and class

Posted on 2012-03-30
1
132 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 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

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

Suggested Solutions

Creating a CSS block that only applies to printing By default, all of your CSS applies to every possible view of your page - whether on screen, printed, landscape, touch-screen, or whatever.  You can, however, add CSS that only applies under certai…
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 tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

726 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