background preloader


Facebook Twitter

Magic Numbers in CSS. Magic numbers in CSS refer to values which "work" under some circumstances but are frail and prone to break when those circumstances change.

Magic Numbers in CSS

They are usually always related to fonts in some way or another. They are created by an author who likely only tested in their own browser under ideal conditions. Let's take a look at some examples so we all know what they are and hopefully can avoid them in the future. Look at this simple set of tabs: Each of the tabs is set to width: 100px;. A bit awkward and likely undesirable. FIXED! font-face rendering incorrectly in Chrome. For a while now web designers have been tackling the issue of fonts on the web.

FIXED! font-face rendering incorrectly in Chrome

Times have now changed from the days of designing strictly in web-safe fonts (Arial, Tahoma, Georgia etc.) to using JavaScript (Cufon) to render more fancy fonts. With a huge wealth of fonts (both paid and free) now readily available online to designers, rendering fonts online has become more of an issue. The @Font-Face Rule And Useful Web Font Tricks. Advertisement The possibility of embedding any font you like into websites via @font-face is an additional stylistic device which promises to abolish the monotony of the usual system fonts.

The @Font-Face Rule And Useful Web Font Tricks

It surely would be all too easy if there was only one Web font format out there. Instead, there’s quite a variety, as you will get to know in this article.


An Introduction To LESS, And Comparison To Sass - Smashing Magazine. Advertisement I’ve been using LESS1 religiously ever since I stumbled upon it months ago.

An Introduction To LESS, And Comparison To Sass - Smashing Magazine

CSS was never really a problem for me, in and of itself, but I was intrigued by the idea of using variables to create something along the lines of a color palette for my websites and themes. Having a color palette with a fixed number of options to choose from helps prevent me from going color crazy and deviating from a chosen style. As it turns out, LESS — and Sass for that matter — are so much more than that. LESS and Sass share a lot of similarities in syntax, including the following: Mixins – Classes for classes.Parametric mixins – Classes to which you can pass parameters, like functions.Nested Rules – Classes within classes, which cut down on repetitive code.Operations – Math within CSS.Color functions – Edit your colors.Namespaces – Groups of styles that can be called by references.Scope – Make local changes to styles.JavaScript evaluation – JavaScript expressions evaluated in CSS. Stop Making Sprites (Compass, Sass, and PNG Sprite Generation)

Update 01/11/12: new code at the bottom of this post.

Stop Making Sprites (Compass, Sass, and PNG Sprite Generation)

Sass has been kicking around for a while, but I hadn’t given it a try until just recently. Sass usually goes hand-in-hand with Rails, Compass makes it so easy to run Sass on standalone projects that I’ve started using it on nearly everything. The result is faster, DRYer, more enjoyable coding. The biggest benefit for me has been Compass’s sprite generation, which — if done right — can cut down your coding time and filesize. Sprites are an optimization best practice, but they’re no fun to work with. Don’t use IDs in CSS selectors? ❧ (@boblet) Recently I came across the post by Matt Wilcox called CSS Lint is harmful, ranting about the useful free tool CSS Lint.

Don’t use IDs in CSS selectors? ❧ (@boblet)

The 30 CSS Selectors you Must Memorize. CSS3 Solutions for Internet Explorer - Smashing Magazine. Advertisement Experienced developers understand that CSS3 can be added to new projects with progressive enhancement in mind.

CSS3 Solutions for Internet Explorer - Smashing Magazine

This ensures that content is accessible while non-supportive browsers fall back to a less-enhanced experience for the user. But developers could face a situation where a client insists that the enhancements work cross-browser, demanding support even for IE6. In that case, I’ve collected together a number of options that developers can consider for those circumstances where support for a CSS3 feature is required for all versions of Internet Explorer (IE6, IE7, & IE8 — all of which are still currently in significant use). Opacity / Transparency. iPad Orientation CSS (Revised) - desideratum.

Sass, just another CSS playground. CSS - Contents and compatibility. CSS > selection styles. A new micro clearfix hack. The clearfix hack is a popular way to contain floats without resorting to using presentational markup.

A new micro clearfix hack

This article presents an update to the clearfix method that further reduces the amount of CSS required. Demo: Micro clearfix hack Known support: Firefox 3.5+, Safari 4+, Chrome, Opera 9+, IE 6+ The “micro clearfix” method is suitable for modern browsers and builds upon Thierry Koblentz’s “clearfix reloaded”, which introduced the use of both the :before and :after pseudo-elements. Here is the updated code (I’ve used a shorter class name too): This “micro clearfix” generates pseudo-elements and sets their display to table. Including the :before selector is not necessary to clear the floats, but it prevents top-margins from collapsing in modern browsers. It ensures visual consistency with other float containment techniques that create a new block formatting context, e.g., overflow:hiddenIt ensures visual consistency with IE 6/7 when zoom:1 is applied.