:first-line

In this chapter you will learn:

  1. Definition for Selector:first-line
  2. An example showing how to use :first-line CSS selector

Description

The :first-line selector adds a style to the first line of the specified selector.

Example

<!DOCTYPE html><!-- ja v  a2 s  .c o  m-->
<html>
<head>
<style>
p:first-line{
    background-color:red;
}
</style>
</head>

<body>
<p>This is a paragraph. This is a paragraph. This is a paragraph. 
This is a paragraph. This is a paragraph. This is a paragraph. 
This is a paragraph. This is a paragraph. This is a paragraph. 
This is a paragraph. This is a paragraph. This is a paragraph. </p>
</body>
</html>

Click to view the demo

Next chapter...

What you will learn in the next chapter:

  1. Definition for Selector :first-child
  2. An example showing how to use :first-child CSS selector
  3. How to combine :first-child with other selectors
Home » HTML CSS Tutorial » CSS Selector Reference
.class
#id
*
element
element,element
element element
element>element
element+element
element1~element2
:lang
:link
:visited
:active
:hover
:focus
:first-letter
:first-line
:first-child
:last-child
:only-child
:nth-child(n)
:nth-last-child(n)
:before
:after
:first-of-type
:last-of-type
:only-of-type
:nth-of-type(n)
:nth-last-of-type(n)
:root
:empty
:target
:enabled
:disabled
:checked
:not
::selection
[attribute]
[attribute=value]
[attribute~=value]
[attribute|=value]
[attribute^=value]
[attribute$=value]
[attribute*=value]