Jeremy Stein - Brain

« »

CSS Advice

  1. Avoid fixed-position alignment. It’s going to look bad on someone’s browser. They might have large fonts or a small browser, etc.
  2. Consider using “em”-scaled sizes rather than “px”-scaled. A “width: 50em” will grow with the font where “width: 400px” won’t. That’s particularly nice for the elderly who might bump up the font size on their browser.
  3. Before using a div or span, try to find an existing tag that matches what you’re trying to express. You can still give it a class or id if it needs special formatting. I mostly suggest this as a purist, but I suppose it would be helpful for screen readers or for old browsers that can’t handle CSS.
  4. IE is evil. Test in IE. It incorrectly implements the box model and widths don’t always work the way they should.
  5. When you can’t get it to work in CSS, just use a table. Yeah, yeah, I know — that’s not the pure way. Just blame it on buggy browsers. It’s just one table — for major layout issues. And you can set all the table/row/cell attributes through CSS. Sometimes it is simply *not* possible to get things lined up the way you want with CSS. Browsers have implemented tables very well for years. They grow with text, things don’t leak out, and they’re good and dealing with fuzzy rules. Try CSS first, but don’t kill yourself with CSS if a table will solve your problem.

April 19, 2006 No Comments.

No Comments

Be the first to comment!

Leave a Reply

Your email address will not be published. Required fields are marked *

Why ask?

« »