How can the styles of Google Fonts be affected when the style name is appended to the font family?

When I try to use the Black style for the Montserrat font using this format:

font-family: 'Montserrat-Black';

It doesn't work as expected. Instead, I have to use the following:

font-family: 'Montserrat';
font-weight: 900;

Why is it that I can't simply use the style name in the font family declaration?

Answer №1

The reason for this issue is that the system is only familiar with the font-family "Montserrat". It does not recognize the font-family "Montserrat-Black", but it is aware that it should load the font "Montserrat-Black" when the user specifies the font-family "Montserrat" with the attribute "font-weight: 900".

<style>

@font-face {
  font-family: "Montserrat-Black";
  src: local(Montserrat-Black);
}

</style>

<div style="font-family: 'Montserrat-Black'">Test</div>
<div style="font-family: 'Montserrat'">Test</div>

To resolve this issue, you can utilize font-face in your code.

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 shift a block to the left when the screen size is changed

My div block has text overlapping the image, and when I resize the screen, the block with the text gets smaller but stays in the same position. I want to move the block to the left side while resizing the screen so that the entire block fits on the screen. ...

Arrange pictures on top of one another with accuracy in Bootstrap

Looking for a way to stack two images precisely on top of each other. However, the top image (the circle) keeps moving around unpredictably. Both images are within a responsive grid setup and the base image should always remain centered. Let's say ...

Position an element to the right inside its parent container with varying width in Internet Explorer 7 or earlier

I am trying to align a button to the right edge of a table inside a container-div that has no set width. The goal is to have the button float on the right side of the table, lining up with its right edge. While my current approach works in most browsers, i ...

Serve the mobile version to mobile visitors and the desktop version to all other visitors

Can someone please explain to me how I can display the Mobile Version of a website when visiting on my phone, and the Desktop Version when viewing on anything larger than 500px? I have separately created both a Mobile Website and a Desktop Website. Is it ...

Issue with interactive rows in a table ( Rails Version 4 )

I am encountering an issue with a table that is linked to a customer show page _table.html.erb <table class="table table-striped table-bordered table-hover table-condensed"> <thead> <tr> <th width="50"><%= sort_link ...

The border styling for top and bottom of table rows in Bootstrap seems to be malfunctioning

I am trying to format my table to look like the one shown in https://i.sstatic.net/FEPyL.jpg My goal is to add top and bottom borders to each row (tr) of my table, similar to what is depicted in the image. While I managed to get one border working, the ot ...

Unpredictable Behavior of CSS Transition with JS createElement() Function

I'm using JavaScript to create a div element and I'm adding the CSS property transition: .5s linear top; When the user clicks on the element (onmousedown event), it is supposed to smoothly move to the top of the screen and then be deleted using ...

Aligning text vertically alongside an image

Looking for some help with aligning the blue title on my website (under the "about us" section) with the Norway flag positioned to its left. I've attempted adjusting the padding-bottom and margin-bottom to shift the title up a few pixels, but it didn ...

Utilize @font-face when saving a webpage

I've been experimenting with @font-face to embed a custom font, but I've noticed that when saving the page locally on my computer, the font is not being saved along with it. This issue has occurred consistently across Firefox, Chrome, and Safari. ...

What is the preferred choice: using camelCase in CSS with Styled Components or Emotion for standard React development?

When I'm coding with React Native, I use the styled properties that follow most of CSS syntax and are formatted in camel case. For instance: //... <Component style={styles.container} /> //... const styles = StyleSheet.Create({ ...

Differences between using CSS properties and AngularJS filters:CSS properties

When working on an angularjs application, one task may be to convert a string to uppercase. There are 2 options available to achieve this, both yielding the same result. However, it is important to consider the scenarios in which one option may be preferre ...

Press the button in an HTML document to activate JavaScript

What could be the issue with my code? I have a button in HTML <a class="btn btn-warning btn-mini publish-btn" href="#" data-rowid="@computer.id" data-toggle="modal" data-target="#myModal">Outdated</a> and my modal <fieldset style="text-al ...

Chrome shows different height for various input types such as time and number

Having some trouble with input elements of different types and varying heights. For example, in Chrome the input type "time" appears taller than type "number." See the simplified illustration here: http://jsfiddle.net/4jteqy1f/ HTML <article class="se ...

The fixed position element appears to be failing to stay fixed in Google Chrome

Something strange is happening with a fixed position element in Chrome. It is still scrolling with the page even though it should be fixed. To better understand the issue, you can view it on the live site In Firefox and even IE, the "Block 1 Block 2 Block ...

How to design a trapezium shape using CSS and HTML

While there are many tutorials available for creating Trapezoids with CSS3, I am interested in making a four-sided shape where none of the sides are parallel (trapezium), similar to the one shown in the image below. Can this be achieved? ...

Exploring the world of SCSS by manipulating variables and arrays

Working with gulp for sprite creation, I encountered an issue with one of the images. $s-ico-webdesign: '442px', '0px', '-442px', '0px', '60px', '60px', '538px', '519px', &apo ...

How can you implement a transform transition toggle when a user clicks on an element

Check out this CodePen example for a cool overlay animation: https://codepen.io/pen/MoWLrZ Experience the unique animation of two overlays as you click for the first time. However, on the second click, watch as both overlays seamlessly return to their ori ...

Is there a way to ensure that the JSON data and the image appear on the same row with some spacing between them?

Trying to display JSON data with images and text side by side but facing issues where the text wraps below the image instead. How can I fix this layout to show text next to the image? Flex-wrap property doesn't seem to work as expected. function for ...

Having trouble with custom CSS <li> positioning within a media query, it's not performing as anticipated

I have customized the alignment of li tags for a CSS media query. Take a look at this JFiddle to see how it should appear: https://jsfiddle.net/4fwx7rbj/1/ The li elements are centered within their container, and the text is aligned with the list images. ...

The process of loading a unique home page based on the screen size of the device

Looking for assistance on dynamically loading different home pages based on screen size. Any suggestions? For instance, if the screen size is less than 960px, I would like to show the default landing page as index1.html and if the screen size is greater t ...