The Wayback Machine - https://web.archive.org/web/20241006010423/https://www.geeksforgeeks.org/tailwind-css-font-weight/
Open In App

Tailwind CSS Font Weight

Last Updated : 17 Jul, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

This class accepts lots of value in tailwind CSS in which all the properties are covered in class form. It is the alternative to the CSS font-weight property. This class is used to set the weight or thickness of the font being used with the HTML Text. The font-weight applied will depend on the font-family used in the browser. For example, some font-family is available only in specific weights.

Font weight classes:

  • font-thin: This class sets the font-weight to 100.
  • font-extralight: This class sets the font-weight to 200.
  • font-light: This class sets the font-weight to 300.
  • font-normal: This class sets the font-weight to 400.
  • font-medium: This class sets the font-weight to 500.
  • font-semibold: This class sets the font-weight to 600.
  • font-bold: This class sets the font-weight to 700.
  • font-extrabold: This class sets the font-weight to 800.
  • font-black: This class sets the font-weight to 900.

Note: Change the weight in the component with the required weight mentioned above.

Syntax:

<element class="font-{weight}">...</element>

Example:

HTML
<!DOCTYPE html>
<html>

<head>
    <link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet">
</head>

<body class="text-center mx-4 space-y-2">
    <h1 class="text-green-600 text-5xl font-bold">
        GeeksforGeeks
    </h1>

    <b>Tailwind CSS Font Weight Class</b>

    <div class="mx-24 bg-green-200">
        <p class="p-2 text-justify">
            font-thin:
            <span class="font-thin pl-10">
                A Computer Science portal for Geeks
            </span>
        </p>

        <p class="p-2 text-justify">font-normal:
            <span class="font-normal pl-4">
                A Computer Science portal for Geeks
            </span>
        </p>

        <p class="p-2 text-justify">font-medium:
            <span class="font-medium pl-2">
                A Computer Science portal for Geeks
            </span>
        </p>

        <p class="p-2 text-justify">font-bold:
            <span class="font-bold pl-8">
                A Computer Science portal for Geeks
            </span>
        </p>

        <p class="p-2 text-justify">font-black:
            <span class="font-black pl-6">
                A Computer Science portal for Geeks
            </span>
        </p>
    </div>
</body>

</html>

Output:


Previous Article
Next Article

Similar Reads

