CSS and round corners: Making accessible menu tabs

Gauloran

Kıdemli Moderatör
7 Tem 2013
8,123
606
local
Introduction

[FONT=&quot]One of the best websites out there, in terms of functionality, is, and always has been, Amazon. In terms of accessibility though, they're not too good.[/FONT]
The problem

[FONT=&quot]Amazon's menu tabs, for example, look really nice but are totally inaccessible. First of all, they're missing ALT tags. Additionally, the W3Cs accessibility guideline 3.1 (priority 2) clearly states:[/FONT]
When an appropriate markup language exists, use markup rather than images to convey information
[FONT=&quot]This basically means don't use images to display text - site users with poor vision are unable to resize text that's displayed through images. Find out how to resize text in your browser, if you don't already know.[/FONT]
The solution

[FONT=&quot]CSS, as usual, comes to our rescue. Adjust the text size in your browser now. Go on, do it. Did you see how the menu tabs at the top of the screen increased in size with the text and it all fits perfectly. Today, you're going to learn how to do this.[/FONT]
[FONT=&quot]We start with a simple link:[/FONT]

Kod:
<a href="#">Home</a>
[FONT=&quot]We'll assign it this CSS code:[/FONT]

Kod:
a { color: #000; background: #fb0; text-decoration: none }
[FONT=&quot]Which gives us:[/FONT]
[FONT=&quot]
home1.gif
[/FONT]
[FONT=&quot]Needs a bit of work, right?[/FONT]
Adding the left corner

[FONT=&quot]We need to make a small image with the same colour:
tab-orange-left2.gif
- here's one I made earlier. Let's call this image "left-tab.gif" and place it into the background of this link:
[/FONT]

Kod:
a{    color: #000;    background: #fb0 url("left-tab.gif") left top no-repeat;    text-decoration: none  }
[FONT=&quot]This new command says that the background image should be "left-tab.gif", the image should be on the left, at the top, and it shouldn't be repeated - kind of obvious really. The result?[/FONT]
[FONT=&quot]
home2.gif
[/FONT]
[FONT=&quot]We're getting there, but we need to move that text over a bit. It's pretty simple to do with a bit of padding:[/FONT]

Kod:
a {     color: #000;     background: #fb0 url("left-tab.gif") left top no-repeat;     text-decoration: none;     padding-left: 10px  }
[FONT=&quot]
home3.gif
[/FONT]
And the right corner

[FONT=&quot]We can only assign one background image to a tag so we need to make a new tag and assign an image to that. We can use:[/FONT]

Kod:
<a href="#"><span>Home</span></a>
[FONT=&quot]Now we just assign this background image
tab-orange-right2.gif
(another one I made earlier) to the <span> and we're ready to go! We'll call this image "right-tab.gif"
[/FONT]

Kod:
a span {    background: url("right-tab.gif") right top no-repeat; }
[FONT=&quot]This code means that every <span> tag within an <a> tag will have this image as its background. And the final result:[/FONT]
[FONT=&quot]
home4.gif
[/FONT]
[FONT=&quot]Perfect! So now you can... wait a minute, can you spot why it's not so perfect? That's right, we forgot to assign some padding to that <span> tag:[/FONT]


Kod:
a span {    background: url("right-tab.gif") right top no-repeat;    padding-right: 10px }
[FONT=&quot]Giving us:[/FONT]
[FONT=&quot]
home5.gif
[/FONT]
[FONT=&quot]Now that really is perfect! Resize the text again and see how it looks![/FONT]​
 
Son düzenleme:
Üst

Turkhackteam.org internet sitesi 5651 sayılı kanun’un 2. maddesinin 1. fıkrasının m) bendi ile aynı kanunun 5. maddesi kapsamında "Yer Sağlayıcı" konumundadır. İçerikler ön onay olmaksızın tamamen kullanıcılar tarafından oluşturulmaktadır. Turkhackteam.org; Yer sağlayıcı olarak, kullanıcılar tarafından oluşturulan içeriği ya da hukuka aykırı paylaşımı kontrol etmekle ya da araştırmakla yükümlü değildir. Türkhackteam saldırı timleri Türk sitelerine hiçbir zararlı faaliyette bulunmaz. Türkhackteam üyelerinin yaptığı bireysel hack faaliyetlerinden Türkhackteam sorumlu değildir. Sitelerinize Türkhackteam ismi kullanılarak hack faaliyetinde bulunulursa, site-sunucu erişim loglarından bu faaliyeti gerçekleştiren ip adresini tespit edip diğer kanıtlarla birlikte savcılığa suç duyurusunda bulununuz.