The font is not displaying properly in any browser, even though everything appears to be set up

Despite reading through all the relevant answers on various platforms, I am still unable to display my fonts properly. I have checked the paths, ensured that the files are in the correct location, and even tested a font squirrel example, but to no avail.

Everything else on my PC seems to be functioning correctly - paths, images, links, etc. Everything in my CSS file appears to be in order:

    body {
    background: url('mcontentback.jpg') repeat center center fixed;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    margin:0;
    padding:0;
    border:0;
    width:100%;
    height:100%;
    min-width:497px;
    text-align:center;
    }
@font-face {
    font-family: 'bahamasregular';
    src: url('../fonts/bahamas-webfont.eot');
    src: url('../fonts/bahamas-webfont.eot?#iefix') format('embedded-opentype'),
          url('../fonts/bahamas-webfont.woff') format('woff'),
          url('../fonts/bahamas-webfont.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-size:100%;
    }
@font-face {
    font-family: 'bahamaslightregular';
    src: url('../fonts/bahamaslight-webfont.eot');
    src: url('../fonts/bahamaslight-webfont.eot?#iefix') format('embedded-opentype'),
          url('../fonts/bahamaslight-webfont.woff') format('woff'),
          url('../fonts/bahamaslight-webfont.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-size:100%;
    }
a {
    color:#369;
    }
a:hover {
    color:#000;
    background:#369;
    text-decoration:underline;
    }
h1,
h2,
h3 {
    color:#000;
    margin:.8em 0 .2em 0;
    padding:0;
    font-family: bahamasregular;
    }
p {
    color:#000;
    margin:.4em 0 .8em 0;
    padding:0;
    font-family: bahamaslightregular;
    }
.colmask {
    position:relative;
    clear:both;
    float:left;
    width:100%;
    overflow:hidden;
    }
.col1 {
    float:left;
    position:relative;
    padding:0 0 1em 0;
    overflow:hidden;
    }
.fullpage {
    min-height:1200px;
    }
.fullpage .col1 {
    width:96%;
    left:2%;
    }
img {
    max-width:100%;
    }

And here is my HTML5 code:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB"><head>

    <title>Blaa blaa</title><meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8">
    <meta name="description" content="Blaa blaa">
    <meta name="keywords" content="Blaa blaa">
    <meta name="robots" content="index, follow">
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
    <link rel="stylesheet" type="text/css" href="../resourses/css/mcontent.css" media="screen"></head>

<body onload="parent.resizeIframe(document.body.scrollHeight)">
    <div class="colmask fullpage">
        <div class="col1">
        <h1>Blaa blaa!</h1>
        <p>Blaa blaa foo blah bla.</p>
        <p>Blaa blaa foo blah bla!</p>
    </div>
</div>
</body>
</html>

Despite all my efforts, I can't seem to figure out what I am doing wrong. I have tested this on IE 11, Firefox 28, and Comodo Dragon on Windows 7. Any insights would be greatly appreciated.

Answer №1

Your CSS code has an excess of brackets, preventing the font-family from being applied to any part of your webpage. Additionally, the font-family is missing quotation marks.

I suggest correcting this section:

h1, h2, h3 {
    color:#000;
    margin:.8em 0 .2em 0;
    padding:0;
    }
    {
    font-family: bahamasregular;
    }

to this:

h1, h2, h3 {
    color:#000;
    margin:.8em 0 .2em 0;
    padding:0;
    font-family: 'bahamasregular';
}

The same error is present in the CSS code for the p element.

For more information, you can refer to this tutorial on @font-face. Also, as suggested by Jukka, make sure to check if the font files are loading properly using your browser's developer tools.

Answer №2

Initially, I encountered a multitude of issues rather than just one. The reason behind its failure to function in Internet Explorer remains somewhat ambiguous to me, as I attempted various solutions prior to testing with IE. However, MF82 highlighted an aspect that potentially resolved the issue with IE. On the other hand, many individuals seem to encounter this issue with Firefox. It's worth noting that this pertains to a local PC, not a server. This is what ultimately worked for me:

On Firefox, local documents can access other local documents within the same directory and in subdirectories, although not directory listings.

The culprit lies in Firefox's prefs.js file under the setting "security.fileuri.strict_origin_policy." For further clarification, refer to MozillaZene's description.

Despite my attempts, merely relocating the font files to the same directory as the CSS file and adjusting the path statements in the CSS file accordingly did not yield success. Nevertheless, modifying the setting did resolve the issue.

To alter the setting "security.fileuri.strict_origin_policy," follow this guide: Editing prefs.js in Firefox. Simply double-clicking the setting will switch its value from "False" to "True."

It is essential to acknowledge that this adjustment exposes your filesystem to traversal. Therefore, I suggest reversing the process once you confirm everything is functioning properly. Only modify the setting when necessary to view the fonts, then revert back. Hopefully, this issue will be rectified in a forthcoming Firefox update.

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

Affix Object to Bottom of Stationary Element

I have a header element that I want to remain fixed while scrolling. The scrollable area should be positioned directly after the fixed header, without using position: absolute and removing it from the document flow. To better illustrate the issue, I' ...

Insert an icon at the conclusion of a truncated multi-line text without causing a line break

I have a specific requirement where I am looking to present two lines of text, followed by an icon displayed through an img tag. If the text exceeds two lines, I want to display an ellipsis. However, it is crucial that the icon remains inline with the text ...

The body tag mysteriously disappears after the function is called within the $().html() command

As I delve into scraping the source code of a website, I encounter an interesting phenomenon. Initially, when I print out the complete source code, everything appears as expected. However, upon attempting to print an actual DOM, I notice a slight change i ...

The jQuery `.load` function appears to be malfunctioning

I am having trouble getting my simple .load() function from jQuery to work. When I click on my DIV, nothing happens. However, the alert TEST does work. <div class="ing">CLICK HERE</div> <div id="overlay3-content"></div> <scrip ...

Hover over an element to trigger the background fading effect on the parent div

I'm looking to create a hover effect on an element within a fullscreen div. When I hover over the element, I want a background image to fade in on the div with the class ".section." While I can easily display the background image, I am unsure of how t ...

Ways to resize column widths in tree views on Odoo version 10?

I have been struggling to adjust the column width of the columns in my tree view. I have attempted a few different solutions: Trying to change the width attribute in the field tag: width="100px" or width="15%%" Using the style att ...

Determine the location of an image with the help of Jquery

I'm currently working on finding the position of an image with Jquery. The issue I am facing is that it only provides me with the initial position of the image when the document was loaded. $(".frog").click(function(){ alert($(".frog").position() ...

Arrange a stationary child in relation to the grandparent element

I created a small window within a browser window, containing an even smaller window with auto-scrolling text. However, I need some text in the smaller window to remain static and not scroll. Therefore, I used position_fixed which is absolutely related to ...

Deleting an element from an HTML page with jQuery

Hi there, I'm just starting to learn about jQuery. Below is an example of a list element I have: <ul> <li> <a href="abc">ABC</a> </li> <li> <!-- This is the element I want to get rid of --&g ...

Highcharts - Troubleshooting the chart reflow feature

Take a look at the fiddle I created. I encountered an issue with the chart width when toggling the sidebar. After seeking help on Stack Overflow from this post, I was able to solve it. Now, I'm facing another bug where adding transitions while togg ...

Can this functionality be accomplished using only HTML and CSS, without relying on JavaScript?

Image for the Question Is it possible to create a zoom functionality using only HTML and CSS, without relying on JavaScript? I need this feature for a specific project that doesn't support JavaScript. ...

Utilizing the p tag to incorporate dynamic data in a single line

I am currently working with two JSON files named contacts and workers. Using the workerId present in the contacts JSON, I have implemented a loop to display workers associated with each contact. The current display looks like this: https://i.sstatic.net/AR ...

What is the purpose of the video-js endcard plugin incorporating native controls into the player?

Endcard is a unique plugin designed for the video-js html5 video player that adds clickable links to the end of a video. (More information on endcards can be found here: https://github.com/theonion/videojs-endcard). To implement an endcard, simply include ...

align the horizontal navigation bar

I am facing an issue with my horizontal navigation bar. I want to include a search bar within the navigation bar, but it is causing misalignment. Here is the link to the code: https://jsfiddle.net/r6ntxg2f/ If you look at the menu, you will notice that i ...

Unable to display <iframe> containing a YouTube video on Mozilla Firefox page

I have included an <iframe> in my webpage to display videos from YouTube, but I am facing an issue with Mozilla Firefox. In Chrome, IE, and Edge, the videos display correctly using the following code: <iframe src="http://www.youtube.com/v/DNLh8p ...

Stop any accidental double clicks on the <input type="submit" /> to avoid duplicate entries

Is it possible to prevent a user from clicking twice on an input tag button with type submit? I attempted using ondblclick="javascript:void(0)", but it did not work. My code is within an Html.BeginForm, not a form element tag. Thank you in advance for al ...

CSS issue: Font size

Can someone help me out with a CSS issue that has been tripping me up? I've been working with CSS for three years now, and this particular problem is stumping me. I have defined some styles in my CSS file that should be applied to the content of my w ...

Text transitions in a gentle fade effect, appearing and disappearing with each change

I want to create a smooth fade in and out effect for the text within a div when it changes or hides. After researching on Google and Stack Overflow, I found that most solutions involve adding a 'hide' CSS class and toggling it with a custom func ...

Tips for ensuring text remains within a div container and wraps to the next line when reaching the edge

Currently, I am working on a flash card application using Angular. Users can input text in a text box, and the text will be displayed on a flash card below it. However, I have encountered an issue where if the user types a lot of text, it overflows and mov ...

A guide to loading CSS and JavaScript files asynchronously

Is it possible to use loadCSS (https://github.com/filamentgroup/loadCSS/blob/master/README.md) to allow the browser to asynchronously load CSS and JavaScript? This is what I currently have in my head tag: <link rel="preload" href="http://zoidstudios. ...