Showing posts with label html. Show all posts
Showing posts with label html. Show all posts

October 17, 2010

Accessibility Is The Path To Awesomeness

Accessibility in the context of a Web site is the degree to which that Web site is usable by people with disabilities. Web pages often have access issues for the following groups of people:

That's one definition of accessibility in an online context. A simpler definition might be: A web site that everyone can use. That's a touch simplistic and idealistic, but it gets closer to what accessibility truly is.

There are a lot of resources out there devoted to helping web designers make their sites more accessible. The University of Minnesota, for example, has a long list of resources and tools related to accessibility. It's pretty overwhelming. About.com also has several articles about accessibility.

There's a simpler method, though, and while it's not 100% foolproof, it will get you fairly close to an accessible website. It is this: Use common sense and well-formed HTML code.

"But," you protest, "what about access keys, and alt text, and all those other things they talk about?" Remember what I said about well-formed HTML code. Images are required to have alt attributes in order for a page to validate. (Pages will still validate with blank alt attributes, though. That's where using common sense comes in: does the page still make sense without the image and without any alt text?)

Access keys (alt+[key]) are slightly different, as they are not required in valid HTML code. It also doesn't always make sense to use them. Using too many on a page can be overwhelming for a user. You also have to be careful not to use keystroke combinations that are already used for browser menus or other similar functions.

The WAVE report for the main page of Wikipedia reveals the access keys that are in use there. By my count, there are 14 different access keys, which make varying degrees of sense. Alt-F might make sense if the search field were labeled "Find articles", but it is not. Alt-U for "Upload file" does make sense, but Alt-K for "Related changes"? Another problem with using Alt-F to get to the search field is that that combination is used in nearly every Windows program to access the File menu. Firefox gets around this by adding Shift to the access key combination (Alt-Shift-F), but Safari overrides the default (Alt-F always brings up the search field).

Wikipedia does do something right, though. If you disable styles on the page, the navigation drops down to the bottom of the page. This makes it easier for people with text-only browsers or screen readers to get to the content.

Another important aspect is the color scheme. If you're planning on designing a Christmas website with red text on a green background, remember that about 5-7% of people suffer from red-green color blindness, or protanopia/deuteranopia, which would make it extremely difficult or even impossible for them to even see that there's text there. Tritanopia is another type of color blindness that affects a person's ability to see blue. One of my friends in college suffered from monochromacy and could only see shades of gray. When choosing colors, you might try using a graphics editor to convert them to grayscale and see if there is enough contrast there even without any "real" coloration.

Finally, organizing content in a way that makes sense is probably the most important step towards accessibility. Remember, you're not designing just for someone with a disability. You're designing for everyone.

September 26, 2010

Beauty In Type

@font-face {
font-family: "FontinSansRegular";
src: url('fonts/fontinsans.eot');
src: local('?'), url('fonts/fontinsans.woff') format('woff'), url('fonts/fontinsans.ttf') format('truetype'), url('fonts/fontinsans.svg#webfontn8vXGJ0x') format('svg');
font-weight: normal;
font-style: normal;
}
Do you know what this is?

It's the future.

Okay, maybe it's not quite that dramatic. However, it does represent a huge step forward in web design. It's a web font declaration in CSS.

Let's go back to the dark ages, when Internet Explorer and Netscape Navigator ruled the Internet. In those days, text online was rendered in whatever fonts you had on your system. Running Windows 95? You got Arial and Times New Roman. Running a Macintosh? Default fonts were Chicago and New York.

Then came CSS, Internet Explorer 3, and the core fonts for the Web project.

The core fonts project aimed to provide a set of fonts that would be widely downloaded and used, which was supposed to ensure that websites looked the same across platforms. The downside to this was that the fonts had to be present on the user's system, not just on the web server. Granted, due to Windows' near-complete domination of the computer market, the vast majority of people probably did have the fonts installed. With the new (partial) CSS implementation in IE 3, you could specify typefaces. Yes, that's a choir of angels you hear singing "Hallelujah".

It still wasn't perfect, not by a long shot. You were still limited to whatever fonts your users had on their systems. You could be reasonably sure, however, that the fonts included in the core package were going to be present for the vast majority of your users. I mean, I could design a page using Footlight MT Light, but it might fall back to Times New Roman on your system.

With the introduction of the @font-face declaration in CSS 2, you could finally reference fonts that weren't stored on the user's computer! In the example above, I'm telling the browser to grab the Fontin Sans file, which is stored in the subfolder fonts. On my server. Not your computer. As long as you're using a browser that's at least as new as Internet Explorer 4, you'll see Fontin Sans on this webpage.

"Wait!" you say. "It displayed your fancy-schmancy new font after a minute, but when it first loaded, [it was in Times New Roman/I couldn't see any of the text]! What gives?"

Yeah, that's the problem with using @font-face. Pingdom says that fontinsans.ttf is one of the last things to load, and it takes a comparatively long time to load on top of that. Until it loads, the page is in limbo. Different browsers handle this limbo time in different ways. Firefox and Opera temporarily fall back to the next font in the font stack. Safari completely hides the text (though not the underline on hyperlinks, interestingly enough; if you load that page in Safari, you can see random lines going across the screen). Internet Explorer, for me at least, takes so long to load the entire page that it renders in Fontin Sans when it finally displays.

When the page is finished loading, though, the typeface is so beautiful that it makes Michelangelo weep.

(Again, maybe not quite that dramatic.)

Want to learn more?

September 13, 2010

I Have A Canvas And A JavaScript Paintbrush

One of the biggest problems of the Internet today is an over-reliance on proprietary plugins. Mac users will be especially familiar with the feelings of abject rage as a Flash game bogs down their system, takes over a chunk of memory, and causes the fans in their laptop to whir consistently, due to the lack of hardware acceleration in the Mac version of Flash Player (which was only recently remedied). There's Flash, Silverlight, Java, and whatever proprietary single-use plugin TV networks' websites make you install to watch their shows.

"So what?" you say. "I just install the plugins when I need them. No big deal." Yeah...except each one requires a download, an installation, and a browser restart. It's a hassle. (And we won't get into cross-platform issues.)

