What is the process for adjusting the text font within a fa-border element?

If you're interested, I have created a site template using only HTML5 and CSS3 which you can find here.

For Font Awesome 5, instead of the SVG with JS version, I opted for the CSS webfont option.

A clever trick I discovered was using

<span class="fas fa-hashtag fa-border" aria-hidden> Lorem ipsum dolor sit amet,</span>
in place of traditional <span> and <h1> tags.

You can see how it looks here.

I am struggling to change the default font. Any suggestions?

P.S. Using

span {font-family: “Font”, sans-serif;}
or
.fa-border {font-family: “Font”, sans-serif;}
did not yield the desired result.

Answer №1

The reason for this issue is the use of the .fas class within your span element, which belongs to the Font Awesome font family.

I recommend wrapping your icon in an <i> tag and then applying the font to the <span>. To add a border, use the fa-border class on the <span> element.

Code Snippet

span {
  font-family: Verdana;
}
<link href="https://use.fontawesome.com/releases/v5.0.6/css/all.css" rel="stylesheet">
<span class="fa-border"><i class="fas fa-hashtag"></i>Lorem ipsum dolor sit amet,</span>

Answer №2

Font-Awesome was initially added to the header, but since it only had one glyph and couldn't render properly, the browser default was used as a replacement.

To resolve this issue, consider targeting the :before element instead

.fa, .far, .fas {
  font-family: "Roboto"; // or any preferred font
}

.fa:before, .far:before, .fas:before {
  font-family: "Font Awesome\ 5 Free";
}

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

Problem with CSS transition on horizontal scrolling list items

I am currently working on a horizontal list with list items. When I hover over the list, it is supposed to expand horizontally to display more information, although this feature has not yet been implemented. However, I am having trouble understanding why ...

problem encountered when inserting data (GET method) in a loop using window.location

I'm currently utilizing sailsjs to extract data from the GET parameter within the URL (mydomain.com/prod_master/addsupp). The specific page is /prod_master/addsupp, designed to receive GET parameters for database insertion. In my Javascript code, I ...

Inject the value of a JavaScript array into an HTML element

Is it feasible to transfer a global javascript array value to an HTML tag, particularly within an img (title) tag? I'm curious if the following is achievable: <img src="_info.gif" height="26" width="37" title=myArray[5]/> If it is possible, p ...

Issue with Navbar collapse button not displaying items on Bootstrap 4.5.0 in combination with Next.js version 9.4.4

I'm currently working on a nextjs demo project where I'm incorporating bootstrap for styling purposes. The initial setup was straightforward as I installed bootstrap using npm and included it in my app.js. import 'bootstrap/dist/css/bootstra ...

How to position an absolute div in the center of an image both vertically and horizontally

Can someone help me figure out how to center a div inside an image? I seem to be having trouble with the positioning and alignment. Any suggestions or advice would be greatly appreciated. Thanks! .template-banner{ width: 100%; height: auto; margin: 0; } ...

The issue of "TypeError: e.fixers is undefined error for prefixfree on dynamically loaded iframes" is arising

My iframe is loaded dynamically with code to run inside it - it's a code playground with a codemirror instance below. One of the pieces of code that runs in the iframe is the prefixfree.min.js from Lea Verou. When the iframe loads or unloads, I encou ...

Start CSS3 Animation Automatically

I am working on a multi-page website with a slider that includes a CSS3 animation featuring the famous rocket animation. Here is the code snippet I used: #outerspace { position: relative; height: 400px; background: #fff; color: #fff; } di ...

Responsive Design: Concealing a Sidebar with CSS

Seeking assistance with optimizing the layout of my app, . It currently displays a menu on the left and a login form in the center, with a graph shown to users upon logging in. Is there a way to configure it so that when accessed on iOS: 1) the left menu ...

What is the best way to align bars at the bottom of a CSS vertical bar chart?

Currently, I am exploring the functionality of two distinct bar charts that I designed using HTML and CSS: one horizontal and the other vertical. Is there a way to shift the bars in my vertical bar chart from the center down to the bottom? https://i.sstat ...

Using Javascript to display different div elements based on the type of mobile device

My goal is to use JavaScript to accomplish the following: 1- Check the mobile device type, if it is an ANDROID device, show the ANDROID_USERS div. If it is an IPHONE device, show the IOS_USERS div. 2- Display the above div only once during the first visit ...

The issue with the left border color not functioning in JavaScript

Attempting to alter the border-left-color property using this script is resulting in a Uncaught SyntaxError: Unexpected token -. Is border-left-color actually supported? Javascript function logoChange() { var description = new Array (); description[0] ...

How can I ensure my button aligns to the left with the element above in Bootstrap?

Here is a JSFiddle link for reference: https://jsfiddle.net/sf4wkyx0/ The alignment of my 'Add' button with the textarea seems slightly off: https://i.sstatic.net/r7lAn.png Both elements are within a container with the class col-2, but the al ...

Tips for optimizing Angular source code to render HTML for better SEO performance

Our web platform utilizes Angular JS for the front-end and node js for the backend, creating dynamic pages. When inspecting the code by viewing the source, it appears like this: For our business to succeed, our website needs to be SEO-friendly in order to ...

SVGs do not display on iPhones

Having some issues with my code - specifically, I have an SVG animation that seems to work on all devices except iPhones. I've been struggling to find a solution. Here is the code snippet for the SVG: <div class="contenuto-svg"> <svg vi ...

Managed the double-click event to select Snap.svg text

I am currently utilizing the snapsvg library for a project where I am implementing the dblclick event to trigger a browser window alert. However, when clicking on the svg canvas, not only does the alert pop up but some text on the canvas also gets selected ...

Angular 9: The instantiation of cyclic dependencies is not allowed

After transitioning from Angular 8 to Angular 9, I encountered an issue with a previously functioning HTTP communication service. The error message now reads: Error: Cannot instantiate cyclic dependency! HttpService at throwCyclicDependencyError (core ...

Does Somebody Possess a Fine Floating Tag?

Some time ago, I came across this floating label that I have been searching for ever since. I experimented with a few that appeared promising and initially worked well, but they ended up presenting their own issues. Some required the mandatory attribute f ...

The curious case of CSS nth-of-type quirks

I am using CSS nth-of-type(even) to organize divs. It usually works fine, but when I send an AJAX request and add new HTML div after another one, the selector starts behaving strangely. .row > .cd-timeline-block-sort:nth-of-type(even) > .cd-timeline ...

SVG failing to display properly

I need to place a close button in the top right corner of my page. Here is the code for the SVG: .icon { width: 24px; height: 24px; /* any changes to the fill attribute have no effect */ fill: currentColor; } <svg class="icon"> &l ...

Guide to positioning a button on top of another button using Vuetify

I'm facing an issue where I want to add a button on a clickable card, but clicking the button also triggers the card click event. Here's my current code snippet: <v-card @click="show = !show"> <v-img src="https://cdn.vuetifyjs.com/im ...