<p class="alert">お知らせする内容があります。</p>
<p class="alert caution">注意する内容があります。</p>
<p class="alert caution">注意する内容があります。</p>
<p class="alert">お知らせする内容があります。</p>
<p class="alert caution">注意する内容があります。</p>
<p class="alert">お知らせする内容があります。</p>
<p>段落要素です。</p>
<p class="alert caution">注意する内容があります。</p>
<p>段落要素です。</p>
.alert { /* alertクラスを選択: .classセレクター */
    padding: 0.5em;
    background-color: gold;
}
.caution { /* cautionクラスを選択: .classセレクター */
    color: orangered;
}
実際の適用例
<style>
    div { /* すべてのdiv要素をスタイル設定 */
        padding: 0.5em;
        border: 1px solid red;
        margin-bottom: 0.5em;
    }
    .box { /* boxクラスを持つdiv要素だけに背景色を追加 */
        background-color: gold;
    }
</style>

<div class="box">boxクラス</div>
<div class="box">boxクラス</div>
<div class="box">boxクラス</div>
<div class="box">boxクラス</div>
<div>div</div>
<div>div</div>
<div class="box">boxクラス</div>
<div class="box">boxクラス</div>
<div>div</div>
<div class="box">boxクラス</div>
<button id="highlight-button" type="button">クリックしてテキストを変更</button>

<script>
    const highlightButton = document.getElementById("highlight-button");

    highlightButton.addEventListener("click", () => {
        // クラス名が 'box' のすべての要素を取得します。
        const boxes = document.querySelectorAll(".box");

        boxes.forEach(box => {
            box.innerHTML = "boxクラス ようこそ。";
        });
    });
</script>
実際の適用例 ボタンをクリックしてみてください!
<p class="a" class="b">1つのHTML要素に複数のクラス名を指定できます。</p>
<p class="a b">1つのHTML要素に複数のクラス名を指定できます。</p>