I'm having trouble with my Montserrat font not displaying the right font style

I'm having an issue with my Montserrat font not displaying correctly. It appears as the standard style instead of the intended one. I have tried adding the specific style in the link, like this:

<link href="https://fonts.googleapis.com/css?family=Montserrat|Ubuntu" rel="stylesheet">

However, I don't want all elements to have the same style. I specifically want my h1 heading to be styled in Montserrat Black, so I added the following CSS:

h1 {
 font-family: "Montserrat-black";
}

Unfortunately, I am not seeing the desired effect. If I try adding a style for black like this:

<link href="https://fonts.googleapis.com/css?family=Montserrat:black|Ubuntu" rel="stylesheet">

The black style ends up being applied to the entire page rather than just h1. Can someone please assist me with how to achieve the result I'm looking for?

Answer №1

Personalize your typography with a variety of font options available on Google Fonts and adjust the font-weight to 300, 500, 700, or 900:

https://i.sstatic.net/xisTp.png

h1 {
  font-family: 'Montserrat', sans-serif;
  font-weight: 900; /* black */
}
  
  <link href="https://fonts.googleapis.com/css?family=Montserrat:400,500,700,900|Ubuntu:400,500,700" rel="stylesheet">
  
  <h1>
    Lorem ipsum dolor sit amet.
  </h1>

Answer №2

When choosing font weights from Google Fonts, options like Montserrat:400,900 are commonly selected. To utilize these weights in CSS, simply specify them in your styling.

body {
  font-family: 'Montserrat', sans-serif;
}

h1 {
  font-weight: 900; /* Black */
}
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,900" rel="stylesheet">

<p>
  Normal body text
</p>

<h1>Black/ 900</h1>

Answer №3

If you're working with both Bootstrap and CSS, the order in which they are written in the HTML code matters. I encountered a similar issue where my CSS code was placed before Bootstrap in the code.

If your custom styles are not taking precedence over the bootstrap styles, simply rearrange the order of your stylesheet links so that your custom stylesheet comes after the bootstrap CDN link:

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="css/styles.css">

By doing this, you first load the default bootstrap styles, allowing you to then customize or override specific components using your own custom CSS.

Answer №4

To achieve the desired font size, it is important to specify both the font family and the font weight. Here is an example:

 h1{
font-family: 'Montserrat', sans-serif;
font-weight: 900;
 }

Additionally, ensure that if you are utilizing an external CSS file, the link to it should be placed after all script and link tags within the head tag. Essentially, it should be located just above the end of the head tag.

  <link rel="stylesheet" href="css/styles.css">
  </head>

Answer №5

Google Fonts has undergone a major transformation. Now, adding font weight is essential. The default font family has been updated. No additional changes are necessary, but setting the font weight to very bold or Black style is recommended.

h1 {
    font-family:  'Montserrat', sans-serif;
    font-size: 3rem; /*Optional*/
    line-height: 1.5; /*Optional*/
    font-weight: 900;
}
  <!--All weights of Montserrat & Ubuntu included below. You can customize as needed-->

  <link href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&family=Ubuntu:ital,wght@0,300;0,400;0,500;0,700;1,300;1,400;1,500;1,700&display=swap" rel="stylesheet">

  
  <h1>Discover fascinating new canine companions in your area.</h1>
  <p>Normal text appears much smaller compared to the desired Montserrat-Black style.</p>

Answer №6

The font goes by the name of Monserrat, not Monserrat-black.

h1 {
  font-family: 'Montserrat', sans-serif;
}
<link href="https://fonts.googleapis.com/css?family=Montserrat|Ubuntu" rel="stylesheet">

<h1>This is a title, styled with the h1 tag</h1>

<p>This is a paragraph, not styled with the h1 tag</p>

Check out the code snippet from the small popup in the bottom-right corner on Google Fonts: https://i.sstatic.net/TC1sa.png

Answer №7

Unfortunately, the font-family style for "Montserrat-something" is no longer functioning properly.

To fix this issue, please make sure to use: font-family: "Montserrat"; font-weight: specify the desired font weight;

Answer №8

The positioning of your external stylesheet link within the HTML document is essential. To effectively modify the default styles, make sure to place your customized stylesheet as the last link in the head section.

This should result in the desired outcome.

Answer №9

This solution may not be effective. If you are facing this issue in Angela Yu's Web Development Bootcamp, make sure to refer to section 71 for guidance. You will find specific instructions to utilize

h1 
{
    font-family: 'Montserrat-Black, sans-serif';
    font-size: 3rem;
    line-height: 1.5; 
    font-weight: 900;
}

Alternatively, to replicate the tutorial's example, you can also use font-weight: bold;

Answer №10

It's important to ensure that the CSS file link is placed below the Bootstrap link for everything to work correctly.

Answer №11

Google no longer supports the

font-family: 'Montserrat-Black', sans-serif;
. To continue using that font, please update your code with the following:

font-family: 'Montserrat', sans-serif;
font-weight: 900;

If this solution does not work, ensure that your CSS Style Sheet link is placed after the bootstrap and any other CSS Stylesheet Link.

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

