1

Please see this css and html and then see the image to understand the gaps that i am talking about. I am probably fussing over something too small, and getting this fixed won't have any effect on the webpage's usability, but i am learning right now, and i just want to understand this behaviour.

<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Untitled Document</title>
    <link rel="stylesheet" href="css/resetdefault.css">
    <link rel="stylesheet" href="css/main.css">
    <script type="text/javascript" src="js/jquery.js"></script>
    <script type="text/javascript" src="js/functions.js"></script>
</head>
<body>
    <div id="topbar">
        <nav id="navmenu">
            <ul>
                <li>Sample</li>
                <li>Sample</li>
                <li>Sample</li>
                <li>Sample</li>
                <li>Sample</li>
                <li>Sample</li>
            </ul>
        </nav>
        <a href="login.html">Sign Out</a>
    </div>
</body>
</html>

I have two css files attached, one is my reset file the other is for this page:

Reset CSS:

 html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr,
 acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp,small, strike,
 strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label,
 legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details,
 embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary,
 time, mark, audio, video, input, select
{
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 100%;
    vertical-align: baseline;
    box-sizing:border-box;
    word-wrap:normal;
    }

article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
    display: block;
    }
body {
    line-height: 1.2;
    }
ol {
    padding-left: 1.4em;
    list-style: decimal;
    }
ul {
    list-style: square;
    }
table {
    border-collapse: collapse;
    border-spacing: 0;
    }
table, th, td {
    border: 1px solid black;
}
a{
    color:black;
    cursor:pointer;
    text-decoration: none;
    }
a:active{
    color:inherit;
    }
input[type="submit"] {
    float: left;
    padding: 4px 8px;
    border: 1px solid rgb(50,50,50);
    font-size: .8em;
}

main file (For this page):

    #navmenu ul li{
    display:inline-block;
    padding:15px;
}

#navmenu ul{
    display:inline-block;
}

#topbar a {
    float: right;
    display: inline;
    padding: 5px;
}

#navmenu {
    display:inline-block;
    float: left;
}

#navmenu ul li:hover {
    background-color: rgb(50,50,50);
    color: rgb(255,255,255);
}

Now this is a image of my nav menu in the browser, notice the gaps in between the li elements. I have changed the display property, i have checked in chrome if this is some kind of margin, but when i do inspect element, it doesn't really tell me what the gap is.

enter image description here

notANerdDev
  • 1,204
  • 11
  • 25

1 Answers1

2

Floating li elements left will remove the gap between them:

#navmenu ul li {
    float: left;
}

Hope this helps

emmanuel
  • 9,385
  • 10
  • 21
  • 37