Better than that, each plugin introduces its own set of security holes. Flash is notorious for this, but it is not alone in that regard.

Plugins used to be the only way to provide interactivity to a website. Something better is looming on the horizon, though: HTML5, and with it, <canvas>, <video>, and <audio>.

The video and audio tags are fairly self-explanatory. As long as the browser properly implements them, they provide plugin-free playback for videos and sound, respectively. Canvas is an HTML tag that essentially gives you a blank area that you draw on using JavaScript. The code required is fairly similar to creating graphics in a Java applet, for those of you who are familiar with that.

Java Applet Code:
g.setColor(new Color(0x5E, 0x2F, 0x00));
g.fillRect(0, 180, 200, 50);

JavaScript Canvas Code:
ctx.fillStyle = "#5E2F00";
ctx.fillRect(0, 180, 200, 50);

Canvas/JavaScript provides no easy way, however, to draw ovals or rounded shapes. Compare the two methods for drawing a rectangle with rounded corners:

Java Applet Code:
g.setColor(Color.white);
g.fillRoundRect(45, 35, 50, 35, 10, 10);
g.setColor(Color.black);
g.drawRoundRect(45, 35, 50, 35, 10, 10);

JavaScript Canvas Code:
ctx.fillStyle = "#FFFFFF";
ctx.strokeStyle = "#000000";
ctx.beginPath();
ctx.moveTo(45, 45);
ctx.quadraticCurveTo(45, 35, 55, 35);
ctx.lineTo(85, 35);
ctx.quadraticCurveTo(95, 35, 95, 45);
ctx.lineTo(95, 60);
ctx.quadraticCurveTo(95, 70, 85, 70);
ctx.lineTo(55, 70);
ctx.quadraticCurveTo(45, 70, 45, 60);
ctx.lineTo(45, 45);
ctx.fill();
ctx.stroke();
ctx.closePath();

Even with that convoluted code, I still saved approximately 60 lines of code generating this image in JavaScript with canvas than it took to do the same thing in a Java applet. Most of this savings probably came from the fact that JavaScript has both a fillStyle and a strokeStyle, while Java uses setColor() for everything, necessitating more color changes. Plus, the user doesn't have to install a plugin to make it work, it renders pretty much instantaneously in the browser window, and you could copy the generated image and save it if you wanted to, which would be useful if you wanted to code a drawing web app of some sort.

Want to learn more about drawing with <canvas>?

September 05, 2010

The Standards Are There, So Use Them

Imagine a scenario.

Kate has just been hired by Widgets Ltd., a start-up company that is being run in a garage outside Madison, Wisconsin, to create a website for their products. She has no web design experience outside of Comp Sci 101, back in the bad old days of freshman year. "No problem," she thinks to herself. "I've got an old copy of Microsoft FrontPage here. I'll just draw some tables and drop the content in. Easiest money I ever made."

Of course, we, as web developers ourselves, can imagine the hideous code that will result from this misguided approach:
<html><head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Welcome to Widgets, Ltd.!</title>
</head>

<body bgcolor="#00FFFF" link="#00FFFF" vlink="#00FFFF">
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1" height="59">
So much for separating organizational and display functions. Kate's work failed to adhere to (or even consider, for that matter) web standards. Without boring you with the details, the above code snippet contains four errors when run through the W3C HTML Validator — and we haven't even made it to any of the actual content yet.