CSS: customize the color of a highlighted row within a table

I am struggling to implement a new feature in my table. Specifically, I want the row to change color (#FFCF8B) when a user selects it. I attempted using #newspaper-b tbody tr.selected td, but it was not successful. #newspaper-b { border-colla ...

Retrieve properly formatted text from the editor.document using the VSCode API

I have been working on creating a personalized VSCode extension that can export the current selected file contents as a PDF. Although PrintCode exists, it does not fit my specific needs. The snippet of code I am currently using is: const editor = vscode.w ...

Issue with input width percentage not functioning as expected

Is there a special method to specify the width of an input field in CSS without it extending beyond the container? I want my input field to be 98% of the container's width, but when I set it to that, it goes off the screen. This is the HTML code I am ...

Centering an image on a webpage using CSS

Here is the code I am using for displaying my image: return <div class="imgContainer"><img src={broomAndText} alt="broomAndText" /></div> In my css file, I have included the following styling: .imgContainer { tex ...

Adaptable background image - smoothly resize/reposition

Is there a way to smoothly resize my background image instead of it jumping abruptly? Currently, when using media queries, the background image goes from 900px to 300px in height instantly at a certain point. How can I make this transition more gradual? ...

Unable to find component: "wrestler-choice-box". If this is a built-in custom element, please ensure it is not included in component resolution

In my attempt to achieve a specific goal, I have an array of data that I want to incorporate into my HTML document along with a Vue component containing a template. My intention is to utilize list rendering so that the names and images from this array bind ...

best method for embedding javascript code within html (within a script tag)

In my quest to create dynamic HTML using jQuery and insert it into a specific div on my website, I encountered an issue. Specifically, I am attempting to generate an anchor element where both the href and label are determined by JavaScript variables. Here ...

Tips for preventing harmful messages in a chat room app

As I am working on a chat room website, users are able to input any content they want into the entry field and then send it to all online users. However, I have concerns about security - what if malicious individuals try to inject harmful HTML or JavaScrip ...

Expanding CSS styles on hover

When my mouse pointer moves out of the red color box, it still triggers the hover function. However, I only want the hover effect to work within the red color box and hide the menu when it's outside the box. This is the source code from JSfiddle: htt ...

Exploring the Four Quadrants of CSS

When I use this fiddle https://jsfiddle.net/8kh5Lw9r/, I am getting the expected four quadrants on the screen. https://i.sstatic.net/O5Q6D.png HTML <div id="one"><p>One</p></div> <div id="two"><p>Two</p></div ...

Search field in DataTables appears to be misaligned

I'm in the process of developing a small website using JSP and DataTables (currently only for the first table). Here's what I have so far: As you can observe, there seems to be an alignment issue with the search field position. I'm n ...

Mobile Exclusive Bootstrap 5 Collapse Feature

Trying to implement the default collapse feature in Bootstrap 5x specifically for mobile devices. Despite setting up a CSS media query as per my research, the .collapse function doesn't seem to work as intended? The goal is to have the collapsed DIV ...

Ensuring Safe Data Storage for an Angular 2 Project with Local Storage

One thing that worries me is the possibility of a hacker accessing the developer's console or local storage to alter user data, like the company name, and then gaining unauthorized access to my database. Here's a closer look at the issue: Curren ...

Exploring the Layout Options of Twitter Bootstrap 3

Can someone help me achieve this specific layout design using Bootstrap 3? --------------------------------------------------------- | | | | | ...

The border-radius property in Bootstrap buttons causes unwanted white border artifacts to appear

Strange anomalies in the borders of my Bootstrap buttons caught my attention recently. Upon further investigation, I realized that this issue is not linked to my custom styles or theme, as the artifacts can also be seen on the Bootstrap button documentatio ...

Printing content from a web page using window.print() function in a form using javascript and angular

Within my HTML code lies a form, complete with a variety of fields: <div class="card-body" id="print"> <form [formGroup]="form"> <div class="text-muted" *ngFor=" ...

Can the value in a JavaScript object be updated dynamically when a button is clicked?

In my JavaScript code, there is an object named annualPlan. Whenever a user submits the HTML form for a specific month, I aim to update the value in the object for that particular month accordingly. For instance, if someone submits August 21 and 200, I w ...

Various CSS regulations for various languages/modes in CodeMirror

Can CodeMirror highlight different languages separately in multi-mode? .cm-s-default .cm-string-html {color: blue;} .cm-s-default .cm-string {color: #170;} Usually, CodeMirror applies the same class names for strings, comments, and other objects in all l ...

Adjustable block with excess content

Forgive me if this question seems basic, but I'm not very familiar with CSS. I have a table with two columns that need to be equally sized and responsive when the page is resized. The header isn't an issue since it only contains a few words in ...

Ways to capture all characters (including special characters like ) using Visual Studio Regex

What I'm Hoping to Achieve: I am looking to reformat multiple HTML files that have a similar structure in Visual Studio. While the HTML sections may vary in length, they all begin with a <div id="some_id"> tag and do not contain any other <d ...