Search code examples
htmlcssbackground-color

My background color for my div is not working


I want to make my element have background #22223b, but my code is not working.

.nav {
  background-color: #22223b;
}
<div class="header">
  <div class="nav">
    <ul>
      <li> <a href="index.html">Home</a> </li>
      <li> <a href="#">About Us</a> </li>
      <li> <a href="#">Start Learning</a> </li>
    </ul>
  </div>

  <div class="account">
    <ul>
      <li> <a href="#">Profile</a> </li>
      <li> <a href="#">Portal</a> </li>
    </ul>
  </div>


Solution

  • The background-color should be visible, if it´s not then there is probably some problem with linking the css file.

    I added the styling in a <style> so the styling applies without needing the css file.

    <div class="nav">
      <ul>
        <li> <a href="index.html">Home</a> </li>
        <li> <a href="#">About Us</a> </li>
        <li> <a href="#">Start Learning</a> </li>
      </ul>
    </div>
    <div class="account">
      <ul>
        <li> <a href="#">Profile</a> </li>
        <li> <a href="#">Portal</a> </li>
      </ul>
    </div>
    
    <style>
      .nav {
        background-color: #22223b;
      }
    </style>