What are web standards, you may be asking? They are a set of guidelines codified by the World Wide Web Consortium (and Ecma International, which standardizes ECMAScript/JavaScript). They define the elements, the syntax, the attributes, the doctypes, everything. Browser developers then take these standards and program their browsers to properly render web pages based on these standards. Opera generally leads the pack as far as standards compliance, with Firefox and Safari following and Internet Explorer trailing in a distant fourth.

Now, designing with web standards does not mean making your website look exactly the same across all browsers. Someone looking at it in Firefox on Windows XP is going to get a slightly different look than someone looking at it in Safari on Snow Leopard. Is that wrong? Is that bad? Not at all. Very few people will even notice without you pointing it out to them. They're different, not wrong — if you coded the site correctly, that is.

So, in summary, my argument for designing to web standards is this. Internet Explorer 6 (and prior versions) didn't care about abiding by web standards, and complications stemming from that caused much wailing and gnashing of teeth. Why would you want your website to even have a possibility of inspiring a response like that? Design to the standards. It will cause many fewer problems.

*The problems described herein are not unique to Microsoft products by any means. However, every time I bash Microsoft, Canonical and Red Hat send me a tenth of a penny. I look forward to being able to afford a gumball.

October 14, 2009

Web Analytics and SEO

I've written a paper on the use of web analytics and search engine optimization. It's available on Google Docs. If you haven't been given access, and you wish to read it, comment on this post with your email address and I'll see about setting up view permissions. Don't worry, I will not display your email address or send it to those nice folks in Nigeria. :-)

Quote of the Day:
Castle: We make a pretty good team, you know. Like Starsky and Hutch, Tango and Cash, Turner and Hooch...
Beckett: You know, now that you mention it, you do remind me a little of Hooch.
--Castle

September 06, 2009

Cascading Style Sheets: An Introduction

Last week, I mentioned CSS -- cascading style sheets. CSS is an important tool for any web designer.

What does CSS do? It takes the place of clunky formatting attributes (and tags, in some cases) in (X)HTML.

Wouldn't it be easier to just keep the formatting in the HTML code? Not really, for multiple reasons. First, many old "staples" of HTML formatting are being deprecated. W3 Schools is an excellent resource for finding out which tags have been deprecated. Second, imagine that you have a website with 10 distinct pages and 5 different hyperlinks on each page. You want to make all hyperlinks bold and bright orange. Which would take less time: typing <b><font color="orange"><a href="link.html"> fifty times, or putting a { font-weight: bold; color: #FFA500 } in a separate CSS file and implementing it in each page?

Still not convinced? What happens if you want to change the formatting to italic fuchsia? If you use CSS, you only have to change the CSS in one place. With pure HTML, you would have to change the code fifty times.

Okay. So how do I use CSS? CSS is a collection of rules. A rule consists of two parts: the selector and the declaration. The selector identifies what elements are affected by the rule. The declaration tells the browser what formatting to apply to that element. W3 Schools comes to the rescue again, with an excellent CSS tutorial. Once you have created your CSS rules, save that file with a .css extension in the same folder as your HTML files. Then, in the head section of each page you want to apply the formatting to, use a link tag to call the stylesheet: <link rel="stylesheet" type="text/css" href="mystyle.css">

I only want to implement a particular CSS rule on one page. Is there any way to do that? Yes. Place the CSS code in a style tag inside the head section:
<style type="text/css">
h1 { color: blue; }
</style>

Obviously, there is much more to CSS than that, but that is the basics. The best way to learn it is to use it, so have fun experimenting!

Quote of the Week:
"Live today. Not yesterday. Not tomorrow. Just today. Inhabit your moments. Don't rent them out to tomorrow." --Betty Lou, Love, Stargirl

August 30, 2009

A Mishmosh

Some interesting things I've learned recently:
  1. The tracert command traces the path from one computer to another to a maximum of 30 hops. When your Internet connection is down, the output consists of 30 lines of "* * * Request timed out."
  2. Apple is run by an evil genius. If I weren't so disciplined, I could waste hours of my life on my iPod, getting stuff on the App Store, and reading Kindle books. Wait, that's what I did yesterday...
  3. HTML may do a lot more now than it used to, but trying to figure out which tags are supported, which are deprecated in favor of other tags, and which are deprecated in favor of CSS is a touch annoying. For example, it's apparently okay to use bold and italic tags, but not strikethrough or underline.
  4. If you have a URL, and you want to get its associated IP address, use NSLOOKUP. For Windows users, type nslookup www.website.com in the Command Prompt. When I typed in www.google.com, for example, I got 6 different IP addresses, all in the 74.125.159.* range. What I liked, though, was that the results were preceded by the words "Non-authoritative answer".
Quote of the Week:
"Nothing is more deceitful than the appearance of humility. It is often only carelessness of opinion, and sometimes an indirect boast." --Mr. Darcy, Pride and Prejudice