View video tutorial

HTML Formatting Elements

HTML

Formatting tags are used to format text.

HTML Formatting elements


➔ Formatting is used to make the text look and feel better.

➔ HTML formatting tags provide the ability to format text without using CSS.

Formatting elements are

<b>, <big>, <del>, <em>, <i>, <ins>, <mark>, <small>, <strong>, <sub>, <sup>, <u>.

Example <b>

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta charset="utf-8" />
    <title>HTML b tag example</title>
    <style>
        p {
            background-color: #e7e9eb;
            padding: 10px;
        }
        button {
            padding: 10px;
        }
    </style>
</head>
<body>
    <p id="para1">This is normal text and <b>This is bold text.</b></p>
    <button onclick="myfunc()">Toggle Style</button>
    <script>
        let element = document.querySelector("#para1");
        function myfunc() {
            if (element.style.fontWeight === "bold") {
                element.style.fontWeight = "normal";
            } else {
                element.style.fontWeight = "bold";
            }
        }
    </script>
</body>
</html>
Try it Now »

Copy code and click on the "Try it Now" button to see how it works.