Luke Luke - 1 month ago 10
CSS Question

How to insert attribute selector for Hgroup subsection

I have looked up for attribute selector on several website but I still don't get it. If I am having this part of the code,

<hgroup>
<h2>HTML5 History</h2>
</hgroup>


How am I supposed to use the attribute selector so that my css code will only apply it to h2 and not the rest.

Answer Source

hgroup.change h2{
  color:red;
}
hgroup#change h2{
  color:blue;
}
<hgroup class="change">
    <h2>HTML5 History</h2>
    <p>HTML5 History</p>
    <span>HTML5 History</span>
</hgroup>
<hgroup id="change">
    <h2>HTML5 History</h2>
    <p>HTML5 History</p>
    <span>HTML5 History</span>
</hgroup>
<hgroup>
    <h2>HTML5 History</h2>
    <p>HTML5 History</p>
    <span>HTML5 History</span>
</hgroup>