1 | <!doctype html> |
---|
2 | <html lang="en"> |
---|
3 | <head> |
---|
4 | <meta charset="utf-8"> |
---|
5 | <link rel="stylesheet" href="css/common.css" type="text/css"> |
---|
6 | <title>Tooltips and title attribute</title> |
---|
7 | <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> |
---|
8 | <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css"> |
---|
9 | <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> |
---|
10 | <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> |
---|
11 | <script type="text/javascript"> |
---|
12 | $(document).ready(function(){ |
---|
13 | $('[data-toggle="tooltip"]').tooltip({ |
---|
14 | placement : 'top' |
---|
15 | }); |
---|
16 | }); |
---|
17 | </script> |
---|
18 | <style type="text/css"> |
---|
19 | |
---|
20 | .bs-example{ |
---|
21 | margin: 20px; |
---|
22 | } |
---|
23 | |
---|
24 | .non-compliant-example { |
---|
25 | padding: 20px; |
---|
26 | } |
---|
27 | |
---|
28 | .red-tooltip + .tooltip > .tooltip-inner {background-color: #f00;} |
---|
29 | .red-tooltip + .tooltip.top > .tooltip-arrow {border-top-color: red;} |
---|
30 | |
---|
31 | .white-tooltip + .tooltip > .tooltip-inner {background-color: #FFF; color: #121212; border: 1px solid #121212; } |
---|
32 | .white-tooltip + .tooltip.top > .tooltip-arrow {border-top-color: #121212;} |
---|
33 | |
---|
34 | .white-tooltip.more-padding + .tooltip > .tooltip-inner { |
---|
35 | padding: 10px; |
---|
36 | } |
---|
37 | |
---|
38 | </style> |
---|
39 | </head> |
---|
40 | <body> |
---|
41 | <div class="wrapper" role="main"> |
---|
42 | <h1>Tooltips - The "title" attribute on its own is not a compliant solution</h1> |
---|
43 | <p>It has been common practice on the web to use the HTML "title" attribute for users to find out more infomation about an icon's purpose or details about points on a graph. Unfortunately these tooltips only appear for mouse users on hover, they do not appear on keyboard focus. This means if you intend to have tooltips you should invest in a solution that works for both hover and focus.</p> |
---|
44 | <h2>Examples:</h2> |
---|
45 | <div class="non-compliant-example"> |
---|
46 | This is a non-accessible example using the standard title attribute to make a tooltip - Hover the word - <a href="#" title="inaccessible tooltip">submarine</a>. Hover with your mouse and also try tabbing with your keyboard to it.</div> |
---|
47 | |
---|
48 | <div class="bs-example"> |
---|
49 | <ul class="list-inline"> |
---|
50 | <p style="margin-bottom: 30px;">These examples are accessible as they allow both mouse and keyboard focus.</p> |
---|
51 | <li><a href="#" data-toggle="tooltip" title="A tooltip" class="white-tooltip">White with black text tooltip</a></li> | |
---|
52 | <li><a href="#" data-toggle="tooltip" title="A much longer tooltip to demonstrate the max-width of the Bootstrp tooltip.">Black/white tooltip</a></li> | |
---|
53 | <li><a href="#" data-toggle="tooltip" class="white-tooltip more-padding" title="This one has more padding">More padding tooltip</a></li> | |
---|
54 | |
---|
55 | <li><a href="#" data-toggle="tooltip" title="Red tooltip" class="red-tooltip">Red tooltip</a></li> |
---|
56 | |
---|
57 | |
---|
58 | </ul> |
---|
59 | </div> |
---|
60 | </div> |
---|
61 | </body> |
---|
62 | </html> |
---|