[pmwiki-users] Idea for a recipe - Avoid Css Hacks

Crisses crisses at kinhost.org
Sun Nov 19 19:53:57 CST 2006


On Nov 19, 2006, at 1:08 PM, Carlos A. Bonamigo wrote:

> Hi again, I was looking for easier ways  to obtain browser  
> compatibility for a
> skin and I saw an article about how to handle css with php.
>
> The code looks like this:
>
...

> Making a way out of the labirynth css can be sometimes.
>
> So, is it a good idea for a recipe?
>
> Carlos
>
>
> (The article and the script can be found here ->
> http://www.stylegala.com/articles/no_more_css_hacks.htm)

I don't use css hacks anymore.  I've found several ways around the  
problems without needing "hacks".  I don't need the css box hacks,  
and I'm trying to remember what the other big problem was...  Boxes  
are resolved by nesting an additional div and using margins on the  
inner div, instead of padding on the outer div.  The visual effect is  
exactly the same.  I don't consider that a hack, since now all  
browsers are in 100% agreement over what they're doing -- I just  
think in terms of anything fixed width needing to be a container  
object on the page.

The other problem is resolved using the !important attribute, which  
is ignored by IE 6.  It's a minor hack/work-around, but definitely  
does not require using separate css files.  You set the attribute  
with !important, then set it again with the settings you want IE 6 to  
use.  Other browsers that respect !important ignore the new setting  
for the attribute, IE 6 doesn't.

IE 7 presumably won't have these problems.

So, while I'm a designer and constantly making custom designs for  
websites, I've found I don't really need complicated hacks &  
workarounds anymore.  At least they all seem to work when I test them  
in browsers.  I still occasionally curse IE 6, but I've found that  
pretty much all I have to do is a search for padding to figure out  
the issue ;)  then I have to figure out a way to change the padding  
into a margin.

Are there reasons for your recipe aside from hacks around browsers?

Crisses




More information about the pmwiki-users mailing list