Font Weight in CSS

CSSWeb DevelopmentFront End Technology

The CSS font-weight property is used to define the boldness of text characters of an element.

Syntax

The syntax of CSS font-weight property is as follows −

Selector {
   font-weight: /*value*/
}

Example

The following examples illustrate font-weight property −

 Live Demo

<!DOCTYPE html>
<html>
<head>
<style>
div {
   margin: 3px;
   font-family: "Ink Free";
   width: 30%;
   font-size: 24px;
}
#one {
   font-weight: normal;
   border-bottom: 2px dashed greenyellow;
}
#two {
   font-family: "Kristen ITC";
   font-weight: bolder;
   border-bottom: 2px dashed cornflowerblue;
}
#three {
   font-weight: bold;
   border-bottom: 2px dashed chocolate;
}
</style>
</head>
<body>
<div id="one">First Demo Text</div>
<div id="two">Another Demo Text</div>
<div id="three">Last Demo Text</div>
</body>
</html>

Output

This gives the following output −

Example

 Live Demo

<!DOCTYPE html>
<html>
<head>
<style>
[class|=lis] {
   font-style: italic;
   font-weight: bold;
}
li[class|="lis-ul"] {
   background-color: cadetblue;
   font-family: Helvetica;
   font-weight: 100;
   color: gainsboro;
   width: 20%;
}
</style>
</head>
<body>
<h2>Tutorials</h2>
<ol>
<li><p>C#</li>
<li class="lis-ul-2">DBMS</li>
<li class="lis-3">OS</li>
<li>Java</li>
<ul>
<li class="lis-ul-one">Core Java</li>
<li class="lis">Advance Java</li>
</ul>
</ol>
</body>
</html>

Output

This gives the following output −

raja
Published on 08-Jan-2020 16:59:27
Advertisements