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; } 

http://jsfiddle.net/4x7wg7sb/1/


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -