- CSS Tutorial
- CSS - Home
- CSS - Introduction
- CSS - Syntax
- CSS - Selectors
- CSS - Inclusion
- CSS - Measurement Units
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Border Block
- CSS - Border Inline
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursor
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS - Inline Block
- CSS - Dropdowns
- CSS - Visibility
- CSS - Overflow
- CSS - Clearfix
- CSS - Float
- CSS - Arrows
- CSS - Resize
- CSS - Quotes
- CSS - Order
- CSS - Position
- CSS - Hyphens
- CSS - Hover
- CSS - Display
- CSS - Focus
- CSS - Zoom
- CSS - Translate
- CSS - Height
- CSS - Hyphenate Character
- CSS - Width
- CSS - Opacity
- CSS - Z-Index
- CSS - Bottom
- CSS - Navbar
- CSS - Overlay
- CSS - Forms
- CSS - Align
- CSS - Icons
- CSS - Image Gallery
- CSS - Comments
- CSS - Loaders
- CSS - Attr Selectors
- CSS - Combinators
- CSS - Root
- CSS - Box Model
- CSS - Counters
- CSS - Clip
- CSS - Writing Mode
- CSS - Unicode-bidi
- CSS - min-content
- CSS - All
- CSS - Inset
- CSS - Isolation
- CSS - Overscroll
- CSS - Justify Items
- CSS - Justify Self
- CSS - Tab Size
- CSS - Pointer Events
- CSS - Place Content
- CSS - Place Items
- CSS - Place Self
- CSS - Max Block Size
- CSS - Min Block Size
- CSS - Mix Blend Mode
- CSS - Max Inline Size
- CSS - Min Inline Size
- CSS - Offset
- CSS - Accent Color
- CSS - User Select
- CSS Advanced
- CSS - Grid
- CSS - Grid Layout
- CSS - Flexbox
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Paged Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS - Image Sprites
- CSS - Important
- CSS - Data Types
- CSS3 Tutorial
- CSS3 - Tutorial
- CSS - Rounded Corner
- CSS - Border Images
- CSS - Multi Background
- CSS - Color
- CSS - Gradients
- CSS - Box Shadow
- CSS - Box Decoration Break
- CSS - Caret Color
- CSS - Text Shadow
- CSS - Text
- CSS - 2d transform
- CSS - 3d transform
- CSS - Transition
- CSS - Animation
- CSS - Multi columns
- CSS - Box Sizing
- CSS - Tooltips
- CSS - Buttons
- CSS - Pagination
- CSS - Variables
- CSS - Media Queries
- CSS - Functions
- CSS - Math Functions
- CSS - Masking
- CSS - Shapes
- CSS - Style Images
- CSS - Specificity
- CSS - Custom Properties
- CSS Responsive
- CSS RWD - Introduction
- CSS RWD - Viewport
- CSS RWD - Grid View
- CSS RWD - Media Queries
- CSS RWD - Images
- CSS RWD - Videos
- CSS RWD - Frameworks
- CSS References
- CSS - Questions and Answers
- CSS - Quick Guide
- CSS - References
- CSS - Color References
- CSS - Web browser References
- CSS - Web safe fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
CSS @font-face - font-weight
The font-weight CSS descriptor permits the authors to specify font weights for the specified fonts in the @font-face at-rule.
font-weight descriptor can be used exclusively to specify the font face'e weight, i.e. how thick or thin the font should look like. These font faces correspond to the different styles of the same font family.
The descriptor font-weight takes the same values as that of its corresponding font-weight property.
The font-weight descriptor should not to be confused with the font-weight property. The font-weight descriptor is used solely with the @font-face at-rule to explicitly select bold font faces for that rule. The font-weight property is then used elsewhere in the style sheet to apply that font weight to an element.
For a particular font family, there are some limited weights available and in case a specified weight does not exist, the nearby weight is used. Fonts that lack bold typeface, gets synthesized by the user agent. In order to avoid this, the shorthand property font-synthesis can be used.
Possible Values
The font-weight CSS descriptor can have one of the following values:
normal: Specifies normal font-weight, which is equal to 400.
bold: Specifies bold font-weight, which is equal to 700.
<number>: Specifies a <number> value between 1 to 1000 (inclusive). Higher values correspond to a bolder font than the lower values.
Syntax
font-weight = auto | normal | bold | <number [1,1000]> ]";
CSS font-weight - Weight Name Mapping
The following table explains the mapping of numerical values and their corresponding common weight names:
Value | Common weight name |
---|---|
100 | Thin (Hairline) |
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) |
CSS font-weight - Variable Fonts
Many of the fonts have a specific weight, corresponding to one of the numbers in the common weight name mapping, shown in the table above. But there are some fonts that support a range of weights with fine granularity to a great extent, these are called the variable fonts. They give the user much more control over the font-weight that they are choosing.
The wght variation of TrueType or OpenType variable fonts, is useful in implementing the varying weights.
Accessibility concerns: Fonts with font-weight equal to 100 (Thin/Hairline) or 200 (Extra Light), especially in the case of fonts with low contrast color ratio, might not be very clear to the people with low vision conditions.
CSS font-weight - Number Value
Following example demonstrates the setting of weight value for a font face, using the range 100 and 900 used inside the @font-face at-rule:
<html> <head> <style> @font-face { font-family: "f1"; src: url("font/Brygada1918-Italic.ttf"); font-weight: 100,900; } .container { font: 2.5rem "f1", sans-serif; } .font-wt-400 { font-weight: 400; } .font-wt-bold { font-weight: bold; } .font-wt-900 { font-weight: 900; } </style> </head> <body> <p class="container font-wt-400">font - 400</p> <p class="container font-wt-bold">font - bold</p> <p class="container font-wt-900">font - 900</p> </body> </html>
To Continue Learning Please Login
Login with Google