Html5 and Css3 - Horizontal navigation bar issues - html

I am designing a webpage. I have two levels of navigation, the social media buttons on the first level and later a navigation bar. I am having issues getting the background colour of the navigation bar to go the complete length of the webpage, at present it starts and stops with the navigation bar. I am guessing it is an issue related to the location or my coding of the clearfix? Anyways I would appreciate your advice. My coding is below, I have attached a photo of my site so you can see what it looks like.
My Html code:
<div id="wrapper">
<header id="header" role="banner">
<div id="logo">
<img src="Images/title.png" alt="logo" width="1018" height="140">
</div>
<div id="social">
<ul>
<li>
<img src="images/twitter.png" alt="Twitter" width="32" height="32">
</li>
<li>
<a href="https://www.facebook.com/Save-NSW-Government-Disability-
Services-ADHC-709029659182219/" target="_blank"><img src="images/facebook.png" alt="Facebook" width="32" height="32"></a>
</li>
<li>
<img src="images/youtube.png" alt="Youtube" width="32" height="32">
</li>
</ul>
</div>
<div id="clearfix">
</div>
<nav id="page_nav">
<div class="menu">
<ul id="navmenu">
<li class="active">Home</li>
<li>About Us</li>
<li>Get Involved<span class="darrow">▼</span>
<ul class="submenu">
<li>Social Media</li>
<li>Union Meetings</li>
<li>Rally</li>
</ul>
</li>
<li>News<span class="darrow">▼</span>
<ul class="submenu">
<li>Shrew's News</li>
<li>Update</li>
</ul>
</li>
<li>Gallery</li>
<li>Contact Us</l>
</ul>
</div>
<div id="clearfix">
</div>
</div>
</nav>
</header>
</div>
My Css:
* {
margin: 0px;
padding: 0px;
}
body {
font-family: sans-serif;
background-color: black;
}
#wrapper {
width: 1366px;
height: auto;
background-color: black;
margin: 0 auto;
padding: 10px;
}
#header {
width: 100%;
height: 140px;
background-color: black;
}
#logo {
float: left;
margin: 0px 0px 20px 50px;
padding-left: 100px;
}
#social {
float: right;
top: 0px;
margin: 0 auto;
}
#social ul li {
float: left;
list-style: none;
padding: 5px;
}
#clearfix:after {
display: block;
clear: both;
}
#page_nav {
background-color: #c50a13;
}
ul#navmenu {
list-style-type: none;
width: 800px;
margin: auto auto 5px auto;
}
ul.submenu {
list-style-type: none;
}
ul#navmenu li {
outline: 1px solid white;
width: 125px;
text-align: center;
position: relative;
float: left;
margin-right: 4px;
color: #26b0f1;
}
ul#navmenu a {
text-decoration: none;
display: block;
width: 125px;
height: 25px;
line-height: 25px;
background-color: #c50a13;
border: 1px solid white;
border-radius: 5px;
color: white;
}
ul#navmenu .submenu a {
margin-top: 3px;
}
ul#navmenu li:hover > a {
background-color: white;
color: #c50a13;
}
ul#navmenu ul.submenu {
display: none;
position: absolute;
top: 26px;
left: 0px;
}
ul#navmenu li:hover .submenu {
display: block;
}
.darrow {
font-size: 14pts;
position: absolute;
top: 10px;
right: 1px;
color: dodgerblue;
}

