15+ Techniques And Tools For Cross Browser CSS Coding

Making your website compatible with a wide range of browsers is probably the hardest task of a front-end developer. To make your coder life easier, here is 15+ tools and techniques for crossbrowser CSS development.

Part 1 – Techniques

Of course, efficient crossbrowser CSS development starts with techniques and good practices. In the first part of the article, I’ll show you X techniques that will make your crossbrowser development easier.

Reset CSS

Due to the fact web browsers define different default styling for html elements, the first thing to do is to always include a CSS reset in your stylesheet. By using this code, you’re already eliminating lots of future headaches.

Internet Explorer conditionnal comments

Let’s face it: Internet Explorer, especially the dinosaur IE6, is the front-end developer nightmare. In order to minimize their errors, Microsoft implemented conditionnal comments in their browser, which allow you to link a stylesheet that will be interpreted by a browser alone.

This technique is not W3C compliant (this is why you should use conditionnal comments instead) but sometimes, it is a real time saver.

Targeting Opera only

Opera isn’t the popular browser, but that isn’t a reason not fix problem that may occur. The code below will only target Opera, allowing you to add CSS rules only for this browser.

@media all and (min-width: 0px){
.classname {}
}

Targeting Safari only

Safari is one of the most standard-compliants browsers, so it is rare that you have to fix Safari-only problems. But it can happen sometimes. Here is a nice hack to write Safari-only CSS rules.

html:lang(en)>body .classname {}

Targeting Google Chrome only

After Opera and Safari, here is finally the same kind of hack, to target only Google Chrome:

body:nth-of-type(1) p{
color: #333333;
}

“Browser Detect” PHP Class

While Internet Explorer is most of the time the reason of crossbrowser compatibility problems, sometimes you may need to detect a wide range of browsers

If you’re working with the PHP language, the Browser Detect class is a very useful tool for detecting more than 20 different browsers.Get the class

JQuery browser detection

Another great piece of code to detect the most common browsers (Safari, Firefox, Chrome, IE and Opera) is the browserdetect.js Jquery plugin.
Once you inclued JQuery and browserdetect.js in your html file, the script will automatically add a css class to the body tag.
For example, your body tag will look like this if the visitor browser is Firefox 3:

WordPress browser detection

A while ago, I’ve explained on my other blog WpRecipes how WordPress can detect the browser used by your visitors. The code below will automatically add a CSS class to the <body> element of each page of your blog. Simply paste it on the functions.php file of your theme.

IE6 crash

Sometimes (Who said always?) Internet fucking Explorer 6 gives us, developers, lots of headaches. Although this is definitely not the best method to make your clients happy, it can be really fun to implement on your own website.

You guessed it, the following line of code will make IE6 crash. Goodbye, dinosaur.

<style>*{position:relative}</style><table><input></table>

If you’re interested in more “IE6 killer” techniques, you should definitely have a look on here.

Part 2 – Tools

Techniques are the required knowledges for efficient cross browser development, but tools can make you save time, hasle, and in three words, make your life easier.
In this second part of this article, let’s have a look at the most usefull tools freely available over the Internet.

Xenocode Browsers

This tool is what I’ll definitely call a must-have. Xenocode Browsers allows you to launch a wide variety of Windows browsers (IE 6, 7 and 8, Firefox 2 and 3, Google Chrome and Opera) directly from the Internet. You only have to install a small plugin, and that’s all.
The only weak point of Xenocode Browsers is that the tool can only run on Windows machines (XP with SP2 and later). This is a sad news for mac users like me, but the tool is still very good.Visit Xenocode Browsers

IE6 CSS Fixer

I know I already said it earlier, but Internet Explorer is the developer’s nightmare. An experimental tool has been created to transform a “normal” css stylsheet into a “IE” stylesheet.
For example, it apply new sizes for your boxes, according to the fact that IE have this well known box model bug.Visit IE6 CSS Fixer

Browsershots

No one can have something like 3 OS and 25 browsers on his/her office. Personally, I remember when I used to ask my friend running another OS than mine “hey, do that site looks good on your computer?“. This is exactly Browsershots purpose: You select the OS, you select the browser, you wait a bit, and the site show you screenshots of your website under the selected OS and browsers.
While Browsershots is obviously an usefull version, there are a few bad points. The worst of it is the waiting time for being able to see your screenshots, depending on how many browsers you selected.
Note that Browsershots offers a paid version, that I haven’t tried for now, which promise slow waiting times.Visit Browsershots

Browsrcamp : How your sites looks on a Mac

MultipleIES : Run multiples version of IE on your PC

MultipleIEs is a Windows-only program allowing you to install and run multiples versions of Internet Explorer (from version 3 to version 6) on your computer.
Althought sometimes some render difference between a “real” IE and multipleIE can occur, it is still an useful tool, if for some reason you can’t use Xenocode Browsers.Download MultipleIE

ie4osx: IE on the Mac

A similar tool to multipleIE is also available for Mac users. Sadly, it runs on X11, it is slow and buggy. But if you don’t have access to a Windows machine, it is still an interesting program to have on your dock.Download ie4osx

The design a company chooses impacts how a potential consumer perceives them. From color choice to style, different elements add up to create a first impression. This means that bad design – or lack of design – can have potential customers closing the browser and seeking other businesses. As a result, your company’s design can […] The post How Web Design Imp […]

Do you want users to spend time on your site and stick around long enough to convert? If so, it’s essential that your content is easy to navigate. If finding information is difficult, users will likely become frustrated and leave, in search of a site that provides a better user experience. A website that is […] The post How to Choose a Navigation Setup appea […]

User experience, also known as UX, is made up of many moving parts that allow it to positively impact how users feel when they visit your website. Without a positive user experience, your marketing tactics can be affected, so it’s important to understand what exactly makes for a great UX design. In this post, we’ll […] The post Why User Experience Matters to […]

Web design is one of the most important parts of any Internet marketing strategy. It has a huge impact on the digital customer experience in several different ways. Your site’s aesthetics, usability, any other crucial factors are essential to your company’s long-term online success. But how dramatically does it actually impact your bottom line? In […] The po […]

No matter how state-of-the-art your company’s website may have seemed when you first launched it, there comes a time when every site can benefit from a redesign. Given the multitude of algorithm changes than happen each year, and regular shifts in consumer Internet use, it can be nearly impossible for an outdated website to deliver […] The post How to Fix (a […]

This content was sponsored by eversign. The long-established way of getting documents signed is a huge headache. It simply isnt good. This is how we commonly handle signatures on a document: We send out the document that needs to be signed via email, snail mail, or fax. (Does anyone still use fax?) The recipient prints […] The post Electronic Signatures with […]

Sponsored by This infographic was first published on The Software Guild. It has been republished here with permission from its creators. A technology stack or tech stack for short refers to a set of technologies, software, and tools that are used in the development and deployment of sites, apps, and other digital products. For example, a […] The post A Guide […]

This content is sponsored via Syndicate Ads. Bushel is a mobile device management (MDM) solution for the iPads, iPhones, and Macs in your workplace. Bushel is developed by JAMF Software, creators of IT solutions for the Apple platform. Without a mobile device management system, the responsibility of setting up, tracking, managing, and securing all the […] Th […]

This infographic reveals common excuses why 46% of small businesses still don't have a website, with counter-arguments for each excuse. The post The Excuses for Not Having a Website (Infographic) appeared first on WebpageFX Blog.