CSS text bold - font-weight property
CSS Tutorial » CSS text bold - font-weight property
Study in this chapter:
1. - How do you make text bold in CSS?
2. - CSS font-weight style
3. - bold text: in line, in span, in div, color, shadow
The font-weight property determines how thick or thin the characters in the text displayed on the screen should be.
We can add font-weight property to an element as:Inline - by using the style attribute in HTML elements
Internal - by using a <style> element in the <head> section
External - by using an external CSS file as style.css
Syntax:
font-weight: normal;
font-weight: bold;
/* Keyword values relative to the parent */
font-weight: lighter;
font-weight: bolder;
/* Numeric keyword values */
font-weight: 100;
font-weight: 200;
font-weight: 300;
font-weight: 400; /* normal */
font-weight: 700; /* bold */
font-weight: 800;
/* Global values */
font-weight: inherit;
font-weight: initial;
font-weight: revert;
font-weight: revert-layer;
font-weight: unset;
Syntax: Inline CSS.
Syntax: HTML Simple text bold.
Example:
Browser Support font-weight property
Element | ![]() Chrome |
![]() IE |
![]() Firefox |
![]() Opera |
![]() Safari |
CSS border padding | Yes | Yes | Yes | Yes | Yes |
Text bold CSS in span and in div.
Website developers, when they want to draw attention to something, have a number of ways at hand to do this.
The most basic is to increase the font weight of the text you want to highlight.
This refers to making the text appear encouraged.
Below we show you an example of bolding a text inside an element such as div and span using internal CSS style.
In the example below I used: span{ font-weight: bold; font-size: 16px; font-family: Arial; color: #006; } .container{ font-family: "Times New Roman"; font-size: 20px; font-weight: 800; color: #930; }
<!DOCTYPE html>
<html>
<head>
<style>
span{
font-weight: bold;
font-size: 16px;
font-family: Arial;
color: #006;
}
.container{
font-family: "Times New Roman";
font-size: 20px;
font-weight: 800;
color: #930;
}
</style>
</head><body>
<span>My text bold using <span> tag</span>
<div class="container">My text bold using <div> tag </div></body>
</html>
In HTML, there are three major ways you can use to bold text. You can use the <b> tag, the <strong> tag, or in CSS with the font-weight property.
Related subjects:
text color
text shadow
font size
CSS text bold on hover
Below we show you an example of bold text on hover, inside a div
<!DOCTYPE html>
<html>
<head>
<style>.container{
font-family: "Times New Roman";
font-size: 20px;
color: #F00;
}
.container:hover{
font-family: "Times New Roman";
font-size: 20px;
color: #039;
font-weight: bold;
}
</style>
</head><body>
<div class="container">My bold text on :hover inside a <div> label </div>
</body>
</html>
Tags: style, mdn, hover in line, in span, font size, in div, color, shadow, without changing width, not working
Bold text inline
We used inline CSS as: <div style="font-family:Times New Roman; font-size:20px; color:#039; font-weight:bold;">My bold text in line of <div> tag - no <style> in the <head></div>
<!DOCTYPE html>
<html>
<head></head>
<body>
<div style="font-family:Times New Roman; font-size:20px; color:#039; font-weight:bold;">My bold text in line of <div> tag - no <style> in the <head></div>
<p> </p>
<div>My simple text in the other box</div>
</body>
</html>
Summary of description
Text Bold, italic, property, style, on hover, font, size, not working, code, on hover, italic, font, property, tag, size, code
CSS text bold - font-weight property - css tutorial
This tool makes it easy to create, adjust, and experiment with custom colors for the web.

Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.

Find here examples of creative and unique website layouts.

Find here examples of creative and unique website CSS HTML menu.