Issue with Internet Explorer 11: Incompatibility with screen and print fonts when using media type

We have implemented new fonts from Google on our website, but we encountered a major issue when trying to print pages that use two specific fonts: OpenSansRegular and OpenSansSemibold. Printing a sample page from an IE browser on an HP LaserJet P3015 resulted in a 49.4c02 error, which seems to be a common problem among HP laserjet printers according to my research. Since there are numerous references to these fonts in our style sheets, it would be quite challenging to rewrite them to depend on media queries. Therefore, I am exploring an alternative solution: replacing these fonts with Arial when printing a page. I attempted two methods:

1) Using a single CSS file with the following code:

@media screen {
    @font-face {
         font-family: OpenSansRegular;
         src: url(fonts/OpenSans-Regular-webfont.eot?#iefix) format("embedded-opentype"), url(fonts/OpenSans-Regular-webfont.woff) format("woff"), url(fonts/OpenSans-Regular-webfont.ttf) format("truetype"), url(fonts/OpenSans-Regular-webfont.svg#OpenSansRegular) format("svg");
         font-weight: normal;
         font-style: normal;
    }
}
@media print {
    @font-face {
        font-family: OpenSansRegular;
        src: local("Times New Roman");
        font-weight: normal;
        font-style: normal;
    }
}

Note: In the "print" media query, I used the local font "Times New Roman" instead of the desired "Arial" for easier troubleshooting.

Results:

  • Successful with Firefox, Chrome, Opera: OpenSansRegular is displayed on screen and "Times New Roman" in the print preview.
  • Issues with IE, Edge: OpenSansRegular is not loaded, so Arial is used. It appears that IE and Edge do not support @font-face in @media queries.

2) Implementing media="print" on the link to load an alternate font:

<link href="screen_font.css" rel="stylesheet" type="text/css">
<link href="print_font.css" media="print" rel="stylesheet" type="text/css">

screen_font.css:

