Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![garrycohen](https://secure.gravatar.com/avatar/025c29501c694a5718f359860ffee8a9?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
garrycohen
13,914 PointsHow to select specific H3 tag
can someone please help.. cannot seem to work it this out..I need to select this specific h3 tag to change the styling.. but cannot seem to correctly select it..
<div id="pagecontent" class="clearfix">
<form action="?" method="post">
<p> Fill out the form below and I will get back to you.</p>
<h3 id="feedback"><?php echo $feedback; ?></h3>
<fieldset>
<div>
<label>Name </label>
<input name="name" id="name" type="text" class="form-poshytip" title="Enter your full name" />
</div>
would it need to be...?
#pagecontent h3 {
}
or
.clearfix h3 {
}
i know its simple but just cannot figure it out!
Thanks
3 Answers
![Adam Moore](https://uploads.teamtreehouse.com/production/profile-photos/755052/micro_IMG_0552.jpg)
Adam Moore
21,956 PointsYou could select the h3 both of those ways, since #pagecontent
and .clearfix
are its parent. You could also, since you only have one h3
, just write h3{ }
. However, assuming you are going to have more h3s, since you gave the h3 a specific ID, I would recommend using #feedback
, so that you know, using its unique identifier, if you add more h3s, you won't have to worry about the others getting selected.
![Cesar Guerrero](https://uploads.teamtreehouse.com/production/profile-photos/89021/micro_FullSizeRender.jpg)
Cesar Guerrero
11,190 PointsIf you want to select a specific h3 tag, you must give that element an id. An id is a unique selector in html which can be accessed through javascript or css. When using an id, the css styling never gets repeated so it is perfect for when only needing to assign it to one specific element.
Heres an example with your situation
```html
<h3 id="feedback"><?php echo $feedback; ?></h3>
```
So you can select that specific h3 element you need with
```
#feedback
{
//Apply Styling Here
}
```
![garrycohen](https://secure.gravatar.com/avatar/025c29501c694a5718f359860ffee8a9?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
garrycohen
13,914 PointsMany thanks for your help Cesar!
![Kevin Lozandier](https://secure.gravatar.com/avatar/405efe275ceff3492be8b0985531fa19?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Kevin Lozandier
Courses Plus Student 53,747 PointsHi, Garry Cohen:
When it comes to selecting specific types of elements, you may want to be very careful resorting to an id. Depending on whether the context h3
is used in your content will be frequent or not, it may be better to leverage a class of the overall component it is part of, also considering :only-of-type
, nth-of-type
, and first-of-type
.
I would say a use of id
is overkill in this particular case.
// Note I'm using Sass for brevity purposes
#pagecontent h3
// Some styles here
#pagecontent h3:first-of-type
// Some styles here.
#pagecontent .subheader
// h3 == .subheader; in case you need more than one
![garrycohen](https://secure.gravatar.com/avatar/025c29501c694a5718f359860ffee8a9?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
garrycohen
13,914 PointsHi Kevin, many thanks for your help here.
I hope one day this kind of stuff will become second nature to me.. but hopefully with lots of practice and help from guys like yourself on here it will be possible!
Cheers Garry
garrycohen
13,914 Pointsgarrycohen
13,914 PointsThanks Adam, that makes sense and worked perfectly.