VEXXHOST Logo
Purple pattern background

Only CSS Hack You Will Ever Need... Seriously.

Mohammed NaserMohammed Naser

While working on a few of my clients pages, I have always used other methods for CSS hacks but mostly using PHP to detect the remote user User-Agent and come up with the specific CSS. Until I have discovered this one:

You can actually have IE6 specific lines in CSS, it is as simple as prefixing them with an underscore. Sure, you might start complaining “STANDARDS!!11!” If I had to choose from a site that works fine in every browser and standards, I will go with the more working one. That is not all! You can actually have lines that are both IE6 & IE7 specific in CSS by prefixing them with a dot.

So to sum it up, let's say if I use a left margin that has to be 5px in Firefox/Opera, 6px for IE6 & 7px for IE7, Here is how I would do it:

margin-left: 5px; /* Left margin for all browsers, mainly Opera, Firefox, etc. */  
.margin-left: 7px; /* Left margin of 7px that can be readable by both IE6 & IE7, now other still think it's 5 while IE6 & IE7 think it's 7 */  
_margin-left: 6px; /* Only IE6 reads this and changes the value to 6px */

I have to admit I was pretty happy upon discovering this hack; I will definitely be using it for a while now that I have found a pretty good one.

Do you have any of your own do not need loads of JavaScript and/or PHP code to work? If so, comment below!

On a side note, here is a little of information about us,

VEXXHOST was created in 2006 and opened it's virtual doors as web hosting provider. VEXXHOST now offers Public, Private and Hybrid cloud all powered by OpenStack.

Our cloud services contains OpenStack software and has been validated through testing to provide API compatibility for OpenStack core services.

If you are interested in reading more blog posts, you can always check out the VEXXHOST blog located on our website which includes many more interesting blogs and tutorials! If you have any questions concerning this blog or in general, feel free to communicate with us through our Contact Us page. One of our support team member will be more than happy to assist you and answer all your questions.

Don't forget to follow us on Twitter for announcements, updates and news regarding VEXXHOST and cloud computing in general – @vexxhost.

Share on social media

Virtual machines, Kubernetes & Bare Metal Infrastructure

Choose from Atmosphere Cloud, Hosted, or On-Premise.
Simplify your cloud operations with our intuitive dashboard.
Run it yourself, tap our expert support, or opt for full remote operations.
Leverage Terraform, Ansible or APIs directly powered by OpenStack & Kubernetes