Page Widget How to - Create CSS and HTML Navigation Bar








Question

We would like to know how to create CSS and HTML Navigation Bar.

Answer


<html>
<head>
<style>
.font_title {<!-- ww w .  j  a  v  a 2s .  co  m-->
  text-align: center;
}
#title {
  width: 800px;
}

#container {
  position: relative;
  margin: auto;
  width: 800px;
  height: 995px;
  background-color: #CCC;
}

#navigation_holder {
  position: relative;
  margin: auto;
  width: 800px;
}

.navigation_button {
  font-size: 26px;
  width: 200px;
  height: 40px;
  background-color: #09C;
}

.navigation_button:hover {
  background-color: #09F;
}
ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

li {
  float: left;
}
a:link,a:visited {
  display: block;
  width: 200px;
  text-align: center;
  font-size: 26px;
  width: 200px;
  height: 40px;
  background-color: #09C;
}

a:hover,a:active {
  background-color: #09F;
}
</style>
</head>

<body>
  <div id="container">
    <div class="font_title" , id="title">Our Site</div>
    <div id="navigation_holder">
      <ul>
        <li id="navigation_button_1"><a href="#"> Home </a></li>
        <li id="navigation_button_2"><a href="#"> About </a></li>
        <li id="navigation_button_3"><a href="#"> Services </a></li>
        <li id="navigation_button_4"><a href="#"> Contact </a></li>
      </ul>
    </div>
  </div>
</body>
</html>

The code above is rendered as follows: