Results tagged “CSS” from Interface_

Poor Interface_ Blog. We’ve been so busy here in Web Com that we’ve neglected you. It’s been a long time since someone posted anything. I wouldn’t be surprised if everyone deleted us from their feed readers!

To make up for it I’m going to work on being a better blog author by offering up some quick CSS tricks I use on almost every site I build.

skip-to-link.jpgFirst up is styling “skip-to” anchor links. These handy links help people using assistive software or hardware, or mobile devices. They allow quick access to the navigation, main content or any other important element on the page without having to “tab” through all the page’s links. Try hitting the tab key (option+tab in Safari) and go through a page’s links to get to the main content. It takes a while doesn’t it? You can see an example of this working on or Parent Relations site.

These links should be the first thing in your mark-up so the users who need them can find them. This is great for accessibility, but they can sometimes get in the way of your page design. Luckily, there’s a way to hide them while still keeping them accessible.

The XHTML

Start by placing this code right after the open <body> tag.

 <div class="offset">
      <a href="#skip">Skip to main content</a>
      <a href="#nav">Skip to navigation</a>
 </div>

Be sure to include the #skip #content anchors somewhere on your page so the links have somewhere to go.

The CSS

 .offset a { 
      position:absolute; 
      left:-1000em; 
      padding:5px; 
      font-weight:bold; 
      background-color:#fc3; 
 }
 .offset a:focus, .offset a:active { 
      position:absolute; 
      top:2em; 
      left:2em; 
 }

What this does is take our “skip-to” links and indents them off the screen to the left. When the link is in focus or active, from “tabbing,” the indention is removed and the link becomes visible.

Why not just use display:none?

Screen readers will not read items with the display:none rule, so we need to use position:absolute and indent the links to hide them.

You try it

The best part about this little CSS trick is that it’s really easy to apply and it won’t affect your existing site design, so there’s no reason not to add this bit of functionality.

CSS frameworks

|

Since Paul wrote some posts on JavaScript frameworks before (part 1, part 2), I thought I’d mention something about CSS frameworks. I’ve begun using them on several projects and have found them to be a huge help. I find that laying out the page is easier, the most common styles are already set and browser bugs are few and far between.

What the heck is a CSS framework?

It’s pretty much a library of pre-built styles that help with designing a Web site. The goal of using a CSS framework is the same as other programming frameworks — to speed up development and ease collaboration between developers. A List Apart wrote a good article on the subject.

Usually, when beginning to style an XHTML page, I’d start with a few basic styles to override some of the browser’s defaults. Then I’d throw in a few other styles for hidden “skip-to” links and basic typography style. This would save me a load of time and without realizing it, I was using a CSS framework!

Other designers used similar methods and one of the first to become widely adopted was Eric Meyer’s “reset styles.” It was a set of styles that would override a browser’s default styles and give the designer a blank canvas eliminating a lot of browser testing.

CSS frameworks have taken this one step further and have included styles for typography, forms, browser bugs and layout grid systems. The methods in which styles are applied have structure so one designer doesn’t have to decipher another’s naming conventions.

Find recent content on the main index or look in the archives to find all content.

Follow us on Twitter