The first-line selector is used to add a style to the first line of the specified selector.
The first-line selector can only be used with block-level elements.
Code:-
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
div::first-line {
background-color: green;
}
</style>
</head>
<body>
<div>
This is the first div and if you have many lines here then it the "first-line" class only applied for the first line. Other lines are display normally.
<br/> This is the second line.
</div>
</body>
</html>
Output:-
This is the first div and if you have many lines here then it the "first-line" class only applied for the first line. Other lines are display normally.
This is the second line.
The first-line selector can only be used with block-level elements.
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
div::first-line {
background-color: green;
}
</style>
</head>
<body>
<div>
This is the first div and if you have many lines here then it the "first-line" class only applied for the first line. Other lines are display normally.
<br/> This is the second line.
</div>
</body>
</html>
Output:-
This is the first div and if you have many lines here then it the "first-line" class only applied for the first line. Other lines are display normally.
This is the second line.
This is the second line.
Css:- First line
Reviewed by Network security
on
May 12, 2019
Rating:

No comments: