html - How to get a <img> tag the focus -
i have below code in html page:
<img id="image_java" alt="image_not" src="images/java-icon.png">
in css page below code:
#image_java: focus { outline: 2px solid blue; }
i have tried:
img:focus{ outline: 2px solid blue;
}
but non of them seem work, suppose display blue margin around image when focus. 1 know how that? thank you!!!
you can't "focus" image unless have interactive element or navigate using tab. try adding interactive element on wrapper div so:
html
<a class="imageanchor" href="#"> <img id="image_java" alt="image_not" src="http://www.w3schools.com/images/w3logotest2.png" /> </a>
css
.imageanchor:focus img{ border: 2px solid blue; }
Comments
Post a Comment