MyPage is a personalized page based on your interests.The page is customized to help you to find content that matters you the most.


I'm not curious

How to make your website cross browser compatible?

Published on 18 June 19
0
0

With the enormous increase in the number of websites and the number of internet users, we have seen the addition of more than 3000 different types of web-enabled devices to access websites. And this huge growth in web resulted in the implementation of different types of technologies and web browsers to access the website content. So it has become very important for a developer to make sure that their website is compatible with every technology and browser for seamless working of the website. And thus this has led for Cross browser compatibility to be the need of the hour for smoother user experience on all browsers and devices.

How to make your website cross browser compatible? - Image 1

But how are you gonna make sure if your website is cross browser compatible or not? Or how to make your website cross browser compatible after knowing that it hinders user experience on some browser due to incompatibility?

Well, the first thought that comes into developers mind is that what are the factors to care about for ensuring cross browser compatibility of the website.

Without further ado, let’s dig deep into all the factors to consider to make your website cross browser compatible. But let’s first understand why your website is even incompatible with some browsers? What does it not work the same on all browsers? What’s so different about all browsers? So, let’s get started.

Why is your website not working on all browsers?

The improper rendering of a website on different browsers arises because some of the web technologies and features are not supported by some of the browsers. Web developers start developing a website or web app with a mindset of taking their favorite browser (Latest Google Chrome version, in most of the cases) in consideration and implementing animation and graphics to make the website more beautiful. If you test it, it will work awesome in the Chrome browser. But what about IE, Edge and Safari browser?

Here disasters come with Internet Explorer. Majority of the web elements do not render as expected, animations break and even some of the sections don’t load at all. Since IE covers a lot user base, so it will become very important to make sure your website run as expected in it.

And why IE is still used by people, is in itself a complete story. Since we do not use IE, we assume nobody uses it. In a past day, I read an article on How to Develop a Web Application Compatible With Internet Explorer 11 and its comments took me by awe! People were concerned why is there even a need to make it compatible with IE 11?

Similarly, it goes for Microsoft Edge, Firefox and Safari browser. And mobile browsers are also added in the story as more than 7740 million mobile users access websites across the globe.

Solution to this problem is to find all the web techs and features which are not supported by different browsers. For Example: Web Authentication API is just supported by the latest versions of Edge, Firefox, Chrome and Opera browser. This will not work for the other browsers like Safari, IE (most hatred one), and some of the mobile browsers showing cross browser compatibility issues.

How to make your website cross browser compatible? - Image 2

In the same way, with caniuse.com you can checkout all the web technologies and features which are not supported by various browsers and try fixing those or avoid them in your website or application to avoid browser compatibility issues.

Define Valid Doctype

Doctype is the primary thing to consider while writing the code which helps browsers to recognize which programming language and set of rules you have used in your code. However, many times developers forget to add it in the code which causes the browser not to understand it properly and cause compatibility issues. Hence, it is necessary to make sure that you have added the Doctype in your website code or not.

Generally, your browser will switch to quirks mode if you forget to add DOCTYPE in your source code. And as “Quirks mode” emulate the older and buggier version of the browser it can be a big headache for your end users. Quirk mode renders web elements and pages in a completely different and non-standard way thus causing browser incompatibility

Keep the code simple

You might be thinking how keeping the code simple helps in making a cross browser compatible website? Well, it doesn’t!

The purpose of keeping a code simple is more towards avoiding cross browser compatibility issues. Many times, when a developer writes a messed up code, a tag if left open can be a huge headache to figure out. And that tag might be the biggest reason of browser incompatibility. That’s because, there are some browsers which are intelligent and they understand the code and add tags by themselves while rendering while some dumb browsers don’t. Keeping a code simple and clean helps to easily figure out those issues and save browser compatibility.

For example: Avoid using nested tags in your markup, use the right element to achieve the goal. For example: if you want to create a menu in the webpage, you should use UI and LI tags instead to repeated Paragraph element or using a table for same.

Check CSS Reset

Every browser has default CSS values which is slightly different from another browser. It will become a pain for developers to add CSS attribute values in the code to make the webpage compatible with the browser. And the worst part is to remember the count the number of times you have used a particular CSS value to make it consistent for all the browsers.

To overcome this problem and avoid the hassle, you can use CSS reset in your code to make sure all the browsers follow the same CSS rule and behave consistently. Eric Meyer’s CSS reset is one of the famous and most used CSS resets which you can use in your source code to make sure of cross browser compatibility of your web page.

You can add following CSS reset file in the header section of your code:

<link rel="stylesheet" href="assets/styles/normalize.css">

<link rel="stylesheet" href="assets/styles/main.css">

Conditional statements for different browsers

No matter how hard you are trying to make your website cross browser compatible, Internet Explorer always acts as pain in web developer’s life. Sometimes, even after putting CSS reset some browser does not render web elements as expected which creates abad user experience and ultimately loss in your online business.