CSS font-weight Property
The CSS font-weight property is used to set the weight or thickness of the font used with HTML text. The font-weight applied will depend on the font family used and the browser. Some font families are available only in specific weights. Understanding how to use the font-weight property effectively can greatly enhance the visual appeal and readabili
5 min read
SVG font-weight Attribute
The font-weight attribute refers to the boldness or lightness of the glyphs used to render the text, relative to other fonts in the same font family. Syntax: font-variant="variation" Attribute Values: Default value: Default value is normal.other value: Other values are bold, bolder, lighter.We will use the font-weight attribute for setting the weig
1 min read
How to change font-weight of a text using JavaScript ?
In this article, we will set the font-weight of a text dynamically using JavaScript. Ti change the font weight dynamically, we use HTML DOM Style fontWeight property. Syntax: object.style.fontWeight = "value" Property Values: normal: The font weight is the default value.lighter: The font weight is the lighter than normal.bold: The font weight is bo
1 min read
Bootstrap 5 Text Font weight and italics
Bootstrap 5 Text Font weight and italics classes are used to manipulate text weight and text style. There are several classes to do so. In this article, we will see the use of each class that has been used in the examples code. Font weight and italics classes: fw-bold: This class is used to make the text bold.fw-bolder: This class is used to make t
2 min read
How to change font-weight of a canvas-type text using Fabric.js?
One can change the font-weight of a canvas-type using Fabric.js which adds versatility and style to the web applications and graphic design. It provides an efficient method to manipulate text properties such as font weight dynamically, which enhances the presentation and readability of the text elements rendered within the canvas ApproachOne can us
3 min read
How to change the Font Size and Color of Text in Tailwind CSS ?
To change the font size and colour of text in Tailwind CSS, we can use the following Utility Classes. Changing Font SizeUse the text-[size] classes to set the font size. Replace [size] with a size identifier like xs, sm, md, lg, xl, or numerical values. <p class="text-lg">This text has a large font size.</p>Changing Text ColorUse the te
1 min read
Tailwind CSS Font Family
This class accepts a lot of font names in tailwind CSS in which all the properties are covered in class form.  It is the alternative to the CSS font-family property. This class is used to specify the font of an element. It can have multiple fonts as a backup system i.e. if the browser does not support one font then the other can be used. Font famil
2 min read
Tailwind CSS Font Size
This class accepts lots of value in tailwind CSS in which all the properties are covered as in class form.  It is the alternative to the CSS font-size property. This class is used to set the font size of the text in an HTML document. Font size classes: text-xs: This class defines the text size as extra small.text-sm: This class defines the text siz
2 min read
Tailwind CSS Font Style
This class accepts lots of value in tailwind CSS in which all the properties are covered as in class form. It is the alternative to the CSS font-style property. If we want to give design to any type of text then we can make the use of Tailwind CSS font style class. It helps to make a better user experience. Font Style classes: italicnon-italicitali
2 min read
Tailwind CSS Font Smoothing
This class accepts lots of value in tailwind CSS in which all the properties are covered as in class form.  It is the alternative to the CSS font-smooth property. This class is used for controlling the font smoothing of an element. Font smoothing classes: antialiasedsubpixel-antialiased Note: This class does not show any effect. antialiased: This u
1 min read
Tailwind CSS Font Variant Numeric
This class accepts lots of values in tailwind CSS in which all the properties are covered in class form.  It is the alternative to the CSS font-variant-numeric property. This class is used to control the usage of alternate glyphs. This is done in terms of units or markers such as numbers or fractions. Font variant numeric classes: normal-nums: Usin
2 min read
How to set default font color using Tailwind CSS ?
In Tailwind CSS, setting the default font color refers to establishing a consistent text color across the entire webpage or specific elements. Tailwind offers utility classes to define font colors, ensuring uniformity in the design without the need for custom CSS styling. Here we have some common approaches : Table of Content Using the global utili
3 min read
How to Customize the Font Size in Tailwind CSS ?
Customizing font size in Tailwind CSS involves using the text-[size] utility class, where [size] can be predefined size identifiers like xs, sm, md, lg, xl, or numerical values. Additionally, you can extend the default font sizes in the configuration file for more customization. Syntax<p class="text-lg"> This text has a large font size. </
2 min read
How to use font from local files globally in Tailwind CSS ?
Tailwind CSS is a utility-first framework that comes with a wide range of pre-configured styles. Among these are default font families such as sans, serif, and mono, which offer system fonts like Arial, Times New Roman, and Courier New. These fonts can be easily applied to HTML elements by adding the corresponding class names, for example: <p cl
3 min read
How to add multiple font files for the same font ?
@font-face In CSS, it is a rule that specifies a custom font. This allows us to expand our scope beyond the web-safe fonts. In this rule, @font-face must be first defined and then webpage elements can be made to refer to it as required. Objective: To define multiple font files under the same font name. Framing this in a more understandable way, wha
2 min read
What is the use of the tailwind.config.js file in Tailwind CSS ?
The tailwind.config.js file in Tailwind CSS serves as a central configuration hub for customizing the framework. It allows you to define colors, fonts, breakpoints, and more, tailoring Tailwind to fit your project's specific design and functionality requirements. Syntax:/** @type {import('tailwindcss').Config} */module.exports = { content: [], them
1 min read
Can you change the base font-family in Tailwind config?
In this article, we will see how to change the base font family in the tailwind config. The base font-family in the Tailwind config can be customized by modifying the theme section in your configuration file ( tailwind.config.js). For this, we simply need to open your tailwind.config.js file, and then locate the theme section and add or modify the
3 min read
Storybook-tailwind. How should I add tailwind to storybook
In this article, we will guide you through the process of adding Tailwind CSS to Storybook to enhance your UI development. Storybook is an open-source UI that helps developers create reusable, organized UI components with proper documentation independently. Tailwind CSS is basically a utility-first CSS framework for building rapid custom UI. Prereq
2 min read
Which CSS framework is better Tailwind CSS or Bootstrap ?
In this article, we will see which CSS framework is better tailwind CSS or bootstrap. Both are widely used CSS frameworks for styling the front end. We will understand each one of them in detail. Both frameworks have their own pros and cons so it depends upon the type of application you are going to build and accordingly you can choose the best fra
5 min read
How to Add a @tailwind CSS Rule for CSS Checker ?
Tailwind CSS is basically a Utility first CSS framework for building rapid custom UI. It is a highly customizable, low-level CSS framework that gives you all of the building blocks that you need. Also, it is a cool way to write inline styling and achieve an awesome interface without writing a single line of your own CSS. In this article, we will ex
4 min read
How to use CSS Animations with Tailwind CSS ?
Tailwind CSS classes are used to style elements and apply animations effortlessly. Utilize Tailwind's animation utility classes to add dynamic visual effects. Combine Tailwind CSS with custom CSS animations for versatile and engaging web designs. Table of Content Tailwind CSS Animation Utility ClassesCSS Animations with Tailwind CSS and JavaScriptT
3 min read
CSS font-stretch Property
The font-stretch property in CSS is used to set the text wider or narrower. This property is not working any font. Its only work when font family has a width-variant face. Syntax: font-stretch: normal|ultra-condensed|extra-condensed|condensed| semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded; Default Value: normal Property Values
2 min read
CSS | Generic font-family collection
The font-family property is used to set the font of text in HTML document. The different font-family is used to create attractive web pages. There are many fonts available to choose from font pool like Google fonts, Adobe fonts, etc and require font API linking and customization. Generic font families mainly come under following categories which ar
4 min read
Foundation CSS Global Style Font Sizing
Foundation CSS offers a global font scaling strategy that enables web developers to specify uniform font sizes across their websites. It is a front-end framework that offers a library of pre-built components, styles, and templates. Foundation CSS's global style font scaling method allows developers to specify font sizes for all components, includin
5 min read
Which property is used as shorthand to specify a number of other font properties in CSS ?
In this article, we are going to discuss a property that is used as shorthand to specify different font properties. The font property is a shorthand property for various font-related properties. Shortening the code in Cascade Style Sheet (CSS) helps to specify all individual related properties into a single property. The font property is used as sh
2 min read
How to Add Apple's new San Francisco font on a Webpage using CSS ?
The newly created Apple's San Francisco font is comfortable for human eyes as per research. Normally Apple's font can not be used on any webpage through CSS. These kind of fonts are in-build in Apple's product but the new San Francisco font can be used in any web content. Mr. Craig Hockenberry introduces the procedure of how we can use that font on
2 min read
How to change the font-color of disabled input using CSS ?
In this article, we are going to learn how to change the font-color of disabled input. There is a method to solve this problem, which is discussed below: Approach: With adding basic CSS property we are able to change the font-color of a disabled input. The disabled input element is unusable and un-clickable. This is a boolean attribute. Here using
2 min read
CSS | font-display property
While using web fonts, the text will be invisible until either web font is loaded or three seconds are passed, at which point the fallback font is used. Font-display allows customizing how web fonts are displayed when the page is being rendered. It is applied using @font-face rule which defines custom fonts in a style sheet. Syntax: @font-face { fo
2 min read
CSS font-variant-numeric Property
The font-variant-numeric property of CSS is used to control the usage of alternate glyphs. This is done in terms of units or markers such as numbers or fractions. in other words, the font-variant-numeric property controls the display of numeric characters in a font. It allows you to specify the stylistic variations for numeric digits, such as linin
3 min read
CSS font-variant-position Property
The font-variant-position of CSS is used to alter the position of the font as a superscript, subscript, or normal font. These are positioned relative to the baseline of the font, which remains unchanged. Syntax: font-variant-position: normal | sub | super Property values: Normal: Normal deactivates superscript and subscript glyphs. If not present a
2 min read