Creating Unordered List Without BulletsTypes of Navigation BarVertical Navigation BarHorizontal Navigation BarScrollable Vertical Navigation BarScrollable Horizontal Navigation Bar
Creating Navigation Bars Using List of Links
A navigation bar is basically a list of links. Therefore, it is logical to use the <ul> and <li> elements to create navigation bar.
Navigation Bar = List of LinksMeanwhile, there are other approaches used in creating navigation bar. In this article, we shall discuss the use of unordered list to create navigation bar under the following sub topics:
The code snippet can be used to create the sub topics above. However, list markers (e.g. bullets) is a default property of list while browsers usually add margins and paddings to list by default. These three properties are not required in a navigation bar.
What do we do?
We shall remove the bullets from the list, and its default paddings and margins.
So, how do we get rid of them?
We shall address this concern in the next topic.
Creating Unordered List Without Bullets
There are four methods to achieve this and each of them is discussed below.
Method 1: Element Type Selector
Create a selector “ul” to remove bullets, margins and paddings for all <ul> and <li>. Note that this will affect all pages.
list-style-type: none; – removes the bullets. A navigation bar does not need list markers.margin: 0; and padding: 0; – remove browser default settingsThe code in the example above is the standard code used in both vertical and horizontal navigation bars created from unordered list.
Create a CSS selector “ul” to remove bullets, margins and paddings for all <ul> and <li> on some specific pages. Then use JavaScript getElementById to apply the style.
Of course making it work is not as easy as writing these steps. You will have to explore on how to getting this done. Don't worry, we can guide you on this when you contact us. Please check our Training Programes Here.
Vertical Navigation Bar
To make the whole link area clickable (not just the text) in a vertical navigation bar, style the <a> elements inside the list as block elements using display: block. By default, block elements consume the whole space in the horizontal direction.
<style>
ul {
list-style-type: none;
margin: 0;
padding: 0;
}
li a {
display: block;
}
</style>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#eLearning">eLearning</a></li>
<li><a href="#eClasses">eClasses</a></li>
<li><a href="#about-us">About Us</a></li>
</ul>
After you have style the <a> element as block, you can specify its width (and padding, margin, height, etc. if you want).
<style>
ul {
list-style-type: none;
margin: 0;
padding: 0;
}
li a {
display: block;
width: 60px;
background-color: blue;
}
</style>
Scrollable Vertical Navigation Bar
Style a <div> container by using overflow: auto and white-space: nowrap. Also set the height of the <div>. Then place the navigation bar inside the <div>.
A well-structured group of links make it easier and quicker for site users and search engines to find valuable content on a web page. A navigation bar can be used to organise your links in a well-structured format. This can help boost visitors’ UXKindly contact us for your website design training or to build and host your website.