Update:
You forgot something in your CSS clearfix.
#clearfix:after {
display: block;
clear: both;
content: ''; /* add me */
}
In addition, you have some errors in your HTML which can affect rendering in different ways in different browsers.
[1] Invalid close tag for an <li>
[2] Extra </div> before the close of your </nav>.
[3] Duplicate IDs: id="clearfix"
First, fix the duplicate IDs. In your CSS, change this:
#clearfix:after {
display: block;
clear: both;
}
To this:
.clearfix:after {
display: block;
clear: both;
}
Here is your HTML without errors.
<div id="wrapper">
<header id="header" role="banner">
<div id="logo">
<img src="Images/title.png" alt="logo" width="1018" height="140">
</div>
<div id="social">
<ul>
<li>
<img src="images/twitter.png" alt="Twitter" width="32" height="32">
</li>
<li>
<img src="images/facebook.png" alt="Facebook" width="32" height="32">
</li>
<li>
<img src="images/youtube.png" alt="Youtube" width="32" height="32">
</li>
</ul>
</div>
<div class="clearfix">
</div>
<nav id="page_nav">
<div class="menu">
<ul id="navmenu">
<li class="active">Home</li>
<li>About Us</li>
<li>
Get Involved<span class="darrow">▼</span>
<ul class="submenu">
<li>Social Media</li>
<li>Union Meetings</li>
<li>Rally</li>
</ul>
</li>
<li>
News<span class="darrow">▼</span>
<ul class="submenu">
<li>Shrew's News</li>
<li>Update</li>
</ul>
</li>
<li>Gallery</li>
<li>Contact Us</li>
</ul>
</div>
<div class="clearfix">
</div>
</nav>
</header>
</div>

Related

How can I vertically center my image in this div?

I am using the following code in my header to display my logo and my navigation. I vertically centered my text with line-height: 90px; but when I try to give my logo vertical-align: middle; it doesn't seem to work. What am I doing wrong?
header {
max-width: 960px;
height: 90px;
margin: 0 auto;
line-height: 90px;
background: #444444;
}
header img {
width: 59px;
height: 32px;
float: left;
}
nav {
float: right;
}
nav ul li {
display: inline-block;
}
nav li:not(:last-child) {
margin: 0px 50px 0px 0px;
}
<header>
<img src="images/logo.png" alt="Logo">
<!-- Bild fehlt noch - SVG -->
<nav>
<ul>
<li>Start
</li>
<li>About me
</li>
<li>Services
</li>
<li>Portfolio
</li>
<li>Contact
</li>
</ul>
</nav>
</header>
Flexbox can do that:
header {
max-width: 960px;
height: 90px;
margin: 0 auto;
line-height: 90px;
background: #444444;
display: flex;
justify-content: space-between;
align-items: center;
}
header img {
width: 59px;
height: 32px;
}
nav {} nav ul li {
display: inline-block;
}
nav li:not(:last-child) {
margin: 0px 50px 0px 0px;
}
nav ul li a {
color: white;
}
<header>
<img src="http://www.fillmurray.com/59/32" alt="Logo">
<!-- Bild fehlt noch - SVG -->
<nav>
<ul>
<li>Start
</li>
<li>About me
</li>
<li>Services
</li>
<li>Portfolio
</li>
<li>Contact
</li>
</ul>
</nav>
</header>

Can't get two divs to align horizontally

