Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Giving navigation links proper focus with style

From: Improving SEO Using Accessibility Techniques

Video: Giving navigation links proper focus with style

You can add what's called pseudo-classes to active elements on your site to make them more interactive. The most common pseudo-classes are found when interacting with links. The hover class is probably the most common among them, and it's one that's activated every time you hover your mouse over a link. One pseudo-class that doesn't get the attention it deserves is the focus class. Focus can be given to an item with a keyboard or another interaction device and should be treated with the same level of importance as the other pseudo-classes. This is especially true if you're creating menus.

Giving navigation links proper focus with style

You can add what's called pseudo-classes to active elements on your site to make them more interactive. The most common pseudo-classes are found when interacting with links. The hover class is probably the most common among them, and it's one that's activated every time you hover your mouse over a link. One pseudo-class that doesn't get the attention it deserves is the focus class. Focus can be given to an item with a keyboard or another interaction device and should be treated with the same level of importance as the other pseudo-classes. This is especially true if you're creating menus.

Always assume people will try to navigate your menu using the tab button. If you don't have a focus pseudo-class defined in your style sheet, they won't know what menu item they are actually on. This brings me to an important point. When we're talking about accessibility, we are not just talking about people who can't see what's on your site, like people with severe vision problems who are blind, or search engines. We are also talking about people who can't access your site through other means, for instance, a person who can't use a mouse, or someone who isn't blind but is really hard of seeing.

For them, we need to add visual cues when they use things like a keyboard to interact with your site, and this is where the focus class kicks in. You'll remember that if we navigate around the site, you will see every time you hover over link, first of all you see the hand pointing icon, and secondly, under for instance, the main menus, you will see that the Main Menu items change appearance when you hover over them. This is the hover pseudo-class. The problem is, when I navigate this site using the Tab button on my keyboard, I navigate through links.

But I don't know where my tab button is, I don't know want item has focus, and I can't see what's going to happen. If you look down at the bottom left corner of my browser window, you'll see that those links appear, but this isn't good enough. I want to visually display where the focus is currently at. For that I am going to add one simple style in my style sheet. So I will go to my Accessible site and open styles in the Notepad. From here, I will scroll down to my Global styles and find where I have all my, a pseudo-classes.

So here I have the anchor class, which is just a link, and then I have the active and hover pseudo-classes. Here I want to add another new pseudo-class. I'll call it a: focus. This is how you mark up pseudo-classes, and whatever style I put in here will be applied every time an anchor gets focused through a keyboard or other device. Now I can apply a style that will be triggered every time someone interacts with the link using a keyboard or another input device.

What I want to happen is there should be a blue box around the link itself. But I don't want that blue box to hamper with the rest of the content. For that I am going to use the attribute outline. Unlike border, which interacts with the rest of the content, outline will literally outline whatever is inside the CSS box you're dealing with. So I will set that color of the outline to 3389a9, which is a blue, and I will set it to a solid, so that is a solid outline, and I'll give it a width of 2 pixels.

When I save this small change and reload my page, scroll to the top, and use the tab button, you'll see where focus is. Now focus is on the header, now focus is on the Home button, now it's on the Flower button, and so on. And as I tab through the page, my new focus pseudo-class highlights the content I'm going to click if I hit Return. So by adding that simple class, I've now added a focus element to all the links on my entire page.

Of course, you can get more specific, and add different styles to different elements so that they appear differently when you use the focus class. But in general, if you just create a: focus and make that a class, then you can style all the elements on the page that are interacted with the keyboard. Accommodating non standard modes of accessing elements on your site is becoming more and more important because many of these non standard methods are becoming standard. Earlier in the course, I spoke of a time in the very close future, where people will surf the web using text-to -speech browsers on their phone while jogging or driving their car.

Likewise, I can see a time in the future, where people use gestures or hand emotions to select elements on a page. This may very well be focus states, so you need to add them to kind of work for what's going to happen possibly in the future.

Show transcript

This video is part of

Image for Improving SEO Using Accessibility Techniques
Improving SEO Using Accessibility Techniques

30 video lessons · 11060 viewers

Morten Rand-Hendriksen
Author

 
Expand all | Collapse all
  1. 3m 3s
    1. Welcome
      1m 4s
    2. Using the exercise files
      1m 59s
  2. 8m 16s
    1. Accessibility and SEO: A primer
      4m 58s
    2. Understanding the benefits of accessibility and SEO
      3m 18s
  3. 11m 26s
    1. Experiencing an inaccessible web site
      6m 4s
    2. Experiencing an accessible web site
      5m 22s
  4. 16m 28s
    1. Evaluating screen readers for Windows and Mac
      5m 56s
    2. Installing browser development tools
      4m 8s
    3. Pretending to be a screen reader
      6m 24s
  5. 7m 40s
    1. Installing SEO tools
      2m 30s
    2. Understanding how search engines search a page
      2m 45s
    3. Comparing sites that are SEO-friendly with ones that are SEO-unfriendly
      2m 25s
  6. 44m 6s
    1. Defining a language for a page
      5m 4s
    2. Defining meta headers for a page
      6m 10s
    3. Creating better semantic markup with HTML5
      3m 13s
    4. Using and hiding section headings
      4m 56s
    5. Creating content hierarchies with heading tags
      5m 29s
    6. Emphasizing content in paragraphs
      5m 36s
    7. Making accessible block quotes
      3m 22s
    8. Using some new HTML5 tags
      4m 47s
    9. Using ordered and unordered lists
      5m 29s
  7. 22m 17s
    1. Marking up links properly
      6m 48s
    2. Marking up images
      7m 23s
    3. Creating a proper image header with CSS
      8m 6s
  8. 32m 43s
    1. Creating an accessible menu with an unordered list
      6m 16s
    2. Creating and hiding nav headings and skip navigation links
      6m 59s
    3. Giving navigation links proper focus with style
      4m 39s
    4. Creating an accessible drop-down menu
      10m 46s
    5. Scrapping drop-down menus for better options
      4m 3s
  9. 3m 44s
    1. Next steps
      3m 44s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now "Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Improving SEO Using Accessibility Techniques.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.