Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Horizontal UL

Featured Replies

Hi,

 

I've built the following navigation inline navigation menu. But I'm puzzled why the text seems centred in each link - as if I've set the left padding to 30px or something.

 

I want the first list item to align to the left of the navigation div.

 

Here's the code if anyone can help.

 

HTML:

<div id="navigation">

<ul>

<li class="Home"><a href="#"> home </a></li>

<li class="Our Services"><a href="#">market assist</a></li>

<li class="Our Approach"><a href="#">renewal manager</a></li>

<li class="Our Team"><a href="#">loyalty builder </a></li>

<li class="Analysis Wheel"><a href="#">reporting</a></li>

<li class="Contact"><a href="#"> toolkit </a></li>

</ul>

</div>

 

CSS:

 

#navigation {

position: absolute;

top: 100px;

left: 0px;

height: 18px;

width:900px;

border-top: 1px dashed #666666;

border-right: 0px solid #FFFFFF;

border-bottom: 1px dashed #666666;

border-left: 0px solid #FFFFFF;

padding: 3px 30px 3px 3px;

font-family: Arial, Helvetica, sans-serif;

font-size: .75em;

text-align::left;

 

}

#navigation ul {

list-style: none;

text-align:left;

margin: 0;

}

#navigation li {

display: inline;

text-align::left;

}

#navigation a:link, #navigation a:visited {

color: #000000;

text-decoration: none;

text-align:left;

border: 0px;;

padding: 18px 30px 18px 0px;

}

#navigation a:hover {

padding: 18px 30px 18px 0px;

color: #1880B4;

border:0px;

}

 

Thanks!

They are left-aligned. Add padding: 0; to ul and backgrounds and you will see what's happening (IE7 was OK but Firefox was setting the first li tag to the right because of default padding):-

#navigation ul {     padding: 0;      background: pink;
list-style: none;
text-align:left;
margin: 0;
}
#navigation li {              background: lime;
display: inline;
text-align::left;
}
#navigation a:link, #navigation a:visited {      background: yellow;
color: #000000;
text-decoration: none;
text-align:left;
border: 0px;;
padding: 18px 30px 18px 0px;
}

 

Note also that the top and bottom padding of 18px is a lot more than the ul and li tags need (Firefox shows the a tags extending above and below the ul and li tags).

  • Author

Brilliant. Thanks vv much.

 

Such a simple but extremely useful way of showing where I was going wrong using background colours.

 

Why didn't I think of that!!?

 

Anyway, onwards and upwards.

 

Jo

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.