I'm pulling my hair out trying to get two div tags to align. I've read page after page of solutions on here but I've not been able to get any of them to work. I'm not sure if this is related to this being a Visual Studio project using MVC. It seems unlikely but I thought I'd mention it.
So this is for a header bar on a company website. Logo should be on the left and the menu should be on the right. It must be responsive. Here's what I've got so far:
header {
width: 100%;
position: absolute;
top: 0;
left: 0;
background-color: #ffffff;
}
logo {
float: none;
width: 215px;
}
nav {
width: 100%;
height: 100%;
float: left;
}
nav ul {
height: auto;
padding: 8px 0px;
margin: 0px;
}
nav li {
display: inline;
padding: 20px;
}
nav a {
text-decoration: none;
color: #171581;
padding: 8px 8px 8px 8px;
}
nav a:hover {
color: #D60053;
}
And here is the HTML
<div style="opacity: 1;" class="wrapper">
<header class="">
<div class="container">
<div class="logo">
<a href="/" class="glyphicon-log-out top-menu">
<img src="~/assets/images/sunwavelogo.png" alt="Sunwave Logo" />
</a>
</div>
<div class="hamburger"></div>
<nav>
<ul>
<li>About</li>
<li>Residential & Business</li>
<li>My Accounts Details</li>
<li>FAQ</li>
<li>Contact us</li>
</ul>
</nav>
</div>
</header>
By changing your CSS like this (note the added dot in .logo)
.logo {
float: left;
width: 215px;
}
nav {
margin-left: 215px;
}
header {
width: 100%;
position: absolute;
top: 0;
left: 0;
background-color: #ffffff;
}
.logo {
float: left;
width: 215px;
}
nav {
margin-left: 215px;
}
nav ul {
height: auto;
padding: 8px 0px;
margin: 0px;
}
nav li {
display: inline;
padding: 20px;
}
nav a {
text-decoration: none;
color: #171581;
padding: 8px 8px 8px 8px;
}
nav a:hover {
color: #D60053;
}
<div style="opacity: 1;" class="wrapper">
<header class="">
<div class="container">
<div class="logo">
<a href="/" class="glyphicon-log-out top-menu">
<img src="~/assets/images/sunwavelogo.png" alt="Sunwave Logo" />
</a>
</div>
<div class="hamburger"></div>
<nav>
<ul>
<li>About</li>
<li>Residential & Business</li>
<li>My Accounts Details</li>
<li>FAQ</li>
<li>Contact us</li>
</ul>
</nav>
</div>
</header>
You have many problems in your code:
logo in your css should be .logo to refer to the class of the logo.
The property float:none should be set to float:left; so it should be correctly floated.
And for the nav you shouldn't specify a width:100% because it will be forced to take the whole width of the header, you need to set it to auto for example.
This is a working snippet:
header {
width: 100%;
position: absolute;
top: 0;
left: 0;
background-color: #ffffff;
}
.logo {
float: left;
width: 215px;
}
nav {
width: auto;
height: 100%;
float: left;
}
nav ul {
height: auto;
padding: 8px 0px;
margin: 0px;
}
nav li {
display: inline;
padding: 20px;
}
nav a {
text-decoration: none;
color: #171581;
padding: 8px 8px 8px 8px;
}
nav a:hover {
color: #D60053;
}
<div style="opacity: 1;" class="wrapper">
<header class="">
<div class="container">
<div class="logo">
<a href="/" class="glyphicon-log-out top-menu">
<img src="~/assets/images/sunwavelogo.png" alt="Sunwave Logo" />
</a>
</div>
<div class="hamburger"></div>
<nav>
<ul>
<li>About
</li>
<li>Residential & Business
</li>
<li>My Accounts Details
</li>
<li>FAQ
</li>
<li>Contact us
</li>
</ul>
</nav>
</div>
</header>
1.Your code was badly formatted.I have formatted it.
2..logo should be set to "float:left".
3..container should have"overflow:hidden"
I have also made Your li straight.(I have made it in one line )
This contains your html formatted code,Css which You may need to change as well as add
<div style="opacity: 1;" class="wrapper">
<header class="">
<div class="container">
<div class="logo">
<a href="/" class="glyphicon-log-out top-menu">
<img src="~/assets/images/sunwavelogo.png" alt="Sunwave Logo" />
</a>
</div>
<div class="hamburger">
<nav>
<ul>
<li>About</li>
<li>Residential & Business</li>
<li>My Accounts Details</li>
<li>FAQ</li>
<li>Contact us</li>
</ul>
</nav>
</div>
</div>
</header>
</div>
Your css code:
* {
margin: 0px;
padding: 0px;
}
header{
width:700px;
margin:0 auto;
}
.container {
overflow: hidden;
}
.logo {
float: left;
margin-right:100px;
}
.hamburger {
/* float: left; */
overflow: hidden;
}
li {
float: left;
padding: 5px;
list-style-type: none;
}
Hope This Is what You had expected

