What I want is that when doing focus
in an element li
(using navigation with the tab key) the style is changed (from h2
, h3
or div
) but not me It works.
I have the following code:
li{
background-color: #361;
background: #FF6;
}
li > a{
background: #FF1;
color: #1F9;
border: solid 4px #F36;
}
li h3 {
color: #a11;
}
li h2 {
color: #1a1;
}
li:focus h3{
border: solid 5px #21F;
color: #a11 !important;
}
li h2:focus {
border: solid 5px #21F;
color: #1a1 !important;
background-color: #111;
background: #111;
}
li div:focus {
border: solid 5px #21F;
color: #1a1 !important;
background-color: #111;
background: #111;
}
<ul>
<li>
<a href="/articulo-77-fracciones-e-instituciones?fc=IV.">
<div>
<div>
<h2>IV</h2>
<h3> Metas y Objetivos</h3>
<p>Las metas y objetivos de cada área de conformidad con sus programas operativos, así como sus funciones y actividades.</p>
</div>
</div>
</a>
</li>
<li>
<a href="/articulo-77-fracciones-e-instituciones?fc=IV.">
<div>
<div>
<h2>V</h2>
<h3> Metas y Objetivos</h3>
<p>Las metas y objetivos de cada área de conformidad con sus programas operativos, así como sus funciones y actividades.</p>
</div>
</div>
</a>
</li>
</ul>
but it is not working. If I apply:
li a:focus {
border: solid 5px #21F;
color: #1a1 !important;
background-color: #111;
background: #111;
}
If it works for me, but I do not want to apply the style to the a
element. I think I can not find the error.
If I put:
li > a
instead of:
li a
obvious I select the a
element from parent to li
only, but in the second form I select the a
element that is descended from li
no matter where is in the hierarchy right? It seems to be a very basic error but I can not find it.