@font-face {
    font-family: OpenSansRegular;
    src: url(fonts/OpenSans-Regular-webfont.eot?#iefix) format("embedded-opentype"), url(fonts/OpenSans-Regular-webfont.woff) format("woff"), url(fonts/OpenSans-Regular-webfont.ttf) format("truetype"), url(fonts/OpenSans-Regular-webfont.svg#OpenSansRegular) format("svg");
    font-weight: normal;
    font-style: normal;
}

print_font.css:

@font-face {
    font-family: OpenSansRegular;
    src: local("Times New Roman");
    font-weight: normal;
    font-style: normal;
}

Results:

  • Successful with Firefox, Chrome, Opera: OpenSansRegular is displayed on screen and "Times New Roman" in the print preview
  • Issues with IE, Edge: "Times New Roman" is used for both screen and print media. It appears that the last font declaration takes precedence regardless of the specified media.

Here is a zip file containing the sample code: zip file

I'm currently out of ideas, any assistance would be greatly appreciated...

Thanks to "Coop", we have included these media queries:

//IE10 and 11 hack
@media print and (-ms-high-contrast: none), (-ms-high-contrast: active) {
    body * { font-family :Arial, sans-serif ; }
}
/* Windows 10 Edge Browser */
@media print and @supports (-ms-accelerator:true) {
    body * { font-family :Arial, sans-serif ; } 
}

We are targeting IE and Microsoft Edge specifically.

Answer №1

In my opinion, encountering issues while attempting to load @font-face within @media queries is a possibility. It is commonly recommended that fonts be loaded outside of media queries for optimal performance and readiness. Media queries can then be used to apply the appropriate font styling. Here's an example:

@font-face {
  font-family: OpenSansRegular;
  src: url(fonts/OpenSans-Regular-webfont.eot?#iefix) format("embedded-opentype"), url(fonts/OpenSans-Regular-webfont.woff) format("woff"), url(fonts/OpenSans-Regular-webfont.ttf) format("truetype"), url(fonts/OpenSans-Regular-webfont.svg#OpenSansRegular) format("svg");
  font-weight: normal;
  font-style: normal; }

@media screen {
  body { font-family: OpenSansRegular; }
}

@media print {
  body { font-family: "Times New Roman"; }
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

endless cycle of scrolling for div tags

My goal is to incorporate a tweet scroller on I believe it uses the tweet-scroller from Unfortunately, this link seems broken as the demo is not functioning. I searched for an alternative solution and came across http://jsfiddle.net/doktormolle/4c5tt/ ...

Expanding HTML zones to reach the bottom of the screen, while implementing top and side menus using the latest HTML5 and CSS techniques

Struggling to design a page layout with two navigation sections (top and left) similar to the example below: The light gray area represents where the main content will be displayed on each page. On the left side is the secondary navigation menu that shoul ...

What is the best way to ensure a dropdown in an input group occupies the full width?

One of the challenges I'm facing involves a row with 2 columns - the first column contains a title and the second column features an input group. Within the input group, there is an icon and a dropdown menu. Unfortunately, the dropdown menu is not oc ...

clicking on a DIV element

I am trying to trigger a JavaScript function by clicking on a DIV element, but for some reason it is not working as expected. I have gone through various examples provided by the helpful people here, but still can't figure out what I'm doing wron ...

Enhance text by hovering over it

I am currently working on implementing a unique feature using jQuery and CSS. Rather than just inheriting the width, I want to create a magic line that extends to the next index item. Scenario: 1: Hover over Element one ELEMENT ONE ELEMENT TWO ELEM ...

css side by side with immovable element

Seeking assistance with CSS. I am looking to create a layout as follows: I want a center-fixed menu with a width of 960px - this part is straightforward. Alongside the menu, I aim to have two divs: one spanning from the left edge of the screen to the cl ...

Tips for including vertical lines within text boxes to distinguish elements

I've been working on a simple form using CSS and HTML, but I'm struggling to add vertical lines to separate my text from the radio buttons. Right now, I'm just using '|' to divide them, but it's not the most visually appealing ...

I am interested in swapping out the text links in a menu for images

Looking to swap out text links in a menu for images, but stuck with template constraints generated by rapidweaver. The HTML template can't be modified, except for the link text itself. For example: <a href="http://truehealth.gr/eng/" rel="">!UK ...

Displaying outcomes in real-time as they appear on the HTML page

I've got a Python for loop that can generate anywhere from 1 to 20 outputs. I'm constructing a web app (using Flask and Heroku) and want each output to be displayed on my HTML page as it's generated by the loop. Here's how I'd like ...

Apply rounded corners to the table row

Currently, I am utilizing a datagrid to display information. I have been attempting to implement border radius on all the table rows, but it doesn't seem to be working. Does anyone have insight into how I can apply border-radius to all rows in the t ...

Text To Appear Gradually When Button Is Clicked

Is it possible to create a fading effect for text when a button is clicked? Currently, my code displays some text as block while hiding the rest with display:none. Take a look at my JavaScript code: <script> //Select button by id const btn1 ...

Change Dropdown menu orientation to vertical

Struggling to convert a CSS drop down menu into a vertical menu. I've tried multiple solutions but can't seem to achieve the desired result. Here is my CSS and HTML code, can anyone point out what I might be missing? #sddmT { margin: 0; pa ...

picture is not properly aligned with the right side of the container

I'm struggling to align the image flush with the right border of the div without any margin or padding. I've tried various methods but none seem to work. Hoping someone can provide a solution for me. Thank you. Below is the code snippet: HTML ...

How can I eliminate the black outline added to text by IE CSS filter?

Is there a way to add text-shadows to elements in IE without having a black outline around the text when it is not black? I know IE doesn't support text-shadow property but using filter: property gets pretty close. If anyone has any suggestions or so ...

Use body height set to 100% to measure the scrollTop distance

I am faced with a challenge on my webpage where I need to adjust the height due to scrolling elements, while also detecting the scrollTop() distance to apply some CSS to the navigation bar. Despite setting the body's height to 100%, it appears that I ...

Tips for dynamically updating the id value while iterating through a class

Here's the HTML snippet I am working with: <div class="info"> <div class="form-group"> <label class="control-label col-sm-2">Title</label> <div class="col-xs-10 col-sm-8"> <inpu ...

Column taking up the entire width positioned on the left side

Is there a way to make a column expand to the full width on the right within a container? <div class="container"> <div class="row"> <div class="col-5"> Lorem ipsum </div> <div class="col-7 img-c ...

Personalized element IDs and unique CSS styles

After editing the code snippet below... <div id="rt-utility"><div class="rt-block fp-roksprocket-grids-utility title5 jmoddiv"> I applied the changes in my custom.css file like this: #rt-utility .rt-block {CODE HERE} However, when attemptin ...

Initiate CSS-Transitions using JavaScript

Despite reading 5 tutorials on how to initiate a CSS-Transition with JavaScript, I am unable to get it to work properly. My current browser is Safari. Below is the code that I have been working on: <html> <head> <title>Test</title&g ...

What is the best way to add CSS to email addresses that are hidden by the WordPress antispambot feature?

My current method involves utilizing the WordPress antispambot code from their Code Reference: https://developer.wordpress.org/reference/functions/antispambot/ While the code is functional, I am interested in customizing the appearance of the email addre ...