Vertical Navigation issue

So the navigation bar is meant to be the height of the page and is fixed, so will always show, even when the user scrolls down the page.
However my .nav is currently looking like this
Help would be greatly appreciated. Also, when creating a responsive website, what should the image size be? Like when creating the image on Photoshop, how large should the canvas be the ensure the image isn't blurry?
HTML and CSS is as follows
.nav {
list-style-type: none;
margin: 0;
padding: 0;
height: 100%;
width: 25%;
position: fixed;
top: -15px;
left: -10px;
}
.nav li a {
display: block;
background-color: #232121;
/*padding-bottom: 73.5px;*/
padding-left: 25px;
/*padding-top: 20px;*/
text-decoration: none;
color: white;
font-weight: 600;
letter-spacing: 2px;
}
.nav li a:hover {
color: #00b4ff;
text-decoration: none;
}
.sub-nav {
list-style-type: none;
background-color: #232121;
color: white;
}
.sub-nav li a {
font-weight: 400;
letter-spacing: 1px;
}
.sub-nav li a:hover {
color: #00b4ff;
text-decoration: none;
font-weight: 400;
}
<ul class="nav">
<li>
<a href="index.html">
<img src="logo1.jpg" alt="logo" class="logo">
</a>
</li>
<li>HOME
</li>
<li>ABOUT
</li>
<li>PRODUCTS
</li>
<li>SALES AND MOTIVATION
<ul class="sub-nav">
<li>SALES SUCCESS
</li>
<li>MOTIVATION
</li>
</ul>
</li>
<li>PROPERTY INVESTMENT
<ul class="sub-nav">
<li>CURRENT LISTINGS
</li>
<li>TESTIMONIALS
</li>
</ul>
</li>
<li>CONTACT
<ul class="sub-nav">
<li>SUBSCRIBE
</li>
</ul>
</li>
<li>CONNECT
</li>
<li>
<a href="facebook.com">
<img src="facebook.jpg" alt="facebook" class="facebook">
</a>
</li>
<li>
<a href="twitter.com">
<img src="twitter.jpg" alt="twitter" class="twitter">
</a>
</li>
<li>
<a href="linkedin.com">
<img src="linkedin.jpg" alt="linkedin" class="linkedin">
</a>
</li>
</ul>
you are having your background-color: #232121 in your .nav li a just changed to your .nav and your .nav was set top:-15px, I changed for top:0
SNIPPET:
.nav {
list-style-type: none;
margin: 0;
padding: 0;
height: 100%;
width: 25%;
position: fixed;
top: 0;
left: -10px;
background-color: #232121;
}
.nav li a {
display: block;
/*padding-bottom: 73.5px;*/
padding: 0 25px;
/*padding-top: 20px;*/
text-decoration: none;
color: white;
font-weight: 600;
letter-spacing: 2px;
}
.nav li a:hover {
color: #00b4ff;
text-decoration: none;
}
.nav li a img {
max-width: 100%
}
.sub-nav {
list-style-type: none;
background-color: #232121;
color: white;
}
.sub-nav li a {
font-weight: 400;
letter-spacing: 1px;
}
.sub-nav li a:hover {
color: #00b4ff;
text-decoration: none;
font-weight: 400;
}
<ul class="nav">
<li>
<a href="index.html">
<img src="//lorempixel.com/300/300" alt="logo" class="logo">
</a>
</li>
<li>HOME
</li>
<li>ABOUT
</li>
<li>PRODUCTS
</li>
<li>SALES AND MOTIVATION
<ul class="sub-nav">
<li>SALES SUCCESS
</li>
<li>MOTIVATION
</li>
</ul>
</li>
<li>PROPERTY INVESTMENT
<ul class="sub-nav">
<li>CURRENT LISTINGS
</li>
<li>TESTIMONIALS
</li>
</ul>
</li>
<li>CONTACT
<ul class="sub-nav">
<li>SUBSCRIBE
</li>
</ul>
</li>
<li>CONNECT
</li>
<li>
<a href="facebook.com">
<img src="facebook.jpg" alt="facebook" class="facebook">
</a>
</li>
<li>
<a href="twitter.com">
<img src="twitter.jpg" alt="twitter" class="twitter">
</a>
</li>
<li>
<a href="linkedin.com">
<img src="linkedin.jpg" alt="linkedin" class="linkedin">
</a>
</li>
</ul>
We could use a bit more code, to figure what is going on with your particular website; just pasting the nav code isn't very helpful.
That being said, let's keep things simple. This how you create a basic fixed sidebar nav. Obviously a lot depends on your specific code, but since we don't have that, we can only guess what's going on and I'm guessing you didn't set height to 100% on the nav's parent element and upstream to the other parents or body.
If you supply more details, perhaps we can elaborate as to what is going on.
body {
height: 100%;
position: relative;
margin: 0;
}
main {
background: red;
height: 1000px;
padding-left: 100px;
}
aside {
background: lightblue;
height: 100%;
position: fixed;
top: 0;
left: 0;
width: 100px;
}
<aside>
links here
</aside>
<main>
this is your main content
</main>
Actually, the .nav is having 100% height now, but the problem is that it doesn't have the background color. You should set background-color: #232121; to .nav too.
As of the cropped words, you have to give the div a width to make sure the words would not be out of boundary.
.nav {
background-color: #232121;
height: 100%;
width: 225px;
position: fixed;
top: 0;
left: -10px;
list-style-type: none;
margin: 0;
padding: 0;
background-color: #232121;
}
.nav li a {
display: block;
background-color: #232121;
width: 200px;
/*padding-bottom: 73.5px;*/
padding-left: 25px;
/*padding-top: 20px;*/
text-decoration: none;
color: white;
font-weight:600;
letter-spacing: 2px;
}
.nav li a:hover {
color: #00b4ff;
text-decoration: none;
}
.sub-nav {
list-style-type: none;
background-color: #232121;
color: white;
}
.sub-nav li a {
font-weight: 400;
letter-spacing: 1px;
padding: 0;
width: 185px;
}
.sub-nav li a:hover {
color: #00b4ff;
text-decoration: none;
font-weight: 400;
}
<ul class="nav">
<li><img src="logo1.jpg" alt="logo" class="logo"></li>
<li>HOME</li>
<li>ABOUT</li>
<li>PRODUCTS</li>
<li>SALES AND MOTIVATION
<ul class="sub-nav">
<li>SALES SUCCESS</li>
<li>MOTIVATION</li>
</ul>
</li>
<li>PROPERTY INVESTMENT
<ul class="sub-nav">
<li>CURRENT LISTINGS</li>
<li>TESTIMONIALS</li>
</ul>
</li>
<li>CONTACT
<ul class="sub-nav">
<li>SUBSCRIBE</li>
</ul>
</li>
<li>CONNECT</li>
<li><img src="facebook.jpg" alt="facebook" class="facebook"></li>
<li><img src="twitter.jpg" alt="twitter" class="twitter"></li>
<li><img src="linkedin.jpg" alt="linkedin" class="linkedin"></li>
</ul>
edit your Css like:
.nav {
list-style-type: none;
margin: 0;
padding: 0;
height: 100px;
width: 100%;
position: fixed;
left: -10px;
/*border: 1px solid red;*/
}
.nav li
{
display: inline;
}
.nav li a {
background-color: #232121;
/*padding-bottom: 73.5px;*/
padding-left: 25px;
/*padding-top: 20px;*/
text-decoration: none;
color: white;
font-weight:600;
letter-spacing: 2px;
}
And html file to :
<!DOCTYPE html>
<html>
<head>
<title>Learning Input</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<ul class="nav">
<li><img src="logo1.jpg" alt="logo" class="logo"></li>
<li>HOME</li>
<li>ABOUT</li>
<li>PRODUCTS</li>
<li>SALES AND MOTIVATION
<!-- <ul class="sub-nav">
<li>SALES SUCCESS</li>
<li>MOTIVATION</li>
</ul> -->
</li>
<li>PROPERTY INVESTMENT
<!-- <ul class="sub-nav">
<li>CURRENT LISTINGS</li>
<li>TESTIMONIALS</li>
</ul> -->
</li>
<li>CONTACT
<!-- <ul class="sub-nav">
<li>SUBSCRIBE</li>
</ul> -->
</li>
<li>CONNECT</li>
<li><img src="facebook.jpg" alt="facebook" class="facebook"></li>
<li><img src="twitter.jpg" alt="twitter" class="twitter"></li>
<li><img src="linkedin.jpg" alt="linkedin" class="linkedin"></li>
</ul>
</body>
</html>

