Unable to resolve @font-face issue despite exhausting all possible solutions

Struggling with the @font-face code and unable to get my font file recognized.

I've attempted various path changes, created new folders, renamed existing ones, even moved the font file to the root directory, but no luck.

Testing in both Firefox and Chrome.

Here are the different CSS codes I've tried:

{various src paths}

Can anyone pinpoint where the font file should go or suggest changes to the CSS to make it work?

(I've already checked similar questions online and tried resources like this website without success.)

Thank you!

UPDATE: Following bozdoz's recommendation didn't solve the issue. Used FontSquirrel to obtain the fonts. CSS looks like this:

@font-face {
    font-family: 'lane';
    {src paths for different font formats}
    font-weight: normal;
    font-style: normal;
}

h1{    font-size: 110px;
    font-family: 'lane', georgia, serif;
    color: #000000; 
    }

The name 'lane' is just used because of bozdoz mentioning it.

All font files can be found here:

http://thefalljourneyindia.iblogger.org/wp-content/themes/thefalltheme/images/

They are named as follows:

univers-webfont.eot, univers-webfont.woof, univers-webfont.ttf, univers-webfont.svg

Answer №1

Have you checked if you are utilizing it correctly? The @font-face format is crucial, especially the number of files required for different browsers. Utilize Font Squirrel to easily generate all the necessary font files for optimal cross-browser compatibility. It seems like you are working with WordPress. Remember to use absolute paths (the first one in your list) in CSS when dealing with WordPress websites. I hope this information proves useful to you.

<style>
@font-face {
    font-family: 'lane';
    src: url('type/lanehum-webfont.eot');
    src: url('type/lanehum-webfont.eot?#iefix') format('embedded-opentype'),
         url('type/lanehum-webfont.woff') format('woff'),
         url('type/lanehum-webfont.ttf') format('truetype'),
         url('type/lanehum-webfont.svg#LaneHumouresqueRegular') format('svg');
    font-weight: normal;
    font-style: normal;
}
.font { font-family:"lane", arial, serif; }
</style>

Answer №2

If you're looking to achieve something similar, consider the following approach:

@font-face { font-family: Yummy; src: url('Yummy-Regular.otf'); } 

Make sure that the font file is referenced relative to your CSS file location. For instance, if your CSS file is situated at:

/Styles/main.css

Then the font file should also be in the same directory. If you decide to specify it like this:

@font-face { font-family: Yummy; src: url('fonts/Yummy-Regular.otf'); } 

Then the font file path would be:

/Styles/fonts/Yummy-Regular.otf

It's advisable to check whether your server is permitting the download of these fonts. You can test the URL to see if there are any 404 or 403 errors.

Answer №3

For creating custom fonts, consider using the FontSquirrel font generator. Their scripts are extensively tested and compatible with various browsers. Be sure to select advanced settings when generating your fonts. Some browsers may not support ttf as a font format, so FontSquirrel provides options such as eot, woff, and ttf

Answer №4

Here are some helpful suggestions based on the feedback provided:

Consider using quotes for your URLs:

url("Univers.ttf");

Make sure to include the font-family property in your code:

font-family: "MyFontName";

To apply your custom font family in CSS, you can use the following syntax:

p { font-family: "MyFontName", Arial, sans-serif; }

Answer №5

Thank you to everyone for your amazing support! I greatly appreciate it. The issue wasn't with the @font-face code, but rather with my CSS structure. My CSS was initially structured like this:

/*   
Info
*/

@media screen {
* {
margin: 0px;
padding: 0px;
}
html { background: black url(images/bg.jpg); }
body { font: 14px/1.4 Georgia, serif; }
article, aside, figure, footer, header, nav, section { display: block; }

@font-face {
font-family: 'lane';
src: url('http://thefalljourneyindia.iblogger.org/wp-content/themes/thefalltheme/images/univers-webfont.eot');
src: url('thttp://thefalljourneyindia.iblogger.org/wp-content/themes/thefalltheme/images/univers-webfont.eot?#iefix') format('embedded-opentype'),
     url('http://thefalljourneyindia.iblogger.org/wp-content/themes/thefalltheme/images/univers-webfont.woff') format('woff'),
     url('http://thefalljourneyindia.iblogger.org/wp-content/themes/thefalltheme/images/univers-webfont.ttf') format('truetype'),
     url('http://thefalljourneyindia.iblogger.org/wp-content/themes/thefalltheme/images/univers-webfont.svg#LaneHumouresqueRegular') format('svg');
font-weight: normal;
font-style: normal;
}

etc.

The key problem was that the @font-face declaration was positioned after @media screen. Once I moved it in front of @media screen and before /* Info */, everything worked seamlessly.

I also discovered that I can utilize both absolute and relative paths when working with Wordpress...

I want to express my gratitude once again for all the assistance provided!

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

Tips for addressing Navbar collision with body content or other pages using CSS

I have successfully created a navigation bar using CSS and JS. The image below illustrates the example of my navigation bar: https://i.sstatic.net/2l4gj.png The issue I am facing is that when I select "MY ACCOUNT," it displays some content. However, upon ...

"Utilizing nested div tags for precise positioning within a parent div tag

For days, I have been attempting to align 4 div tags (accommodation site widgets) within another div tag so that they are displayed in a single horizontal line side by side. Despite using CSS properties such as "float" and "display", only 2 out of the 4 di ...

Issue with Slider Width in WP 5.6 editor and ACF Pro causing layout problems

Is anyone else experiencing a specific issue after updating to WP 5.6? Since the update, all my websites are facing problems with rendering a Slick Slider in the Block Editor. Interestingly, everything looks fine on the front-end. The root of the problem ...

Grow an element starting from its center without being limited by the boundaries of a div

I'm faced with a puzzling issue that I believe has a simple solution, but it seems to be eluding me at the moment. Essentially, I have a div containing an image as its background. Upon clicking this div, I want another circular div (created using bord ...

What is the best way to invert the positioning of the li elements to move upwards?

https://i.stack.imgur.com/mZaoS.png Seeking assistance on adjusting the height of bars to start from the bottom and go upwards instead of starting from the top position and going downwards. The JavaScript code below is used to generate the li elements and ...

Issues arising from the v-for loop iterating through the products list

Apologies for any language errors in my English, as it is not my first language. If you would like to view my github page, you can find it here: https://github.com/CapitaineBarbarossa/test-carousel I am currently facing an issue with creating a dynamic car ...

"Using enchant.js to create a game that utilizes an if statement to show a specific

I am looking to implement an if statement into my game that will display an html div (#game-over) once a certain score is reached. The div is currently set to "display:none". I have created a js fiddle for the game with the code $('#game-over'). ...

The style from '<URL>' was not applied as it has a MIME type of 'text/html', which is not a compatible stylesheet MIME type

After attempting to run the angular application with the home component, an error appeared stating that styles were refused and images could not be found. It's puzzling because the CSS and image folder are located in the /src/assets folder. I have tr ...

Personalized Bootstrap 4 grid system

Could someone guide me on how to create this grid layout with Bootstrap 4? I am trying to achieve a design where one column stretches from the edge of the window to the inside, while the other column is half the width of a standard .container element. ht ...

Aligning a 900px wide element with an orange background on the left and a white background on the right

I have a section on my website that I want to position in the center of the screen. It's a simple task, but I have a specific design in mind. I want the left side of the section to have an orange background, while the right side should be white. I&apo ...

Selecting the initial and final elements in a list without utilizing pseudo-classes

Currently, I am in the process of designing a custom MUI styled component and I have encountered a challenge. I want to apply extra styles specifically for the first and last child elements. The issue arises because MUI utilizes the emotion styled library, ...

Menu with option to delete next to each selection item

My task is to create a drop-down menu with a delete 'X' option next to each item. This functionality should work even when the drop-down is dynamically populated, without resorting to using a list as an alternative. UPDATE: The icons next to eac ...

The clash between Angular.json's CSS styles configuration and a component's own CSS settings

After experimenting with both angular.json's CSS setting and component CSS setting, I noticed that the component CSS setting is not fully applied. I am looking for a way to ensure that the component CSS setting works properly in a particular componen ...

How to adjust the transparency of a background image in a parent div without impacting its child elements? (Using Twitter Bootstrap)

In an effort to enhance the aesthetics of a website, I have been utilizing Twitter Bootstrap. One snippet of my HTML code looks like this: <div class = 'container-fluid bg-1'> <div id ='yield_wrap'> ...

Tips on eliminating borders in react-table components

Within my React.js component, I have implemented a table using react-table along with some material-ui components displayed alongside the table: import React from 'react' import { useTable, useGlobalFilter, usePagination } from 'react-table& ...

Enhance the textarea using Javascript when clicked

I am experimenting with styling my textarea using a combination of JAVASCRIPT and CSS. The goal is to make it expand in size from 20px height to 120px height when clicked, using document.getElementById("tweet_area"). However, I am facing an issue where t ...

Bootstrap's alignment of items is not functioning as anticipated

For my simple webpage, I am using Bootstrap 4 to add a header and footer. However, I am facing an issue where the footer is not displaying at the end of the page. Below is the HTML code I am using. Can anyone please guide me on what to do? html, body ...

Fixing a CSS animation glitch when using JavaScript

I'm facing an unusual issue with my CSS/HTML Check out my code below: a:hover { color: deeppink; transition: all 0.2s ease-out } .logo { height: 300px; margin-top: -100px; transition: all 0.2s ease-in; transform: scale(1) } .logo:hover { transit ...

Utilize HTML to resize image to fit within container

I've encountered an issue while working with Adobe Dreamweaver CS5. I added a swap behavior to an image in an html document, expecting it to pop up at its original size and restore on mouse out. However, the swapped image ends up filling the entire sc ...

What is the best way to manage classNames dynamically in React with Material-UI?

I am wondering how to dynamically add and remove classes from an img tag. My goal is to change the image automatically every 2 seconds, similar to Instagram's signup page. I am struggling to achieve this using the material-ui approach. Below is a snip ...