Android browser - remove outline border when anchor is focused
Asked Answered
C

2

14

I am using on my Android app a webview which loades an external page. It has a few anchors (<a> tags). When I press on it, yellow border appears.

How can I prevent it and remove this border ?

I've tried following tricks:

// jQuery
$("a").focus(function(){
    $(this).attr("hideFocus", "hideFocus");
});

// CSS
a, :focus {
    outline: none;
}

but with no success.

Thanks !

Centimeter answered 13/9, 2011 at 8:18 Comment(2)
Shouldn't a, :focus be a:focus?Virginavirginal
Doesn't :focus match all elements that can be focused, even button etc ?Centimeter
G
47

Set the CSS property -webkit-tap-highlight-color as follows:

* { -webkit-tap-highlight-color: rgba(0,0,0,0); }

Note: setting the color in other ways usually fails because of the way webkit renders the highlight. Depends on version/variant according to my experience.

Galatians answered 13/9, 2011 at 8:22 Comment(1)
-webkit-focus-ring-color: rgba(0,0,0,0); ?Archoplasm
P
1

according to this post it's better to use

a:focus,
button:focus,
input:focus,
textarea:focus {
    outline: none;
}
Pearly answered 12/5, 2019 at 11:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.