DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Related

  • Choosing the Best CSS Frameworks for Enterprise Web Applications
  • React, Angular, and Vue.js: What’s the Technical Difference?
  • Build an AI Chatroom With ChatGPT and ZK by Asking It How!
  • Cookies Revisited: A Networking Solution for Third-Party Cookies

Trending

  • Creating a Web Project: Caching for Performance Optimization
  • Developers Beware: Slopsquatting and Vibe Coding Can Increase Risk of AI-Powered Attacks
  • How to Merge HTML Documents in Java
  • Agile’s Quarter-Century Crisis
  1. DZone
  2. Coding
  3. Languages
  4. How to Develop a Web Application Compatible With Internet Explorer 11

How to Develop a Web Application Compatible With Internet Explorer 11

Though IE is now deprecated, people out there still use it. Learn how to tailor your HTML and CSS to create IE compatible apps and UIs.

By 
Saif Sadiq user avatar
Saif Sadiq
·
Nov. 13, 18 · Tutorial
Likes (4)
Comment
Save
Tweet
Share
19.4K Views

Join the DZone community and get the full member experience.

Join For Free

Developing web pages compatible with Internet Explorer can be tough at times. Even though Internet Explorer’s support was pulled back by Microsoft, it still remains a popular choice among users. Internet Explorer misbehaves with some of the most important components of HTML, be it low-height, margin, or padding.

To achieve a proper fix to this problem, developers can use conditional comments and CSS commands to target browser specific commands. While it is practically impossible to achieve 100% compatibility for Internet Explorer due to its discontinued support and compatibility issues, there are several feasible ways to make sure that the user receives a decent experience. Although there is no way to develop perfectly compatible web pages, here’s a guide on how to develop a web application compatible with Internet Explorer 11 and its other variants. 

1. Using Conditional Comments

Conditional statements are the best possible way to target a piece of code specific to a given browser. They make sure that the code targets the mentioned browser and doesn’t interfere with the existing code. Other browsers ignore these kinds of HTML chunks. Conditional statements have become a standard method for embedding extra CSS into the web sheet to fill the voids in such browser’s incapabilities. For instance, incorporating the following code in your browser HTML with the source

<link href="everything.css" rel="stylesheet">
<!--[if IE]>
<link href="stupidie.css" rel="stylesheet">
<![endif]--> 

will only work for Internet Explorer (IE 9 or below). So, this will behave as a comment for all other browsers except Internet Explorer. You can also code this for specific IE versions by mentioning the exact version. This saves time that you’d have wasted in creating a completely new stylesheet for Internet Explorer. In addition to this, conditional comments don’t require DHTML or scripting, thus eliminating the need for a scripting engine, too. Conditional comments are brought into action only during the parsing and downloading phase, so only the content earmarked for the browser is actually downloaded.

2. Do Not Skip Cross-Browser Testing

What seems to be beautiful code in your personal browser might misbehave in other browsers. No matter how good your code is, there’s always a possibility that there’s something that doesn’t work in another browser. This is the core reason why you should not upload website to the server without performing cross-browser testing. 

Opting for online tools that you access to multiople browsers, so you never have to worry about missing out on a popular browser and OS combination. Use the tool to perform live and interactive cross-browser testing of your public or locally hosted web pages and applications. You may use the tool to capture automated screenshots for accelerated web layout testing. There are a lot of other amazing online cross-browser testing tools. Check them out before proceeding with the testing process. 

3. Using Certain CSS Commands

Internet Explorer and its newer sibling, Edge, hold a considerable share of audience. So, it is important to account for the compatibility of your web pages for IE and Edge users. Every browser behaves differently and this is the reason why checking the cross-browser compatibility of HTML pages and other pieces of code are in demand. Here are some of the most useful CSS commands that you can use for higher compatibility with IE and edge:

a. Vanishing Background Images and Text

Internet Explorer can sometimes make the background images and text disappear, enclosed by floating elements, especially during page scrolls. To tackle this problem, you can use the CSS command position: relative in the CSS rules that apply to the background image.

b. Unstyled Version of the Page Flashing

Once in a while when the site is stacking, an unstyled form of the page may show up for a second or two, preceding the loading of the outer CSS template. This is an instance of a Flash of Unstyled Content (FOUC). Although it corrects itself once the styles are loaded, this bug can be painstaking and confusing.

c. Doubling of the Margin Attribute

Time and again in IE, the margin attributes can double, for example, and a specified margin of 10px to a floating element winds up taking up to 20px. This bug is called the double margin bug and is quite consistent in IE6. The bug can be fixed by applying the display: inline rule to the CSS floating element.

d. Dropping of Some Containers

With only partial support for height and width properties by Internet Explorer, a bug called the ‘Flat Drop Bug’ often appears. The containers grow out of their assigned sizes, thus creating havoc on the page. Style your boxes with a negative right margin to prevent this. Apart from that, incorporate a position: relative statement in your code.

e. Min-Height Property

IE has this bad habit of ignoring the min-height property. It fetches the one from the declare minimum height, which results in some compatibility issues. Use the following statement in your code to fix the issue: 

#inner-container {
	min-height: 140px;
	height: auto !important;
	height: 140px;
}

4. Some JavaScript Hacks

Although IE is trying hard to cope up with the modern day browsers, it is still popular among developing countries and that’s why it is important that your HTML supports IE well. Apart from the recommendations above, there is one more CSS hack to achieve a web application compatible with Internet Explorer 11.

* Flickering Background Images

Background images can sometimes be wobbly when CSS is being utilised for buttons and links. This happens because the IE browser fails to cache the background images and thus keeps on reloading. You can solve this bug by adding the following code:

try {
  document.execCommand('BackgroundImageCache', false,true true); 
}
catch(e) {}

The purpose of this article is to show you how to develop a web application compatible with Internet Explorer 11 and lower. We have discussed some of the most prominent issues and their fixes. However, you can’t just rely on your code to work perfectly for all browsers and you must always test your web pages for cross-browser compatibility. 

There are plenty of tools available to make sure that your pages look like you actually want them to be. The core requirement is to make sure that all the issues with your web page are resolved and there is nothing that doesn’t work well on any Internet Explorer browser. Last but not the least, Enterprise Mode for Internet Explorer 11 can be exceptionally compelling in giving backward compatibility. The Enterprise Mode Site List incorporates the capacity to put any web application in any document mode, including IE8 and IE7 Enterprise Modes, without even changing a single line of code.

Web application Internet (web browser) Internet Explorer 11 code style CSS Compatibility (chemical)

Opinions expressed by DZone contributors are their own.

Related

  • Choosing the Best CSS Frameworks for Enterprise Web Applications
  • React, Angular, and Vue.js: What’s the Technical Difference?
  • Build an AI Chatroom With ChatGPT and ZK by Asking It How!
  • Cookies Revisited: A Networking Solution for Third-Party Cookies

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!