This stylesheet rendering issue can be solved by providing different CSS files for different browsers using conditional statements. A particular browser will only access CSS files associated to it. And simple if else, if End if conditional commands can help to achieve the same.

Here’s the sample code:

1

2

3

4

5

6

<!-- [If IE]>

<link type="text/css" href="IEHacks.css" />

<![endif]-->

<!-- [if !IE]>

<link type="text/css" href="NonIEHacks.css" />

<![endif]-->

Use Cross Browser Friendly Libraries and Frameworks

You can rely on Cross browser compatible Javascript libraries like jQuery, YahooUI, MooTools, Dojo and CSS frameworks Bootstrap, Foundation, 960 grid, etc that they will not create any incompatibility issues. Though this will not guarantee complete cross browser compatibility but will save major cross browser compatibility issues that are caused due to incompatible libraries and frameworks.

Validate your code

Once you are done with the coding part, next comes the validation. Is the code you developed, correct? Does it not miss major tags, elements? Is the syntax correct?

It’s always a good practice to validate the web page code before pushing it on public servers. Because a valid code cannot do magic and make your web page work on all browsers seamlessly but can save you a lot of basic incompatibility issues and an invalid code can generate various sort of compatibility issues and problems.

You can use W3C HTML Validator and CSS Validator to validate your HTML and CSS code. You can also browser plugins such as Firefox ad-on https://addons.mozilla.org/en-US/firefox/addon/249 for easy validation right from your browser.

How to make your website cross browser compatible? - Image 3

You will have a list of issues and bugs in your source code after validating the source code. You can fix them and you will be all set to cross one item from your cross browser testing checklist.

Don’t Skip Cross Browser Testing

Last but not least, Cross browser testing of the website n Well, this is what we were aiming from the beginning when we started this article, right? Since you’re now sure that your website is cross browser compatible, still you’ll need to make sure that it is. Cross browser testing will help you to make sure that your website is perfectly working in all the browsers or not.

You can use a tool like LambdaTest as your cross browser testing tool which provides a platform with all the latest browsers (also Internet Explorer, most hatred one), browser versions and operating systems on which you can test your website for browser compatibility issues. LambdaTest also provides an online selenium grid that gives you the ability to run your test scripts on 2000+ browser environments.

You can make a list of bugs after testing and figure out how to fix them. And you will be all set with your seamless and cross browser compatible website.

I hope these tips and techniques will help you make your website cross browser compatible. Let me know in the comment section if that helped!

With the enormous increase in the number of websites and the number of internet users, we have seen the addition of more than 3000 different types of web-enabled devices to access websites. And this huge growth in web resulted in the implementation of different types of technologies and web browsers to access the website content. So it has become very important for a developer to make sure that their website is compatible with every technology and browser for seamless working of the website. And thus this has led for Cross browser compatibility to be the need of the hour for smoother user experience on all browsers and devices.

How to make your website cross browser compatible? - Image 1

But how are you gonna make sure if your website is cross browser compatible or not? Or how to make your website cross browser compatible after knowing that it hinders user experience on some browser due to incompatibility?

Well, the first thought that comes into developers mind is that what are the factors to care about for ensuring cross browser compatibility of the website.

Without further ado, let’s dig deep into all the factors to consider to make your website cross browser compatible. But let’s first understand why your website is even incompatible with some browsers? What does it not work the same on all browsers? What’s so different about all browsers? So, let’s get started.

Why is your website not working on all browsers?

The improper rendering of a website on different browsers arises because some of the web technologies and features are not supported by some of the browsers. Web developers start developing a website or web app with a mindset of taking their favorite browser (Latest Google Chrome version, in most of the cases) in consideration and implementing animation and graphics to make the website more beautiful. If you test it, it will work awesome in the Chrome browser. But what about IE, Edge and Safari browser?

Here disasters come with Internet Explorer. Majority of the web elements do not render as expected, animations break and even some of the sections don’t load at all. Since IE covers a lot user base, so it will become very important to make sure your website run as expected in it.

And why IE is still used by people, is in itself a complete story. Since we do not use IE, we assume nobody uses it. In a past day, I read an article on How to Develop a Web Application Compatible With Internet Explorer 11 and its comments took me by awe! People were concerned why is there even a need to make it compatible with IE 11?

Similarly, it goes for Microsoft Edge, Firefox and Safari browser. And mobile browsers are also added in the story as more than 7740 million mobile users access websites across the globe.

Solution to this problem is to find all the web techs and features which are not supported by different browsers. For Example: Web Authentication API is just supported by the latest versions of Edge, Firefox, Chrome and Opera browser. This will not work for the other browsers like Safari, IE (most hatred one), and some of the mobile browsers showing cross browser compatibility issues.

How to make your website cross browser compatible? - Image 2

In the same way, with caniuse.com you can checkout all the web technologies and features which are not supported by various browsers and try fixing those or avoid them in your website or application to avoid browser compatibility issues.

Define Valid Doctype

