Transcending CSS

Andy Clarke

Mentioned 3

Finally, a progressive guide devoted exclusively to the art of Web design!

More on Amazon.com

Mentioned in questions and answers.

Currently I am designing a website and I am finding it VERY difficult to display the website perfect on ALL browsers.

Is there any rules, suggestions etc to follow?

Thanks

Develop for Firefox. Then apply IE-specific fixes. Hopefully, it'll render OK in Chrome and Safari.

The reason is that there are fixes available to make IE work 'properly' but not many to make Firefox behave badly.

Oh, and buy a copy of Transcending CSS.

For design websites is it better to do it your self by learning HTML/CSS or using web design programs? and why?

I'm not going to read the responses, so its quite possible someone has already said this, but oh well.

First and foremost, you should always write out your HTML / CSS by hand. The reason for this is that no matter how advanced an HTML editor is, it will never be as good as it could / should be. For "good" html / css, you will actually end up writing your page in a different order than what you see.

For example, a page that is displayed like:

________________
|logo          |
|----menu------|
|..............|
|...content....|
|..............|
|....footer....|
----------------

"should" actually flow as follows:

<h1>title of site</h1>
<div id="content">.....</div>
<ul id="menu">....</ul>
<div id="footer">...</div>

which an HTML editor would simply throw a hissy fit if you did it through the nice pretty gui. What may be advantageous is to use Web Expression 2 or Visual Studio for its intellisense. It may help speed up (or maybe slow down) your learning curb.

I really recommend Transcending CSS Design if you are already familiar with HTML / CSS. Otherwise grab a CSS book first even over an HTML book. Styling through CSS will teach you proper semantic HTML (or should,anyway).

I am building a new WebSite based on Grails technology.

Concerning the graphical design of my website, I plan to use services from a professional web designer but meanwhile, I need to do some basics graphical design myself in order to have a "user-friendly" beta-version.

I have read through the stackoverflow.com site but couldn't make up my mind. Here is what I have found out: how-do-you-choose-a-css-framework what-is-the-best-css-grid-framework can-someone-recommend-a-bells-and-whistles-css-framework what-is-the-best-css-framework-and-are-they-worth-the-effort

But unfortunately there are many contradictory answers. First, some say that using CSS framework is backwards authoring and not a good thing. Others advice YUI Grids, BluePrint, 960 gs, YAML...And many say that Compass allows to develop CSS layouts easily and reusable.

So considering that:

  • I am new to the CSS world and I do not intend to be a web designer
  • My layout should be user-friendly (but not necessary awesome L&F)
  • It should be maintanable and easily improvable (by a professionnal web designer)
  • Easy to implement (in order to have something quickly)

What do you advice me for getting started with the web design of my site?

Thank you for your advices.

Fabien

First, if you don't intend to be a web designer, I'd suggest outsourcing your CSS. There are several websites where you can supply HTML or a Photoshop design and have it coded up for well under a grand (1k). Or get HTML/CSS designs free.

Then there is one thing you need to know and another two you need to work out:

  1. all HTML should be written in a semantic and valid manner: semantic = properly ordered headings, lists, no excessive divs etc.; valid = will pass WC3 validation tests. None of this is rocket science, but is still a skill that needs to be learned. Andy Clarke's Transcending CSS is a great book on semantic HTML/CSS. For ease of maintenance, the HTML and CSS should be tidy and consistently indented, etc.

  2. you need to determine whether you'll be needing an admin backend and database for managing content, or if you're just building a site consisting of static pages (i.e. html and css files, images and other media etc.). If it's the former, that's a whole other learning curve :-)

  3. what are your best skills? If you're a good designer, get other people to write the HTML/CSS, or use a ready-made template (there are many on the web) and customise it. Here's a good start for multi-column layouts. If you're a programmer, learn to use a framework like Django (Python), Titanium (Perl), something smaller in Ruby (because Ruby on Rails is a bit big to start with) or one in your favourite language.

Good CSS is a craft, and simplicity is the essence, but if you want to learn enough to get started, my advice would be to:

  1. understand inheritance (the 'cascade' in CSS) and the fact that anything can be a 'block', so don't use lots of nested divs just to apply a style. Instead, apply the style to the HTML element itself, or to the element only when it appears in a parent block (like a menu unordered list contained in a sidebar div);

  2. learn about block and inline elements (Web Design from Scratch is a great learning resource and I'd recommend it), and that CSS can change this behaviour;

  3. test in Firefox, then test in Internet Explorer. >= IE7's not so bad (but look out for HasLayout). What you can't tweak to get right in IE, use conditional comments to add CSS that only IE can see - never use CSS hacks - .htc files that add missing IE functionality (e.g. rollover styles on any element) are available;

  4. learn about CSS positioning, and use 'fixed' sparingly;

  5. put all your CSS in one file (for starters), and don't use inline CSS in the HTML;

  6. styling forms and form fields is almost a separate skill :-)

Use background images to add style, but also understand that you can offset and overlap images using positioning. You'll need to use PNGs for nice transparency, though. Oh yes, and opacity looks nice, but requires non-standard CSS for now. although the more flexible rgba (a=alpha) method is widely-supported. As do rounded corners, but both worth using.

I'd avoid CSS frameworks and resets for now - they'll complicate things at this stage by adding yet another DSL to learn (but read the arguments and the pros and cons). To avoid annoying default margins and padding, I always reset everything by doing html *, body * {margin: 0; padding 0;} then build padding and margins back in wherever needed - never been a problem so far :-)