When I change my navbar position to fixed, it changes sides of the screen and shinks

To begin I'd like to state that I'm using the bootstrap framework and I'm aware they have a navbar template but it doesn't fit what I'm trying to do with this one navigation bar
The bar is supposed to be full width and with a right float which it is until i add position:fixed to it. Then it shrinks down to about 30% screen width and floats to the left.
I added the code snippet from the navibation bar below but I cannot add the bootstrap library to the snipet so it won't look right on here either way.
If you would like to see it live: http://test.suburbandogma.com/test-three.html
.container {
width: 100%;
margin: 0;
padding: 0;
}
#top-nav {
position: fixed;
background-color: #f8f8f8;
padding-top: 0.3em;
border-bottom: 0.1em solid #ccc;
}
.border-right {
border-right: 0.1em solid #ccc;
}
#top-list li {
padding-right: 0.5em;
}
#top-list li:nth-child(6) {
margin-right: 0.5em;
}
#top-list li a {
font-family: 'Open-sans', sans-serif;
font-size: 0.85em;
font-weight: bold;
color: #808080;
}
.top-icons {
position: relative;
top: 0.2em;
height: 15px;
width: 15px;
}
<div class="container">
<div class="row" id="top-nav">
<div class="col-md-12">
<ul class="pull-right list-inline" id="top-list">
<li class="border-right">Support#domainname.com</li>
<li class="border-right">Terms of Service</li>
<li class="border-right">Privacy Policy</li>
<li><a href="#"><img class="img-responsive top-icons" src="/images/icons/twitter-icon.svg" alt="Twitter Icon"/>
<li><a href="#"><img class="img-responsive top-icons" src="/images/icons/facebook-icon.svg" alt="Facebook Icon"/>
<li><a href="#"><img class="img-responsive top-icons" src="/images/icons/skype-icon.svg" alt="Skype Icon"/>
</ul>
</div>
</div>
</div>
Just give #top-nav a width of 100% you can also ditch the row and column divs.
HTML:
<div id="top-nav">
<ul class="pull-right list-inline" id="top-list">
<li class="border-right">Link 1</li>
<li class="border-right">Link 2</li>
<li class="border-right">Link 3</li>
<li><img class="img-responsive top-icons" src="/images/icons/twitter-icon.svg" alt="Twitter Icon"></li>
<li><img class="img-responsive top-icons" src="/images/icons/facebook-icon.svg" alt="Facebook Icon"></li>
<li><img class="img-responsive top-icons" src="/images/icons/skype-icon.svg" alt="Skype Icon"></li>
</ul>
</div>
CSS:
#top-nav {
position: fixed;
background-color: #F8F8F8;
width: 100%;
padding-top: 0.3em;
border-bottom: 0.1em solid #CCC;
}
Add:
width:100%;
to your css for #top-nav
Don't use the .row (that's for the grid system or a similar pattern) or the .col-md-12 (which is extra unnecessary html) or the .container (it has a width at different breakpoints and is required for the grid).
A fixed position needs a width or a position. Also, you didn't close your links or your list on the icons.
https://jsbin.com/putajo/1/
https://jsbin.com/putajo/1/edit?html,css,output
HTML
<div id="top-nav">
<ul class="pull-right list-inline" id="top-list">
<li class="border-right">Support#domainname.com</li>
<li class="border-right">Terms of Service</li>
<li class="border-right">Privacy Policy</li>
<li>X</li>
<li>X</li>
<li>X</li>
</ul>
</div>
CSS
#top-nav {
position: fixed;
background-color: #f8f8f8;
padding-top: 0.3em;
border-bottom: 0.1em solid #ccc;
left:0;
right:0;
}
.border-right {
border-right: 0.1em solid #ccc;
}
#top-list li {
padding-right: 0.5em;
}
#top-list li:nth-child(6) {
margin-right: 0.5em;
}
#top-list li a {
font-family: 'Open-sans', sans-serif;
font-size: 0.85em;
font-weight: bold;
color: #808080;
}
.top-icons {
position: relative;
top: 0.2em;
height: 15px;
width: 15px;
}

