li:first-child color: red; : li.first « Tags « HTML / CSS






li:first-child color: red;

   

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
  <title>Chapter 2</title>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <style>
body {
  font: 1em Verdana, Geneva, Arial, Helvetica, sans-serif;
}
ul {
  color:black;
}

li:first-child {
  color: red;
}
  
  </style>
</head>
<body>
  <ul>
    <li>Brie</li>
    <li>Cheddar</li>
    <li>Red Leicester</li>
    <li>Shropshire Blue</li>
  </ul>
</body>
</html>

   
    
    
  








Related examples in the same category

1.First-child Selector
2.First child of Li with class