Theoretically, creating a web page is easy. The major aspects include writing an HTML code, testing it on a web browser and uploading it. HTML and CSS are standards, which means that a web page working fine on a particular browser may not come up clean on other browsers.
Of course, things do not turn up as simple practically. There is a variety of browsers, with each browser displaying the HTML and CSS in a different manner.
To ensure that the web pages perform uniformly across all the web browsers, cross-browser coding should be practiced by the web designers. In this post, we will discuss 10 of the tried and tested tricks you can follow to achieve an error-free and cross-browser ready website.
CSS or the Cascading Style Sheets is a set of web formatting instructions which controls the appearance the web pages. Some browsers which are compatible with CSS are:
But before you come up to a conclusion that it will save you a lot of time, you should understand that most of the web browsers do not fully support all of its features.
CSS acts as a portraying component which characterizes the components of a web page. At the same time, the cascading style sheets control the design of various pages at the same time.
While there’s no secret to curating a perfect cross-browser compatible website which ensures the bang-on aesthetics you wish for, there are some aspects which can be taken care of to improve your chances. Here are ten easy to follow yet effective tips for coding a cross-browser website.
1. The Simpler, The Better
The more complex the HTML and CSS gets, the more likely are they prone to errors and bugs. Try keeping the layout elementary at the design stage that is: a header, some columns and a footer. If your design has multiple sidebar boxes, things will turn out to be hectic as the process advances.
Avoid using a lot of nested elements and integrate only the required elements. For creating a menu, use ul and li instead of a table or a series of p elements.
Nothing annoys a designer more than carefully styling a web page and when the time comes to test it, an unknown error keeps showing up. In such situations, a designer should keep his nerves and begin with the markup and style sheets validation.
There are many free as well as paid tools available on the web to see if your HTML and CSS markups are legit. With the help of these tools, you can be assured that the markups are perfect and the web pages display the content the way you want it to.
Firebug is an all in one debugger and editor. It allows a developer to work on the HTML, JavaScript and CSS markups. You can monitor the markups in real time, highlight them and remove them as well.
While you validate the Page Source, the bugs and errors are reported. And if you cannot find out what’s wrong, the tool provides you with some suggestions.
You have to upload the file you want to validate. The validator will show you the results in different formats, such as:
The tool checks your markup for potential errors and bugs. You can set multiple CSS profiles, to choose a certain medium for the style sheet and control the information in the report.
This tool does not use the W3C rules for validation, but relies on the built-in custom protocols. You can pick from the version of HTML you wish to use, whether you want to see the source code and many other options.
Some web browsers feature a quirks mode. In this, the browser contends with its earlier versions which are often full of bugs. Although it enables an older website to be compatible with the web browsers of today, it becomes quite a task if you are looking for standardized web pages. This is because in a quirks mode, the web pages are not displayed in a standardized manner, but in its own unique way.
By default, a web browser switches to the quirks mode if you do not include the document type declaration, or the DOCTYPE. Hence, you should always remember to add a valid DOCTYPE at the end of the web page.
Every web browser has its own default values for certain aspects such as line height and width. These default values often conflict with the custom CSS rules and distort the overall appearance of the web pages.
To avoid the dilemma of customizing every CSS rule you write, you can perform all this resetting in the beginning of your CSS file. Once you add these rules in your style sheet, you can be assured that you are working from the same point for all the browsers.
Generally, developers test the web pages on a single browser at once. Then, they go to other browsers and continue making necessary changes as they go from one browser to another. This is an ideal approach rather than validating a website on all browsers in a single run.
To create your website, Firefox is the most preferred browser as it makes it easier to fix any compatibility issues over other browsers. Firefox comes with a plethora of add-ons, which makes it quite very developer-friendly. If the web pages are coming up clean on Firefox, you can be rest assured that they will perform well on other browsers.
The web browsers of today have rendering quirks, so it becomes the responsibility of the developer to test the markups on every one if them. Here’s a list of the primary web browsers:
As a quick approach, you can go for an online testing service. There are many websites such as Browsershots which take screenshots of your site and show you how they will appear on different operating systems and web browsers. These screenshots are emailed or simply made available for download. Some of the tools are paid but they surely let you know beforehand the compatibility issues the web pages might face.
CSS tricks bear no fruits if you are unable to test them on the leading web browsers. Here are some useful tools to authenticate the cross browser compatibility of the HTML and CSS markups:
This is an easy yet effective way of hunting down the cross-browser glitches. Quirksmode interprets the CSS and displays all the possible concerns.
The Browsershots tool take screenshots of the web pages and show you how your website will be displayed on different web browsers and operating systems.
This is a reliable web app that enables you to analyze the appearance of the web pages on different versions of Internet Explorer. The tool tests the template on different versions of browsers and operating systems and displays the results in an interface similar to Ms Word.
There are times when you try your level best but still, you are unable to get the desired results on certain browsers, especially the internet explorer. Here, you need some reliable and tested to be true hacks.
An easy alternative for this, you can include the IE only markup with comments. With this simple trick, you can feature the additional HTML or JavaScript only for IE.
PNG are prodigious. You can have 250+ degrees of transparency in an image. To create retina-optimized visuals, you can show off your design skills like add smooth borders and custom backgrounds.
But the Internet Explorer is not able to effectively display transparent PNGs and show foul boxes where it is supposed to be transparent. With a little bit of optimization, you can make PNGs work seamlessly in IE6. This will not require you to make major tweaks in the CSS.
You can use IE PNG Fix for the same.
Most of the web browsers are compatible with Flash and JavaScript. It is feasible to avail fallbacks in case the web browser of a visitor does not support such features.
For instance, in the case of Safari on iPhone, the Flash navigation menus go useless since the browser does not support Flash.
Here’s a quick cheat sheet to save time on experimenting with different media files:
This may be a point of discussion among the web designers. Many webmasters nowadays use automated tools to save time. They come handy especially if you are not well versed with HTML. But, it is important to note that such tools do not match up with the flexibility and elegance of a designer who skillfully hand-codes the cross-browser HTML markups.
Coding the HTML, XHTML, and CSS markups by hand goes a long way. You are in total control of what you are developing and always tweak the program as per the needs of preferences.
If you find hand coding hectic, you can use a text-based Web page editor. There are many such tools available on the internet. You may try out any of the following:
Here’s a quick check list you can consider after you have done coding a cross browser website:
Spending some extra time to make the web pages work flawlessly on as many browsers as possible always pays off. You will not only ensure that the website is accessible to the maximum audience, but you also keep the visitors happy, which is important.