This last chapter is pretty much a grab bag of bits of advice and tricks you can use. There's not much more that I can tell you about website coding, so here are some tips about website design.
There is no real right
way to design a website, no one ultimate configuration of placing and color. I can, however, offer some tips to nudge you in the right direction.
There are a few basic things to remember:
Consistency doesn't make you look boring, it makes you look competent. It also helps you create webpages faster by allowing you to create:
Furthermore, it makes your webpage easier to figure out.
There are few design mistakes worse than contrast, which is how much your text stands out against the background. A good rule of thumb is if you must highlight text to read it, you need to adjust your contrast. Beware of colorful pictures; too many conflicting colors will make your text hard to read as well.
In the examples, I have a page called A Terrible Webpage
(there is also a text-only version of it). It has no errors in JavaScript, CSS, or HTML—but the page itself is horrid. The problems, paragraph by paragraph:
Lastly, the h2
elements have moving borders and text, making them distracting even without their garish colors, while the hr
elements have animated backgrounds of their own.
In short, there's loads of features that a) take up quite a bit of bandwidth, b) make the page difficult to read, c) bog down your computer (you may notice that the moving content constantly changes speed), and d) generally make the page suck.
Properly coding your structure, styling, and behavior is important, but that alone does not make a good webpage—nor does shoddy coding prevent a webpage from looking good. The trick is to start with an idea for a good design, then use good coding to bring it into being.
Below are a bunch of websites you should visit:
URI: http://www.alistapart.com
This webpage contains a lot of advanced website coding tricks.
URI: http://www.csszengarden.com
This webpage shows what kind of sites can be made with CSS.
URI: http://www.webdeveloper.com/forum/
This is where I learned most of my coding habits. It's also where the seed of this book was planted.
URI: http://www.webpagesthatsuck.com/
This webpage shows what to avoid by exposing websites that have particularly bad design.
This is where I got most of my JavaScript information.
URI: http://www.w3.org
This is where I got most of my (X)HTML and CSS information, and there's a lot more you can use there too.
One thing I didn't really cover were some design tricks, so I'll cover them here.
One common practice is to have the navigation menu on one side of the page or the other, creating a two- or three-colum page. It makes for a fairly simple, elegant, and easy-to-use page layout.
One common way to to do so is to use absolute positioning for the menu.
In the case we're going to use, we:
Fairly straightforward. But it also means that the content of the page that is not positioned absolutely will overlap the menu. This is solved by one simple rule:
120 pixels of padding on the left hand side pushes the rest of the content over, while leaving any absolutely-positioned elements where they are.
The results are nice and neat, and the CSS is very simple and straightforward.
If you wanted #Menu on the right side, you'd just change the absolute position of #Menu and adjust the padding. You could even have padding on both sides if you wanted a menu on either side.
In the meantime, you should see the coding trickery I used in creating the Horrors page. Your eyes do not deceive you; the crappy page takes far more coding than the simple page, and some of the worst features (changing colors and moving text) were created with JavaScript trickery.
With that final bit, I think it's time for me to let you go and learn more about website designing on your own. Happy coding.