What is the best way to include multiple font styles for different tags?

While working on a website project, the client requested to use Roboto as the main font (by Google). Different styles of Roboto such as Roboto Thin or Roboto Light were used for various elements on the page. However, I utilized the @font-face selector to ensure that the browser displays the text in Roboto. The challenge lies in needing different weights that are not part of the standard Roboto font. If this explanation is unclear, feel free to ask for further clarification or examples.

PS: I came across a similar thread addressing a comparable issue where system fonts were used alongside @font-face. Using @fontface, how do I apply different styles to different font-families?

Answer №1

How can you apply multiple font-faces to different tags?

@font-face {
    font-family: 'Diamond';
    src: url('../fonts/diamond.eot');
    src: url('../fonts/diamond.eot?#iefix') format('embedded-opentype'),
         url('../fonts/diamond.woff') format('woff'),
         url('../fonts/diamond.ttf') format('truetype'),
         url('../fonts/diamond.svg#diamond') format('svg');
    font-weight: normal;
    font-style: normal;
}
@font-face {
    font-family: 'GothicStyle';
    src: url('../fonts/gothic.eot');
    src: url('../fonts/gothic.eot?#iefix') format('embedded-opentype'),
         url('../fonts/gothic.woff') format('woff'),
         url('../fonts/gothic.ttf') format('truetype'),
         url('../fonts/gothic.svg#gothic') format('svg');
    font-weight: normal;
    font-style: normal;
}

apple {
    font-family: Diamond;
}
banana {
    font-family: GothicStyle;
}

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

What is the best way to position an image in the bottom right corner of a fluid div container?

I am struggling to position this icon image at the bottom right hand corner of this div, so that it appears as if the message is originating from the icon's head. Despite my efforts, I have yet to find a definitive solution. https://i.stack.imgur.com ...

AngularJS: Understanding the difference between ng-show and using display:none

I recently encountered a scenario where I needed to hide an HTML element by default using CSS. Here's how I did it: HTML: <div class="box"> </div> CSS: .box { display: none; } However, I wanted to be able to show and hide the elem ...

Connect the mileage tracker to a Datalist or grid view component

I recently downloaded the Odometer Sample from , however, I am facing an issue where only the first element in the Datalist is getting the Odometer display, while others are not displaying it. Here is the snippet of code: <script type="text/javascript" ...

Unable to sort the list items when utilizing the load() function

I have multiple li elements within a ul and I am using the following code to sort them in ascending order based on the data-percentage attribute: $(function() { $(".alll li").sort(sort_li).appendTo('.alll'); function sort_li(a, b) { re ...

Getting the URL of a CSS background image in NodeJS and Express: A step-by-step guide

I've recently learned that using getComputedStyle in a Node environment is not possible due to it being a browser-specific behavior. Despite this, I am still interested in retrieving all background image URLs within Node and downloading them as shown ...

How can I retrieve the value from an input form using jQuery if it returns null?

Despite trying various methods, I have been unsuccessful in retrieving form values using jQuery and sending them in an AJAX GET request. The value keeps showing as null even after spending more than 18 hours on it. Any help would be greatly appreciated. $ ...

Using HTML to position multiple lines of text alongside an image

I have multiple lines of content and hyperlinks. Additionally, there is an image included. I am looking to have the text aligned on the left with the image on the far right, positioned next to the text. While I attempted to use flexblocks to center everyt ...

Ways to adjust image sizes to fill the row with CSS

I am facing an issue with displaying multiple images using flexbox. Whenever an image cannot fit in the same row, it leaves a gap which disrupts the layout. https://i.sstatic.net/bXltY.jpg My goal is to resize these images dynamically so that there are n ...

The functionality of `config.assets.debug = true` fails to

I've encountered an issue with the configuration on development where config.assets.debug = true doesn't seem to work correctly. Instead of having multiple separate JavaScript and CSS file inclusions, I'm getting a consolidated one: <li ...

In order to properly set up Require JS, you will need to configure the JS settings

Is there a way to specify the path from any property inside the require JS config section? We are trying to pass a property inside the config like so: The issue at hand: var SomePathFromPropertyFile = "CDN lib path"; require.config({ waitSeconds: 500 ...

Customize the dynamic options for selecting with Bootstrap

I have been experimenting with the bootstrap select plugin and have run into an issue while trying to dynamically add options using Javascript. Unfortunately, the list always appears empty. Interestingly, when I revert back to using a conventional HTML sel ...

Tips for maintaining the size of an object while resizing a window

My circles are designed to increase in width at regular intervals, and once they reach a certain scale, they disappear and start over. However, every time I resize the screen or zoom in and out, the circle gets distorted into an oval or stretched object. H ...

What is the best way to display a Bootstrap toggle?

I am facing an issue with a Bootstrap toggle in a Handlebars template. When the page initially loads, the toggle is visible, however, after re-templating the Handlebars template that contains the toggle, it disappears. Before Re-Template: Initial code : ...

Adjust Text to Perfectly Fit Button

I am developing a quiz using bootstrap and javascript. One issue I encountered is that the text in the buttons can sometimes be longer than the button itself. This results in the text not fitting properly within the button, making it unreadable on mobile ...

Enable content to be displayed when hovering over it with a mouse in

As a newcomer to JavaScript, I am eager to learn how to add an interactive feature to my menu item. I want to create an info box that pops up when the menu item is clicked, and can also be displayed when hovering over it. Below is the script I have so far, ...

Outlook-2010 does not support the current display

Looking for help styling a page that will be opened in ms-outlook 2010. The issue is that it does not support the display attribute. Anyone have a recommendation for an alternative? One suggestion could be to create a class with properties similar to disp ...

The droplist functionality in jQuery does not seem to be functioning properly within an ASP.NET MVC 5

After adding an external theme to my project and writing a script for listing data in a dropdown list on a separate page, I encountered an issue where the script works on other pages but not on the Layout theme page. HomeController Note: The partial view ...

Troubleshooting Problem with Centering Rows in Bootstrap

I am utilizing the most recent version of Bootstrap 3 to design a website for a friend, but I am encountering a challenge with centering elements on the page. Typically, I would use the following code: .center{ width: 90%; margin: 0 auto; } Howev ...

Create a CSS menu that centers the links

Here is the CSS code I am using for my horizontal menu: nav { height: 40px; width: 100%; background: #F00; font-size: 11pt; font-family: Arial; font-weight: bold; position: relative; border-bottom: 2px solid # ...

Is there a way to retrieve the central anchor point position (x, y) of the user's selection in relation to the document or window?

Is there a way to retrieve the center anchor point position (x, y) of the user's selection relative to the document or window? I have tried using window.getSelection() to get selected nodes, but I am unsure how to obtain their position: See an examp ...