How do i solve the issue of position of <ul>?

i created a style called "topbar" using css.
The code are as follows:
.topbar:hover ul{ display: inline;}
.topbar {
float: left;
margin-left: 20px;
margin-right: 20px;
font-family:"Georgia";
}
.topbar ul {
display: none;
top:30px;
position: absolute; border-style:solid;
border-width:1px; background-color:white;}
}
.clear {
clear: both;
}
then i went to create a ul "grid" and allows mouse hover enlarge of images
ul.grid, ul.grid > li {
margin: 0;
padding: 0;
}
ul.grid {
}
ul.grid > li {
float: left;
list-style-type: none;
text-align: center;
font-family:"Georgia", serif;
padding-top:50px;
padding-bottom:25px;
padding-right:25px;
padding-left:0px;
}
ul img:hover { width: 200px; height: 250px; }
my html code:
<body>
<div class="topbar">
<p>Title</p>
<ul>
<li>A-Z</li>
<li>Z-A</li>
</ul>
</div>
<div class="topbar">
<p>Genre</p>
<ul>
<li>Action</li>
<li>Comedy</li>
<li>Animation</li>
<li>Horror</li>
<li>Drama</li>
</ul>
</div>
<div class="clear"></div>
<br />
<div id="videos">
<ul class="grid">
<li>
<p class="image"><img src="http://3.bp.blogspot.com/-AGAaic1-yrM/TcWmj77lHzI/AAAAAAAAAkQ/K6zzSk1WgUY/s1600/thor-movie-poster-1.jpg" alt="Thor" width="175" height="200" /></p>
<p class="name">Thor</p>
<p class="genre">Action</p>
<p class="format">DVD</p>
<p class="year">2011</p>
</li>
<li>
<p class="image"><img src="http://www.galacool.com/wp-content/uploads/2010/02/hangover2.jpg" alt="Hangover" width="175" height="200" /></p>
<p class="name">Hangover</p>
<p class="genre">Comedy</p>
<p class="format">DVD</p>
<p class="year">2009</p>
</li>
</ul>
</div>
</body>
Why do i have a left unwanted space beside my "thor" movie image?
The left space must be the indentation of the List where you are putting them. Ideally, to remove this left-indentation, you should set both padding and margins to "0" for the "UL".
This small piece of code works perfectly in this context:
CSS
#navcontainer ul
{
margin: 0;
padding: 0;
list-style-type: none;
}
HTML
<div id="navcontainer">
<ul>
<li>Milk
<ul>
<li>Goat</li>
<li>Cow</li>
</ul>
</li>
<li>Eggs
<ul>
<li>Free-range</li>
<li>Other</li>
</ul>
</li>
</ul>
</div>