16

I want to remove the outline on an active jQuery UI tab (or at least change the color).

Working from this example, I tried this unsuccessfully:

<style>
    #tabs .ui-state-focus
    {
        outline: none;
    }
</style>

(based on a tip from this question and answer).

What's the trick to removing the outline from an active tab?

Community
  • 1
  • 1
jedierikb
  • 12,752
  • 22
  • 95
  • 166

9 Answers9

25

I don't believe it's the class focus that you need to target, it's the CSS psuedo-class :focus

.ui-state-focus:focus { outline:1px dotted red !important }

if that works, go with {outline:none} to remove it. You are sort of jacking up your accessibility by worrying about it though, FYI.

Dawson
  • 7,567
  • 1
  • 26
  • 25
  • Yes it does... click inside the Result window, and hit (you should see a red dotted line around the first tab element). Maybe we're chasing different issues? – Dawson Jan 04 '13 at 15:46
  • 1
    Ah, cool, I see that now. But in mac-chrome, clicking a tab puts a blue border around the same tab. I am trying to change that. – jedierikb Jan 04 '13 at 15:48
  • 3
    It has something to do with how fine-grained your selector is. Using `*:focus { outline:none }` works, but so does `#tabs ul li a:focus { outline:none; /* outline-color:red */; }` - paste that CSS into your fiddle, you'll see. Mac Lion & Chrome tested – Dawson Jan 04 '13 at 17:24
  • To prove my statement above replace your class-based '.ui....' selector in the fiddle you passed me with `#tabs ul li a:focus, #tabs ul li:focus`. Don't change the CSS. Now, on `click/active`, and `` what once was fuzzy light blue will be dotted red line. – Dawson Jan 04 '13 at 17:45
24

There are lots of ways to do this. Here are two examples (I suggest option 2):

Option 1

Remove the outline from all elements that use the .ui-widget class:

.ui-widget * { outline: none; }​

Here's a working fiddle.

Option 2

Make the outline color transparent:

#tabs li a
{
    outline-color: none;
}​

Here's a working fiddle.

James Hill
  • 60,353
  • 20
  • 145
  • 161
  • 2
    On a Mac, `outline-color:transparent` actually changes the color from the default blue to a graphite color. (OS X Lion + Chrome) – Dawson Jan 04 '13 at 17:26
  • @Dawson, agreed. Simply replace with `outline: none;` – Matt Dec 12 '13 at 16:05
  • 1
    This worked for me where the accepted answer did not for some reason. Thank you! – deebs Mar 16 '15 at 18:14
15

I managed to remove it with

.ui-tabs-anchor:active, .ui-tabs-anchor:focus{
     outline:none;
}
DJ22T
  • 1,628
  • 3
  • 34
  • 66
4

if you want to remove the outline only on a specific tabs then I suggest you use the following:

$("#tabs ul li").css({'outline': 'none'}); // where #tabs can be any specific tab group

inside the script tag of your html.

collapsar
  • 17,010
  • 4
  • 35
  • 61
Gabriel N.
  • 51
  • 2
  • 1
    congrats to your first answer! make sure to have a look at the [markdown (message formatting syntax) help page](http://stackoverflow.com/editing-help). – collapsar May 17 '13 at 07:20
3

You can disable the outline by specifying outline-width: 0;

#tabs li a
{
    outline-width: 0;
}​

A more generic solution without using IDs would be:

.ui-tabs ul li a
{
    outline-width: 0;
}​

Demo: http://jsfiddle.net/ebCpQ/

techfoobar
  • 65,616
  • 14
  • 114
  • 135
  • This requires I know the div id ahead of time. I am dynamically creating tabbed panels (with auto-generated ida), so I believe I would have to dynamically insert css to use this solution? – jedierikb Jan 03 '13 at 19:51
3

I had to do this to prevent possible initial tab order focus too:

.ui-state-active a, .ui-state-hover a, .ui-state-visited a, .ui-state-focus a, .ui-state-focus:focus {
    outline:none;
}
Ryan
  • 491
  • 4
  • 16
1

you can try this

a:focus { outline: none; } 
Arsalan
  • 128
  • 1
  • 8
0

To make it more clear, the outline appears on the element inside of the ul.ui-tabs li.ui-tabs-nav. Most of above examples forgot to mention this: so here is a working answer for the original question:

.ui-tabs-nav .ui-state-focus a {
    outline: none;
}     

http://jsfiddle.net/xJ9Zr/5/

Frankey
  • 3,679
  • 28
  • 25
0

Oddly enough, none of this worked for me. I had to add a border to get the outline (or maybe it was a blue border) to go away:

.ui-state-hover, .ui-state-focus, .ui-state-active
{
    border: 1px solid #ccc !important; /*Or any other color*/
    border-bottom: 0 !important;
} 
deebs
  • 1,390
  • 10
  • 23