Using the ::first-letter Selector

Description

The ::first-letter selector selects the first letter in a block of text.

Example

The following code uses the ::first-letter Pseudo-Element Selector.


<!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
::first-letter {<!--  w  w  w.j a v a 2s  .com-->
  background-color: grey;
  color: white;
  border: thin black solid;
  padding: 4px;
}
</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. </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