Select the first child element of every <ul> element - HTML CSS CSS Selector

HTML CSS examples for CSS Selector:first-child

Description

Select the first child element of every <ul> element

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
ul > :first-child {
    background:red;
}
</style><!-- ww w  .  j ava  2  s .c om-->
</head>
<body>

<ul>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Coca Cola</li>
</ul>

<ul>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Coca Cola</li>
</ul>

</body>
</html>

Related Tutorials