Using the ::first-line Selector

Description

The ::first-line selector matches the first line of a block of text.

Example

The following code shows an example of using the ::first-line selector.


<!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
::first-line {<!--  w  w w. ja va 2s . c  o  m-->
  background-color: grey;
  color: white;
}
</style>
</head>
<body>
  <p>This is a test. This is a test. This is a test. This is a test.
  This is a test. This is a test. This is a test. This is a test.
  This is a test. This is a test. This is a test. This is a test.
  This is a test. This is a test. This is a test. This is a test.
  </p>

  <p>
    I like <span lang="en-uk" class="class2">CSS</span>.
  </p>

  <a href="http://w3c.org">Visit the W3C website</a>
</body>
</html>

Click to view the demo





















Home »
  HTML CSS »
    CSS »




CSS Introduction
CSS Background
CSS Border
CSS Box Layout
CSS Text
CSS Font
CSS Form
CSS List
CSS Selectors
CSS Others
CSS Table