How Can I Use Font Families For HTML Elements In CSS

admin_img Posted By Bajarangi soft , Posted On 02-11-2020

In CSS The CSS font properties define the font family, boldness, size, and the style of a text.SO today we discuss how to do it.

How Can I Use Font Families For HTML Elements In CSS

Step 1:Create index.html file and implement as below code in it.

<p class="serif">This is a paragraph, shown in the Times New Roman font.</p>
<p class="sansserif">This is a paragraph, shown in the Arial font.</p>
<p class="monospace">This is a paragraph, shown in the Lucida Console font.</p>

Step 2:Implement CSS code as below to font family.

<style>
    body {
        background: #2e9ad0;
    }

    .serif {
        font-family: "Times New Roman", Times, serif;
    }

    .sansserif {
        font-family: Arial, Helvetica, sans-serif;
    }

    .monospace {
        font-family: "Lucida Console", Courier, monospace;
    }

</style>

Complete Code For Using Font Families For HTML Elements.

<!DOCTYPE html>
<html>
<head>
    <title>How Can I Use Font Families For HTML Elements In CSS</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"/>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<style>
    body {
        background: #2e9ad0;
    }

    .serif {
        font-family: "Times New Roman", Times, serif;
    }

    .sansserif {
        font-family: Arial, Helvetica, sans-serif;
    }

    .monospace {
        font-family: "Lucida Console", Courier, monospace;
    }

</style>
<body>
<br/><br/>
<div class="container">
    <br><br><br>
    <div class="text-center">
        <h1 id="color" style="color: white;">Font Families For HTML Elements In CSS</h1>
    </div>
    <br>
    <div class="well">
        <p class="serif">This is a paragraph, shown in the Times New Roman font.</p>
        <p class="sansserif">This is a paragraph, shown in the Arial font.</p>
        <p class="monospace">This is a paragraph, shown in the Lucida Console font.</p>
    </div>
    <br>
</div>
</body>
</html>

Related Post