Introduction:
You can define the weight by using the existing keywords or 100-based multiples up to 900. The font’s thickness grows proportionally with the number.
Syntax: font-weight: normal | bold | lighter | bolder | number | initial | inherit | unset;
Regular, bold, lighter, bolder, bolder, and number are universal property values in the above syntax, but initial, inherit, and unset are global values.
CSS font-weight is one of the many properties you can use to style fonts on your web page. It allows you to control the weight or boldness of a font. This complete guide will show you how to use font weight and tips for getting the most out of it.
We will also cover some of the browser differences when it comes to applying different weights. So, whether you are new to CSS or want to learn more about using font weight, read on!
What does “Font Weight” refer to?
A cursed text generator is a type of tool that generates text that is meant to be disturbing, unsettling, or just plain weird. It often uses a combination of strange fonts, unusual symbols, and eerie formatting to create a sense of unease in the reader. Cursed text generators have become popular in recent years as a way to add a creepy or ominous touch to social media posts, memes, and other online content. Some people enjoy using them for fun, while others use them as a way to express their dark thoughts and emotions. However, it’s important to be aware that some cursed text generators may contain content that is offensive or triggering, so it’s important to use them responsibly and with caution.
What are the Property Values for Font Weights in CSS?
Using this syntax, the property values indicate:
- Normal: It indicates the font’s default average weight. 400 is the numerical equivalent of the standard keyword.
- Bold: This attribute value contributes to the definition of a bold typeface. 700 is the numerical equivalent of this feature.
- Lighter: This property value is linked to the font weight of the parent class. Using this keyword, one can reduce the font’s weight by one level compared to its parent class.
- Bolder: Like the lighter property value, bolder is related to the font weight of the parent class. However, this term will increase the font weight by one level rather than decrease it.
- Number: Instead of using the term “number” as the property value, use the numbers 100, 200 and 900. An alternative number is used if the weight for a requested number is unavailable for a certain font family.
What are the Global Values for Font Weights in CSS?
In addition to the typical property values, CSS font weights also support global values.
- Initial: The initial keyword resets the font-weight property to its default value.
- Inherit: This global setting will set the element’s font weight to the value it received from its parent class.
- Unset: This resets the font-weight property to the value inherited from the parent class, if available. The original default value will be applied if the weight is not derived from the parent class.
What Must You Know Regarding the Use of Numerical Values?
Although there are real numerical numbers such as 100, 200, 300, 400, 500, 600, 700, 800, and 900 that you may use to specify the “boldness” in the displayed text, the actual outcome is likely to be decided by what font you choose in your CSS. These numerical values are as follows: 100, 200, 300, 400, 500, 600, 700, 800, and 900.
Not all online fonts, sometimes known as “font families,” were designed with various bold iterations from the beginning. In practice, most typeface families offer little more than a handful of different weights. When weight is supplied for which there is no face, the system will use a look associated with a weight close to the specified consequence.
However, the utilization of font-weight also has a few drawbacks to consider. For instance, if you’re looking for a uniform layout or brand image throughout your website and all of your links are blue, your text is changing weights for different functions (for instance, buttons are bolder than body text). It might be challenging for visitors who use screen readers or other accessibility devices to navigate your site without assistance from a sighted person since they won’t know what kind of material they should focus on while engaging with the website.
The numerical values are as follows:
100 – Thin
200 – Extra Light (Ultra Light)
300 – Light
400 – Normal
500 – Medium
600 – Semi Bold (Demi Bold)
700 – Bold
800 – Extra Bold (Ultra Bold)
900 – Black (Heavy)
Comparable Font Weights for Lighter and Bolder Values
Depending on the font-weight inherited from the parent class, lighter or bolder keywords can increase or reduce the thickness. The following table depicts the absolute weight chosen depending on the inherited value.
Inherited Value | Bolder | Lighter |
100 | 400 | 100 |
200 | 400 | 100 |
300 | 400 | 100 |
400 | 700 | 100 |
500 | 700 | 100 |
600 | 900 | 400 |
700 | 900 | 400 |
800 | 900 | 700 |
900 | 900 | 700 |
Note: Only 100, 400, 700, and 900 are considered when changing to a relative typeface, regardless of the font family.
Illustration of Font Weight in CSS
In this example, all standard property values will be used.
<!DOCTYPE html>
<html>
<head>
<title>Center example</title>
</head>
<body>
<p style=”font-weight: normal;”>Normal font</p>
<p style=”font-weight: bold;”>Bold font</p>
<p style=”font-weight: lighter;”>Lighter font</p>
<p style=”font-weight: bolder;”>Bolder font</p>
<p style=”font-weight: 100;”>100 weight</p>
<p style=”font-weight: 200;”>200 weight</p>
<p style=”font-weight: 300;”>300 weight</p>
<p style=”font-weight: 400;”>400 weight</p>
<p style=”font-weight: 500;”>500 weight</p>
<p style=”font-weight: 600;”>600 weight</p>
<p style=”font-weight: 700;”>700 weight</p>
<p style=”font-weight: 800;”>800 weight</p>
<p style=”font-weight: 900;”>900 weight</p>
</body>
</html>
The Output will be –
Use Case scenarios of Font-Weight.
When it comes to style, there will be moments when you will want to make your content stand out more, and there will also be instances when you wish to make it less visible.
When you want to highlight terms in your web page that hint at almost being subliminal, you can please the eye by making the font text less dramatic, this can be done by adjusting your font size.
When to use a specific font weight and when not to use it?
The font-weight property of CSS is often utilized to draw focus and attention to the text that is being displayed. They are also frequently used to highlight a particular word or phrase on the page to attract readers’ attention. The third type of font is the “bolder” font.
These are a more prominent font-weight than the standard, and they place an even greater focus on drawing attention to themselves. Be sure that your design has sufficient space for the bolder fonts you intend to use before incorporating them into the layout. Bolder fonts typically take up more page space than standard fonts.
Final Words
Font weight is a style property in CSS that allows you to control the boldness or lightness of your text. You can use numerical, keywords, or relative values to change the font weight.
So there you have it, The Complete Guide to CSS Font-Weight. We’ve looked at what font weight is, how you can use numerical values to specify the weight of your text, and some global and property matters that you should be aware of.
We’ve also looked at using numerical values and comparing different font weights for lighter and bolder text. Hopefully, this guide has helped you better understand how to control the weight of your fonts using CSS. And if you’re developing a new website and want to make sure you’re making the proper choices, this article will significantly assist you.
FAQs
1. What is regular font-weight CSS?
The average font weight in CSS is 400. It is crucial to keep in mind that only four font weights are taken into consideration when working with relative weights: thin (100), normal (400), bold (700), and heavy.
2. How can I alter the weight of the text in CSS?
The numerical values are as follows:
100 – Thin.
200 – Extra Light (Ultra-Light)
300 – Light.
400 – Normal.
500 – Medium.
600 – Semi Bold (Demi Bold)
700 – Bold.
800 – Extra Bold (Ultra Bold)
3. What exactly does “font-weight 400” refer to?
400 is considered to be expected. 500 – Medium. 600 – Semi Bold 700 – Bold. 800 – Extra Bold
400 is also considered the standard font-weight.
4. What is font family in CSS?
The font-family property of an element indicates the typeface. As a “fallback” method, the font-family attribute can simultaneously store numerous fonts’ names. If the browser cannot display the first font, it will go to the following font in the list.
Author Bio:
I am Korra Shailaja, Working as a Digital Marketing professional & Content writer in MindMajix Online Training. I Have good experience in handling technical content writing and aspire to learn new things to grow professionally. I am an expert in delivering content on the market demanding technologies like Mulesoft Training, Dell Boomi Tutorial, Elasticsearch Course, Fortinet Course, PostgreSQL Training, Splunk, Success Factor, Denodo, etc.