.class - HTML CSS CSS Selector

HTML CSS examples for CSS Selector:class

Description

The .class selector selects elements by specified class attribute.

To select elements by class value, use element.class.

The following code selects all elements by class value

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
.intro {<!--  w ww  .j av a2s  .c  o m-->
    background-color: red;
}
</style>
</head>
<body>

<h1>Welcome to My Homepage</h1>

<div class="intro">
  <p>this is a test.</p>
  <p>this is a paragraph.</p>
</div>

<p>I <b>like</b> css.</p>

</body>
</html>

Related Tutorials