Doctype is the primary thing to consider while writing the code which helps browsers to recognize which programming language and set of rules you have used in your code. However, many times developers forget to add it in the code which causes the browser not to understand it properly and cause compatibility issues. Hence, it is necessary to make sure that you have added the Doctype in your website code or not.

Generally, your browser will switch to quirks mode if you forget to add DOCTYPE in your source code. And as Quirks mode emulate the older and buggier version of the browser it can be a big headache for your end users. Quirk mode renders web elements and pages in a completely different and non-standard way thus causing browser incompatibility

Keep the code simple

You might be thinking how keeping the code simple helps in making a cross browser compatible website? Well, it doesn’t!

The purpose of keeping a code simple is more towards avoiding cross browser compatibility issues. Many times, when a developer writes a messed up code, a tag if left open can be a huge headache to figure out. And that tag might be the biggest reason of browser incompatibility. That’s because, there are some browsers which are intelligent and they understand the code and add tags by themselves while rendering while some dumb browsers don’t. Keeping a code simple and clean helps to easily figure out those issues and save browser compatibility.

For example: Avoid using nested tags in your markup, use the right element to achieve the goal. For example: if you want to create a menu in the webpage, you should use UI and LI tags instead to repeated Paragraph element or using a table for same.

Check CSS Reset

Every browser has default CSS values which is slightly different from another browser. It will become a pain for developers to add CSS attribute values in the code to make the webpage compatible with the browser. And the worst part is to remember the count the number of times you have used a particular CSS value to make it consistent for all the browsers.

To overcome this problem and avoid the hassle, you can use CSS reset in your code to make sure all the browsers follow the same CSS rule and behave consistently. Eric Meyer’s CSS reset is one of the famous and most used CSS resets which you can use in your source code to make sure of cross browser compatibility of your web page.

You can add following CSS reset file in the header section of your code:

Conditional statements for different browsers

No matter how hard you are trying to make your website cross browser compatible, Internet Explorer always acts as pain in web developer’s life. Sometimes, even after putting CSS reset some browser does not render web elements as expected which creates abad user experience and ultimately loss in your online business.

This stylesheet rendering issue can be solved by providing different CSS files for different browsers using conditional statements. A particular browser will only access CSS files associated to it. And simple if else, if End if conditional commands can help to achieve the same.

Here’s the sample code:

1

2

3

4

5

6

Use Cross Browser Friendly Libraries and Frameworks

You can rely on Cross browser compatible Javascript libraries like jQuery, YahooUI, MooTools, Dojo and CSS frameworks Bootstrap, Foundation, 960 grid, etc that they will not create any incompatibility issues. Though this will not guarantee complete cross browser compatibility but will save major cross browser compatibility issues that are caused due to incompatible libraries and frameworks.

Validate your code

Once you are done with the coding part, next comes the validation. Is the code you developed, correct? Does it not miss major tags, elements? Is the syntax correct?

It’s always a good practice to validate the web page code before pushing it on public servers. Because a valid code cannot do magic and make your web page work on all browsers seamlessly but can save you a lot of basic incompatibility issues and an invalid code can generate various sort of compatibility issues and problems.

You can use W3C HTML Validator and CSS Validator to validate your HTML and CSS code. You can also browser plugins such as Firefox ad-on https://addons.mozilla.org/en-US/firefox/addon/249 for easy validation right from your browser.

How to make your website cross browser compatible? - Image 3

You will have a list of issues and bugs in your source code after validating the source code. You can fix them and you will be all set to cross one item from your cross browser testing checklist.

Don’t Skip Cross Browser Testing

Last but not least, Cross browser testing of the website n Well, this is what we were aiming from the beginning when we started this article, right? Since you’re now sure that your website is cross browser compatible, still you’ll need to make sure that it is. Cross browser testing will help you to make sure that your website is perfectly working in all the browsers or not.

You can use a tool like LambdaTest as your cross browser testing tool which provides a platform with all the latest browsers (also Internet Explorer, most hatred one), browser versions and operating systems on which you can test your website for browser compatibility issues. LambdaTest also provides an online selenium grid that gives you the ability to run your test scripts on 2000+ browser environments.

You can make a list of bugs after testing and figure out how to fix them. And you will be all set with your seamless and cross browser compatible website.

I hope these tips and techniques will help you make your website cross browser compatible. Let me know in the comment section if that helped!

Post a Comment

Please notify me the replies via email.

Important:
  • We hope the conversations that take place on MyTechLogy.com will be constructive and thought-provoking.
  • To ensure the quality of the discussion, our moderators may review/edit the comments for clarity and relevance.
  • Comments that are promotional, mean-spirited, or off-topic may be deleted per the moderators' judgment.
You may also be interested in
 
Awards & Accolades for MyTechLogy
Winner of
REDHERRING
Top 100 Asia
Finalist at SiTF Awards 2014 under the category Best Social & Community Product
Finalist at HR Vendor of the Year 2015 Awards under the category Best Learning Management System
Finalist at HR Vendor of the Year 2015 Awards under the category Best Talent Management Software
Hidden Image Url