How to have a element that groups elements inside of
OK so for my site we have a navbar that uses a list. We have a section of elements that float left, and a section that floats right. My code works perfectly, it's just that the W3 validator constantly tells me that I can't have a div element inside of a ul element. If I assigned each individual li element the class that floats them left, they don't stay on the same line. Here's the code (exact links have been removed):
.navbar {
font-family: 'Open Sans', sans-serif;
}
.navbar ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333333;
display: block;
}
.navbar li a {
display: block;
color: white;
text-align: center;
padding: 10px;
text-decoration: none;
}
/* On-site navigation */
.leftnav li {
float: left;
}
.leftnav li:hover {
background-color: #111111;
}
/* Links to Social Media */
.medianav li {
float: right;
}
.medianav li:nth-child(1) {
background-color: #ff0000;
}
.medianav li:nth-child(1):hover {
background-color: #ff6666;
}
.medianav li:nth-child(2) {
background-color: #7289DA;
}
.medianav li:nth-child(2):hover {
background-color: #99AAB5;
}
.medianav li:nth-child(3) {
background-color: #1da1f2;
}
.medianav li:nth-child(3):hover {
background-color: #49baff;
}
<nav class="navbar">
<ul>
<div class="leftnav">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="members.html">Members</a></li>
<li><a href="smash.html">Smash Club</a></li>
</nav>
<div class="medianav">
<li><a href="https://www.youtube.com">YouTube</a></li>
<li><a href="https://discord.gg">Discord</a></li>
<li><a href="#">Twitter</a></li>
</nav>
</ul>
</nav>
And this is what it has to look like:
However, if I do this to the html, which makes the validator happy:
<nav class="navbar">
<ul>
<li class="leftnav"><a href="index.html">Home</a></li>
<li class="leftnav"><a href="about.html">About</a></li>
<li class="leftnav"><a href="members.html">Members</a></li>
<li class="leftnav"><a href="smash.html">Smash Club</a></li>
<li class="medianav"><a href="https://www.youtube.com">YouTube</a></li>
<li class="medianav"><a href="https://discord.gg">Discord</a></li>
<li class="medianav"><a href="#">Twitter</a></li>
</ul>
</nav>
This happens:
So how do I fix this? Sorry if it was long, or has been asked before in different words, but I couldn't find any other resource.
html css html-lists nav
add a comment |
OK so for my site we have a navbar that uses a list. We have a section of elements that float left, and a section that floats right. My code works perfectly, it's just that the W3 validator constantly tells me that I can't have a div element inside of a ul element. If I assigned each individual li element the class that floats them left, they don't stay on the same line. Here's the code (exact links have been removed):
.navbar {
font-family: 'Open Sans', sans-serif;
}
.navbar ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333333;
display: block;
}
.navbar li a {
display: block;
color: white;
text-align: center;
padding: 10px;
text-decoration: none;
}
/* On-site navigation */
.leftnav li {
float: left;
}
.leftnav li:hover {
background-color: #111111;
}
/* Links to Social Media */
.medianav li {
float: right;
}
.medianav li:nth-child(1) {
background-color: #ff0000;
}
.medianav li:nth-child(1):hover {
background-color: #ff6666;
}
.medianav li:nth-child(2) {
background-color: #7289DA;
}
.medianav li:nth-child(2):hover {
background-color: #99AAB5;
}
.medianav li:nth-child(3) {
background-color: #1da1f2;
}
.medianav li:nth-child(3):hover {
background-color: #49baff;
}
<nav class="navbar">
<ul>
<div class="leftnav">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="members.html">Members</a></li>
<li><a href="smash.html">Smash Club</a></li>
</nav>
<div class="medianav">
<li><a href="https://www.youtube.com">YouTube</a></li>
<li><a href="https://discord.gg">Discord</a></li>
<li><a href="#">Twitter</a></li>
</nav>
</ul>
</nav>
And this is what it has to look like:
However, if I do this to the html, which makes the validator happy:
<nav class="navbar">
<ul>
<li class="leftnav"><a href="index.html">Home</a></li>
<li class="leftnav"><a href="about.html">About</a></li>
<li class="leftnav"><a href="members.html">Members</a></li>
<li class="leftnav"><a href="smash.html">Smash Club</a></li>
<li class="medianav"><a href="https://www.youtube.com">YouTube</a></li>
<li class="medianav"><a href="https://discord.gg">Discord</a></li>
<li class="medianav"><a href="#">Twitter</a></li>
</ul>
</nav>
This happens:
So how do I fix this? Sorry if it was long, or has been asked before in different words, but I couldn't find any other resource.
html css html-lists nav
Note thatdiv
elements are not allowed as children of a` ul. The only permitted children are
li. i fyou want to group
li` use a submenu.
– Paulie_D
Nov 14 '18 at 16:58
Semantically, you don't have one list, you have two. If you marked up your content with the right semantics, applying the required styling would have been simple.
– Alohci
Nov 14 '18 at 17:06
add a comment |
OK so for my site we have a navbar that uses a list. We have a section of elements that float left, and a section that floats right. My code works perfectly, it's just that the W3 validator constantly tells me that I can't have a div element inside of a ul element. If I assigned each individual li element the class that floats them left, they don't stay on the same line. Here's the code (exact links have been removed):
.navbar {
font-family: 'Open Sans', sans-serif;
}
.navbar ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333333;
display: block;
}
.navbar li a {
display: block;
color: white;
text-align: center;
padding: 10px;
text-decoration: none;
}
/* On-site navigation */
.leftnav li {
float: left;
}
.leftnav li:hover {
background-color: #111111;
}
/* Links to Social Media */
.medianav li {
float: right;
}
.medianav li:nth-child(1) {
background-color: #ff0000;
}
.medianav li:nth-child(1):hover {
background-color: #ff6666;
}
.medianav li:nth-child(2) {
background-color: #7289DA;
}
.medianav li:nth-child(2):hover {
background-color: #99AAB5;
}
.medianav li:nth-child(3) {
background-color: #1da1f2;
}
.medianav li:nth-child(3):hover {
background-color: #49baff;
}
<nav class="navbar">
<ul>
<div class="leftnav">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="members.html">Members</a></li>
<li><a href="smash.html">Smash Club</a></li>
</nav>
<div class="medianav">
<li><a href="https://www.youtube.com">YouTube</a></li>
<li><a href="https://discord.gg">Discord</a></li>
<li><a href="#">Twitter</a></li>
</nav>
</ul>
</nav>
And this is what it has to look like:
However, if I do this to the html, which makes the validator happy:
<nav class="navbar">
<ul>
<li class="leftnav"><a href="index.html">Home</a></li>
<li class="leftnav"><a href="about.html">About</a></li>
<li class="leftnav"><a href="members.html">Members</a></li>
<li class="leftnav"><a href="smash.html">Smash Club</a></li>
<li class="medianav"><a href="https://www.youtube.com">YouTube</a></li>
<li class="medianav"><a href="https://discord.gg">Discord</a></li>
<li class="medianav"><a href="#">Twitter</a></li>
</ul>
</nav>
This happens:
So how do I fix this? Sorry if it was long, or has been asked before in different words, but I couldn't find any other resource.
html css html-lists nav
OK so for my site we have a navbar that uses a list. We have a section of elements that float left, and a section that floats right. My code works perfectly, it's just that the W3 validator constantly tells me that I can't have a div element inside of a ul element. If I assigned each individual li element the class that floats them left, they don't stay on the same line. Here's the code (exact links have been removed):
.navbar {
font-family: 'Open Sans', sans-serif;
}
.navbar ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333333;
display: block;
}
.navbar li a {
display: block;
color: white;
text-align: center;
padding: 10px;
text-decoration: none;
}
/* On-site navigation */
.leftnav li {
float: left;
}
.leftnav li:hover {
background-color: #111111;
}
/* Links to Social Media */
.medianav li {
float: right;
}
.medianav li:nth-child(1) {
background-color: #ff0000;
}
.medianav li:nth-child(1):hover {
background-color: #ff6666;
}
.medianav li:nth-child(2) {
background-color: #7289DA;
}
.medianav li:nth-child(2):hover {
background-color: #99AAB5;
}
.medianav li:nth-child(3) {
background-color: #1da1f2;
}
.medianav li:nth-child(3):hover {
background-color: #49baff;
}
<nav class="navbar">
<ul>
<div class="leftnav">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="members.html">Members</a></li>
<li><a href="smash.html">Smash Club</a></li>
</nav>
<div class="medianav">
<li><a href="https://www.youtube.com">YouTube</a></li>
<li><a href="https://discord.gg">Discord</a></li>
<li><a href="#">Twitter</a></li>
</nav>
</ul>
</nav>
And this is what it has to look like:
However, if I do this to the html, which makes the validator happy:
<nav class="navbar">
<ul>
<li class="leftnav"><a href="index.html">Home</a></li>
<li class="leftnav"><a href="about.html">About</a></li>
<li class="leftnav"><a href="members.html">Members</a></li>
<li class="leftnav"><a href="smash.html">Smash Club</a></li>
<li class="medianav"><a href="https://www.youtube.com">YouTube</a></li>
<li class="medianav"><a href="https://discord.gg">Discord</a></li>
<li class="medianav"><a href="#">Twitter</a></li>
</ul>
</nav>
This happens:
So how do I fix this? Sorry if it was long, or has been asked before in different words, but I couldn't find any other resource.
.navbar {
font-family: 'Open Sans', sans-serif;
}
.navbar ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333333;
display: block;
}
.navbar li a {
display: block;
color: white;
text-align: center;
padding: 10px;
text-decoration: none;
}
/* On-site navigation */
.leftnav li {
float: left;
}
.leftnav li:hover {
background-color: #111111;
}
/* Links to Social Media */
.medianav li {
float: right;
}
.medianav li:nth-child(1) {
background-color: #ff0000;
}
.medianav li:nth-child(1):hover {
background-color: #ff6666;
}
.medianav li:nth-child(2) {
background-color: #7289DA;
}
.medianav li:nth-child(2):hover {
background-color: #99AAB5;
}
.medianav li:nth-child(3) {
background-color: #1da1f2;
}
.medianav li:nth-child(3):hover {
background-color: #49baff;
}
<nav class="navbar">
<ul>
<div class="leftnav">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="members.html">Members</a></li>
<li><a href="smash.html">Smash Club</a></li>
</nav>
<div class="medianav">
<li><a href="https://www.youtube.com">YouTube</a></li>
<li><a href="https://discord.gg">Discord</a></li>
<li><a href="#">Twitter</a></li>
</nav>
</ul>
</nav>
.navbar {
font-family: 'Open Sans', sans-serif;
}
.navbar ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333333;
display: block;
}
.navbar li a {
display: block;
color: white;
text-align: center;
padding: 10px;
text-decoration: none;
}
/* On-site navigation */
.leftnav li {
float: left;
}
.leftnav li:hover {
background-color: #111111;
}
/* Links to Social Media */
.medianav li {
float: right;
}
.medianav li:nth-child(1) {
background-color: #ff0000;
}
.medianav li:nth-child(1):hover {
background-color: #ff6666;
}
.medianav li:nth-child(2) {
background-color: #7289DA;
}
.medianav li:nth-child(2):hover {
background-color: #99AAB5;
}
.medianav li:nth-child(3) {
background-color: #1da1f2;
}
.medianav li:nth-child(3):hover {
background-color: #49baff;
}
<nav class="navbar">
<ul>
<div class="leftnav">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="members.html">Members</a></li>
<li><a href="smash.html">Smash Club</a></li>
</nav>
<div class="medianav">
<li><a href="https://www.youtube.com">YouTube</a></li>
<li><a href="https://discord.gg">Discord</a></li>
<li><a href="#">Twitter</a></li>
</nav>
</ul>
</nav>
html css html-lists nav
html css html-lists nav
edited Nov 14 '18 at 22:40
Maarti
1,8523822
1,8523822
asked Nov 14 '18 at 14:30
abnormalfantasyabnormalfantasy
614
614
Note thatdiv
elements are not allowed as children of a` ul. The only permitted children are
li. i fyou want to group
li` use a submenu.
– Paulie_D
Nov 14 '18 at 16:58
Semantically, you don't have one list, you have two. If you marked up your content with the right semantics, applying the required styling would have been simple.
– Alohci
Nov 14 '18 at 17:06
add a comment |
Note thatdiv
elements are not allowed as children of a` ul. The only permitted children are
li. i fyou want to group
li` use a submenu.
– Paulie_D
Nov 14 '18 at 16:58
Semantically, you don't have one list, you have two. If you marked up your content with the right semantics, applying the required styling would have been simple.
– Alohci
Nov 14 '18 at 17:06
Note that
div
elements are not allowed as children of a` ul. The only permitted children are
li. i fyou want to group
li` use a submenu.– Paulie_D
Nov 14 '18 at 16:58
Note that
div
elements are not allowed as children of a` ul. The only permitted children are
li. i fyou want to group
li` use a submenu.– Paulie_D
Nov 14 '18 at 16:58
Semantically, you don't have one list, you have two. If you marked up your content with the right semantics, applying the required styling would have been simple.
– Alohci
Nov 14 '18 at 17:06
Semantically, you don't have one list, you have two. If you marked up your content with the right semantics, applying the required styling would have been simple.
– Alohci
Nov 14 '18 at 17:06
add a comment |
4 Answers
4
active
oldest
votes
You can use two ul's
<nav class="navbar">
<ul class="leftnav">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="members.html">Members</a></li>
<li><a href="smash.html">Smash Club</a></li>
</ul>
<ul class="medianav">
<li><a href="https://www.youtube.com">YouTube</a></li>
<li><a href="https://discord.gg">Discord</a></li>
<li><a href="#">Twitter</a></li>
</ul>
you need to adjust your css as well
.medianav, .medianav li {
float: right;
}
.leftnav, .leftnav li {
float: left;
}
.navbar, .navbar ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333333;
display: block;
}
add a comment |
There was a structure issue. now Nav has 2 lists
.navbar {
font-family: 'Open Sans', sans-serif;
background-color: #333333;
padding: 0;
min-height: 1px !important;
/* Overrided the default min-height of navbar which is 50px by-default in Bootstrap */
}
.navbar ul {
list-style-type: none;
margin: 0;
padding: 0;
}
.navbar li {
float: left;
}
.navbar li a {
display: block;
color: white;
text-align: center;
padding: 10px;
text-decoration: none;
}
/* Links to Social Media */
.medianav li:nth-child(1) {
background-color: #ff0000;
}
.medianav li:nth-child(1):hover {
background-color: #ff6666;
}
.medianav li:nth-child(2) {
background-color: #7289DA;
}
.medianav li:nth-child(2):hover {
background-color: #99AAB5;
}
.medianav li:nth-child(3) {
background-color: #1da1f2;
}
.medianav li:nth-child(3):hover {
background-color: #49baff;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<nav class="navbar">
<ul class="navigation-links pull-left">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="members.html">Members</a></li>
<li><a href="smash.html">Smash Club</a></li>
</ul>
<ul class="medianav pull-right">
<li><a href="https://www.youtube.com">YouTube</a></li>
<li><a href="https://discord.gg">Discord</a></li>
<li><a href="#">Twitter</a></li>
</ul>
</nav>
add a comment |
Your HTML syntax is a little bit off, you didn't close the nav and div properly.
Trying doing your HTML like this, it worked for me:
<nav class="navbar">
<ul>
<div class="leftnav">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="members.html">Members</a></li>
<li><a href="smash.html">Smash Club</a></li>
</div>
<div class="medianav">
<li><a href="https://www.youtube.com">YouTube</a></li>
<li><a href="https://discord.gg">Discord</a></li>
<li><a href="#">Twitter</a></li>
</div>
</ul>
</nav>
add a comment |
You openend two <div>
tag and closed it with a </nav>
tag. Just replace the two </nav>
with </div>
:
.navbar {
font-family: 'Open Sans', sans-serif;
}
.navbar ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333333;
display: block;
}
.navbar li a {
display: block;
color: white;
text-align: center;
padding: 10px;
text-decoration: none;
}
/* On-site navigation */
.leftnav li {
float: left;
}
.leftnav li:hover {
background-color: #111111;
}
/* Links to Social Media */
.medianav li {
float: right;
}
.medianav li:nth-child(1) {
background-color: #ff0000;
}
.medianav li:nth-child(1):hover {
background-color: #ff6666;
}
.medianav li:nth-child(2) {
background-color: #7289DA;
}
.medianav li:nth-child(2):hover {
background-color: #99AAB5;
}
.medianav li:nth-child(3) {
background-color: #1da1f2;
}
.medianav li:nth-child(3):hover {
background-color: #49baff;
}
<nav class="navbar">
<ul>
<div class="leftnav">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="members.html">Members</a></li>
<li><a href="smash.html">Smash Club</a></li>
</div>
<div class="medianav">
<li><a href="https://www.youtube.com">YouTube</a></li>
<li><a href="https://discord.gg">Discord</a></li>
<li><a href="#">Twitter</a></li>
</div>
</ul>
</nav>
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53302564%2fhow-to-have-a-div-element-that-groups-li-elements-inside-of-ul%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can use two ul's
<nav class="navbar">
<ul class="leftnav">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="members.html">Members</a></li>
<li><a href="smash.html">Smash Club</a></li>
</ul>
<ul class="medianav">
<li><a href="https://www.youtube.com">YouTube</a></li>
<li><a href="https://discord.gg">Discord</a></li>
<li><a href="#">Twitter</a></li>
</ul>
you need to adjust your css as well
.medianav, .medianav li {
float: right;
}
.leftnav, .leftnav li {
float: left;
}
.navbar, .navbar ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333333;
display: block;
}
add a comment |
You can use two ul's
<nav class="navbar">
<ul class="leftnav">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="members.html">Members</a></li>
<li><a href="smash.html">Smash Club</a></li>
</ul>
<ul class="medianav">
<li><a href="https://www.youtube.com">YouTube</a></li>
<li><a href="https://discord.gg">Discord</a></li>
<li><a href="#">Twitter</a></li>
</ul>
you need to adjust your css as well
.medianav, .medianav li {
float: right;
}
.leftnav, .leftnav li {
float: left;
}
.navbar, .navbar ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333333;
display: block;
}
add a comment |
You can use two ul's
<nav class="navbar">
<ul class="leftnav">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="members.html">Members</a></li>
<li><a href="smash.html">Smash Club</a></li>
</ul>
<ul class="medianav">
<li><a href="https://www.youtube.com">YouTube</a></li>
<li><a href="https://discord.gg">Discord</a></li>
<li><a href="#">Twitter</a></li>
</ul>
you need to adjust your css as well
.medianav, .medianav li {
float: right;
}
.leftnav, .leftnav li {
float: left;
}
.navbar, .navbar ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333333;
display: block;
}
You can use two ul's
<nav class="navbar">
<ul class="leftnav">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="members.html">Members</a></li>
<li><a href="smash.html">Smash Club</a></li>
</ul>
<ul class="medianav">
<li><a href="https://www.youtube.com">YouTube</a></li>
<li><a href="https://discord.gg">Discord</a></li>
<li><a href="#">Twitter</a></li>
</ul>
you need to adjust your css as well
.medianav, .medianav li {
float: right;
}
.leftnav, .leftnav li {
float: left;
}
.navbar, .navbar ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333333;
display: block;
}
answered Nov 14 '18 at 15:02
SpiritSpirit
917
917
add a comment |
add a comment |
There was a structure issue. now Nav has 2 lists
.navbar {
font-family: 'Open Sans', sans-serif;
background-color: #333333;
padding: 0;
min-height: 1px !important;
/* Overrided the default min-height of navbar which is 50px by-default in Bootstrap */
}
.navbar ul {
list-style-type: none;
margin: 0;
padding: 0;
}
.navbar li {
float: left;
}
.navbar li a {
display: block;
color: white;
text-align: center;
padding: 10px;
text-decoration: none;
}
/* Links to Social Media */
.medianav li:nth-child(1) {
background-color: #ff0000;
}
.medianav li:nth-child(1):hover {
background-color: #ff6666;
}
.medianav li:nth-child(2) {
background-color: #7289DA;
}
.medianav li:nth-child(2):hover {
background-color: #99AAB5;
}
.medianav li:nth-child(3) {
background-color: #1da1f2;
}
.medianav li:nth-child(3):hover {
background-color: #49baff;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<nav class="navbar">
<ul class="navigation-links pull-left">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="members.html">Members</a></li>
<li><a href="smash.html">Smash Club</a></li>
</ul>
<ul class="medianav pull-right">
<li><a href="https://www.youtube.com">YouTube</a></li>
<li><a href="https://discord.gg">Discord</a></li>
<li><a href="#">Twitter</a></li>
</ul>
</nav>
add a comment |
There was a structure issue. now Nav has 2 lists
.navbar {
font-family: 'Open Sans', sans-serif;
background-color: #333333;
padding: 0;
min-height: 1px !important;
/* Overrided the default min-height of navbar which is 50px by-default in Bootstrap */
}
.navbar ul {
list-style-type: none;
margin: 0;
padding: 0;
}
.navbar li {
float: left;
}
.navbar li a {
display: block;
color: white;
text-align: center;
padding: 10px;
text-decoration: none;
}
/* Links to Social Media */
.medianav li:nth-child(1) {
background-color: #ff0000;
}
.medianav li:nth-child(1):hover {
background-color: #ff6666;
}
.medianav li:nth-child(2) {
background-color: #7289DA;
}
.medianav li:nth-child(2):hover {
background-color: #99AAB5;
}
.medianav li:nth-child(3) {
background-color: #1da1f2;
}
.medianav li:nth-child(3):hover {
background-color: #49baff;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<nav class="navbar">
<ul class="navigation-links pull-left">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="members.html">Members</a></li>
<li><a href="smash.html">Smash Club</a></li>
</ul>
<ul class="medianav pull-right">
<li><a href="https://www.youtube.com">YouTube</a></li>
<li><a href="https://discord.gg">Discord</a></li>
<li><a href="#">Twitter</a></li>
</ul>
</nav>
add a comment |
There was a structure issue. now Nav has 2 lists
.navbar {
font-family: 'Open Sans', sans-serif;
background-color: #333333;
padding: 0;
min-height: 1px !important;
/* Overrided the default min-height of navbar which is 50px by-default in Bootstrap */
}
.navbar ul {
list-style-type: none;
margin: 0;
padding: 0;
}
.navbar li {
float: left;
}
.navbar li a {
display: block;
color: white;
text-align: center;
padding: 10px;
text-decoration: none;
}
/* Links to Social Media */
.medianav li:nth-child(1) {
background-color: #ff0000;
}
.medianav li:nth-child(1):hover {
background-color: #ff6666;
}
.medianav li:nth-child(2) {
background-color: #7289DA;
}
.medianav li:nth-child(2):hover {
background-color: #99AAB5;
}
.medianav li:nth-child(3) {
background-color: #1da1f2;
}
.medianav li:nth-child(3):hover {
background-color: #49baff;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<nav class="navbar">
<ul class="navigation-links pull-left">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="members.html">Members</a></li>
<li><a href="smash.html">Smash Club</a></li>
</ul>
<ul class="medianav pull-right">
<li><a href="https://www.youtube.com">YouTube</a></li>
<li><a href="https://discord.gg">Discord</a></li>
<li><a href="#">Twitter</a></li>
</ul>
</nav>
There was a structure issue. now Nav has 2 lists
.navbar {
font-family: 'Open Sans', sans-serif;
background-color: #333333;
padding: 0;
min-height: 1px !important;
/* Overrided the default min-height of navbar which is 50px by-default in Bootstrap */
}
.navbar ul {
list-style-type: none;
margin: 0;
padding: 0;
}
.navbar li {
float: left;
}
.navbar li a {
display: block;
color: white;
text-align: center;
padding: 10px;
text-decoration: none;
}
/* Links to Social Media */
.medianav li:nth-child(1) {
background-color: #ff0000;
}
.medianav li:nth-child(1):hover {
background-color: #ff6666;
}
.medianav li:nth-child(2) {
background-color: #7289DA;
}
.medianav li:nth-child(2):hover {
background-color: #99AAB5;
}
.medianav li:nth-child(3) {
background-color: #1da1f2;
}
.medianav li:nth-child(3):hover {
background-color: #49baff;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<nav class="navbar">
<ul class="navigation-links pull-left">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="members.html">Members</a></li>
<li><a href="smash.html">Smash Club</a></li>
</ul>
<ul class="medianav pull-right">
<li><a href="https://www.youtube.com">YouTube</a></li>
<li><a href="https://discord.gg">Discord</a></li>
<li><a href="#">Twitter</a></li>
</ul>
</nav>
.navbar {
font-family: 'Open Sans', sans-serif;
background-color: #333333;
padding: 0;
min-height: 1px !important;
/* Overrided the default min-height of navbar which is 50px by-default in Bootstrap */
}
.navbar ul {
list-style-type: none;
margin: 0;
padding: 0;
}
.navbar li {
float: left;
}
.navbar li a {
display: block;
color: white;
text-align: center;
padding: 10px;
text-decoration: none;
}
/* Links to Social Media */
.medianav li:nth-child(1) {
background-color: #ff0000;
}
.medianav li:nth-child(1):hover {
background-color: #ff6666;
}
.medianav li:nth-child(2) {
background-color: #7289DA;
}
.medianav li:nth-child(2):hover {
background-color: #99AAB5;
}
.medianav li:nth-child(3) {
background-color: #1da1f2;
}
.medianav li:nth-child(3):hover {
background-color: #49baff;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<nav class="navbar">
<ul class="navigation-links pull-left">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="members.html">Members</a></li>
<li><a href="smash.html">Smash Club</a></li>
</ul>
<ul class="medianav pull-right">
<li><a href="https://www.youtube.com">YouTube</a></li>
<li><a href="https://discord.gg">Discord</a></li>
<li><a href="#">Twitter</a></li>
</ul>
</nav>
.navbar {
font-family: 'Open Sans', sans-serif;
background-color: #333333;
padding: 0;
min-height: 1px !important;
/* Overrided the default min-height of navbar which is 50px by-default in Bootstrap */
}
.navbar ul {
list-style-type: none;
margin: 0;
padding: 0;
}
.navbar li {
float: left;
}
.navbar li a {
display: block;
color: white;
text-align: center;
padding: 10px;
text-decoration: none;
}
/* Links to Social Media */
.medianav li:nth-child(1) {
background-color: #ff0000;
}
.medianav li:nth-child(1):hover {
background-color: #ff6666;
}
.medianav li:nth-child(2) {
background-color: #7289DA;
}
.medianav li:nth-child(2):hover {
background-color: #99AAB5;
}
.medianav li:nth-child(3) {
background-color: #1da1f2;
}
.medianav li:nth-child(3):hover {
background-color: #49baff;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<nav class="navbar">
<ul class="navigation-links pull-left">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="members.html">Members</a></li>
<li><a href="smash.html">Smash Club</a></li>
</ul>
<ul class="medianav pull-right">
<li><a href="https://www.youtube.com">YouTube</a></li>
<li><a href="https://discord.gg">Discord</a></li>
<li><a href="#">Twitter</a></li>
</ul>
</nav>
answered Nov 14 '18 at 15:00
Umair QaziUmair Qazi
1514
1514
add a comment |
add a comment |
Your HTML syntax is a little bit off, you didn't close the nav and div properly.
Trying doing your HTML like this, it worked for me:
<nav class="navbar">
<ul>
<div class="leftnav">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="members.html">Members</a></li>
<li><a href="smash.html">Smash Club</a></li>
</div>
<div class="medianav">
<li><a href="https://www.youtube.com">YouTube</a></li>
<li><a href="https://discord.gg">Discord</a></li>
<li><a href="#">Twitter</a></li>
</div>
</ul>
</nav>
add a comment |
Your HTML syntax is a little bit off, you didn't close the nav and div properly.
Trying doing your HTML like this, it worked for me:
<nav class="navbar">
<ul>
<div class="leftnav">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="members.html">Members</a></li>
<li><a href="smash.html">Smash Club</a></li>
</div>
<div class="medianav">
<li><a href="https://www.youtube.com">YouTube</a></li>
<li><a href="https://discord.gg">Discord</a></li>
<li><a href="#">Twitter</a></li>
</div>
</ul>
</nav>
add a comment |
Your HTML syntax is a little bit off, you didn't close the nav and div properly.
Trying doing your HTML like this, it worked for me:
<nav class="navbar">
<ul>
<div class="leftnav">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="members.html">Members</a></li>
<li><a href="smash.html">Smash Club</a></li>
</div>
<div class="medianav">
<li><a href="https://www.youtube.com">YouTube</a></li>
<li><a href="https://discord.gg">Discord</a></li>
<li><a href="#">Twitter</a></li>
</div>
</ul>
</nav>
Your HTML syntax is a little bit off, you didn't close the nav and div properly.
Trying doing your HTML like this, it worked for me:
<nav class="navbar">
<ul>
<div class="leftnav">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="members.html">Members</a></li>
<li><a href="smash.html">Smash Club</a></li>
</div>
<div class="medianav">
<li><a href="https://www.youtube.com">YouTube</a></li>
<li><a href="https://discord.gg">Discord</a></li>
<li><a href="#">Twitter</a></li>
</div>
</ul>
</nav>
answered Nov 14 '18 at 14:42
RokoRoko
10312
10312
add a comment |
add a comment |
You openend two <div>
tag and closed it with a </nav>
tag. Just replace the two </nav>
with </div>
:
.navbar {
font-family: 'Open Sans', sans-serif;
}
.navbar ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333333;
display: block;
}
.navbar li a {
display: block;
color: white;
text-align: center;
padding: 10px;
text-decoration: none;
}
/* On-site navigation */
.leftnav li {
float: left;
}
.leftnav li:hover {
background-color: #111111;
}
/* Links to Social Media */
.medianav li {
float: right;
}
.medianav li:nth-child(1) {
background-color: #ff0000;
}
.medianav li:nth-child(1):hover {
background-color: #ff6666;
}
.medianav li:nth-child(2) {
background-color: #7289DA;
}
.medianav li:nth-child(2):hover {
background-color: #99AAB5;
}
.medianav li:nth-child(3) {
background-color: #1da1f2;
}
.medianav li:nth-child(3):hover {
background-color: #49baff;
}
<nav class="navbar">
<ul>
<div class="leftnav">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="members.html">Members</a></li>
<li><a href="smash.html">Smash Club</a></li>
</div>
<div class="medianav">
<li><a href="https://www.youtube.com">YouTube</a></li>
<li><a href="https://discord.gg">Discord</a></li>
<li><a href="#">Twitter</a></li>
</div>
</ul>
</nav>
add a comment |
You openend two <div>
tag and closed it with a </nav>
tag. Just replace the two </nav>
with </div>
:
.navbar {
font-family: 'Open Sans', sans-serif;
}
.navbar ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333333;
display: block;
}
.navbar li a {
display: block;
color: white;
text-align: center;
padding: 10px;
text-decoration: none;
}
/* On-site navigation */
.leftnav li {
float: left;
}
.leftnav li:hover {
background-color: #111111;
}
/* Links to Social Media */
.medianav li {
float: right;
}
.medianav li:nth-child(1) {
background-color: #ff0000;
}
.medianav li:nth-child(1):hover {
background-color: #ff6666;
}
.medianav li:nth-child(2) {
background-color: #7289DA;
}
.medianav li:nth-child(2):hover {
background-color: #99AAB5;
}
.medianav li:nth-child(3) {
background-color: #1da1f2;
}
.medianav li:nth-child(3):hover {
background-color: #49baff;
}
<nav class="navbar">
<ul>
<div class="leftnav">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="members.html">Members</a></li>
<li><a href="smash.html">Smash Club</a></li>
</div>
<div class="medianav">
<li><a href="https://www.youtube.com">YouTube</a></li>
<li><a href="https://discord.gg">Discord</a></li>
<li><a href="#">Twitter</a></li>
</div>
</ul>
</nav>
add a comment |
You openend two <div>
tag and closed it with a </nav>
tag. Just replace the two </nav>
with </div>
:
.navbar {
font-family: 'Open Sans', sans-serif;
}
.navbar ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333333;
display: block;
}
.navbar li a {
display: block;
color: white;
text-align: center;
padding: 10px;
text-decoration: none;
}
/* On-site navigation */
.leftnav li {
float: left;
}
.leftnav li:hover {
background-color: #111111;
}
/* Links to Social Media */
.medianav li {
float: right;
}
.medianav li:nth-child(1) {
background-color: #ff0000;
}
.medianav li:nth-child(1):hover {
background-color: #ff6666;
}
.medianav li:nth-child(2) {
background-color: #7289DA;
}
.medianav li:nth-child(2):hover {
background-color: #99AAB5;
}
.medianav li:nth-child(3) {
background-color: #1da1f2;
}
.medianav li:nth-child(3):hover {
background-color: #49baff;
}
<nav class="navbar">
<ul>
<div class="leftnav">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="members.html">Members</a></li>
<li><a href="smash.html">Smash Club</a></li>
</div>
<div class="medianav">
<li><a href="https://www.youtube.com">YouTube</a></li>
<li><a href="https://discord.gg">Discord</a></li>
<li><a href="#">Twitter</a></li>
</div>
</ul>
</nav>
You openend two <div>
tag and closed it with a </nav>
tag. Just replace the two </nav>
with </div>
:
.navbar {
font-family: 'Open Sans', sans-serif;
}
.navbar ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333333;
display: block;
}
.navbar li a {
display: block;
color: white;
text-align: center;
padding: 10px;
text-decoration: none;
}
/* On-site navigation */
.leftnav li {
float: left;
}
.leftnav li:hover {
background-color: #111111;
}
/* Links to Social Media */
.medianav li {
float: right;
}
.medianav li:nth-child(1) {
background-color: #ff0000;
}
.medianav li:nth-child(1):hover {
background-color: #ff6666;
}
.medianav li:nth-child(2) {
background-color: #7289DA;
}
.medianav li:nth-child(2):hover {
background-color: #99AAB5;
}
.medianav li:nth-child(3) {
background-color: #1da1f2;
}
.medianav li:nth-child(3):hover {
background-color: #49baff;
}
<nav class="navbar">
<ul>
<div class="leftnav">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="members.html">Members</a></li>
<li><a href="smash.html">Smash Club</a></li>
</div>
<div class="medianav">
<li><a href="https://www.youtube.com">YouTube</a></li>
<li><a href="https://discord.gg">Discord</a></li>
<li><a href="#">Twitter</a></li>
</div>
</ul>
</nav>
.navbar {
font-family: 'Open Sans', sans-serif;
}
.navbar ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333333;
display: block;
}
.navbar li a {
display: block;
color: white;
text-align: center;
padding: 10px;
text-decoration: none;
}
/* On-site navigation */
.leftnav li {
float: left;
}
.leftnav li:hover {
background-color: #111111;
}
/* Links to Social Media */
.medianav li {
float: right;
}
.medianav li:nth-child(1) {
background-color: #ff0000;
}
.medianav li:nth-child(1):hover {
background-color: #ff6666;
}
.medianav li:nth-child(2) {
background-color: #7289DA;
}
.medianav li:nth-child(2):hover {
background-color: #99AAB5;
}
.medianav li:nth-child(3) {
background-color: #1da1f2;
}
.medianav li:nth-child(3):hover {
background-color: #49baff;
}
<nav class="navbar">
<ul>
<div class="leftnav">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="members.html">Members</a></li>
<li><a href="smash.html">Smash Club</a></li>
</div>
<div class="medianav">
<li><a href="https://www.youtube.com">YouTube</a></li>
<li><a href="https://discord.gg">Discord</a></li>
<li><a href="#">Twitter</a></li>
</div>
</ul>
</nav>
.navbar {
font-family: 'Open Sans', sans-serif;
}
.navbar ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333333;
display: block;
}
.navbar li a {
display: block;
color: white;
text-align: center;
padding: 10px;
text-decoration: none;
}
/* On-site navigation */
.leftnav li {
float: left;
}
.leftnav li:hover {
background-color: #111111;
}
/* Links to Social Media */
.medianav li {
float: right;
}
.medianav li:nth-child(1) {
background-color: #ff0000;
}
.medianav li:nth-child(1):hover {
background-color: #ff6666;
}
.medianav li:nth-child(2) {
background-color: #7289DA;
}
.medianav li:nth-child(2):hover {
background-color: #99AAB5;
}
.medianav li:nth-child(3) {
background-color: #1da1f2;
}
.medianav li:nth-child(3):hover {
background-color: #49baff;
}
<nav class="navbar">
<ul>
<div class="leftnav">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="members.html">Members</a></li>
<li><a href="smash.html">Smash Club</a></li>
</div>
<div class="medianav">
<li><a href="https://www.youtube.com">YouTube</a></li>
<li><a href="https://discord.gg">Discord</a></li>
<li><a href="#">Twitter</a></li>
</div>
</ul>
</nav>
edited Nov 14 '18 at 21:35
answered Nov 14 '18 at 14:40
MaartiMaarti
1,8523822
1,8523822
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53302564%2fhow-to-have-a-div-element-that-groups-li-elements-inside-of-ul%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Note that
div
elements are not allowed as children of a` ul. The only permitted children are
li. i fyou want to group
li` use a submenu.– Paulie_D
Nov 14 '18 at 16:58
Semantically, you don't have one list, you have two. If you marked up your content with the right semantics, applying the required styling would have been simple.
– Alohci
Nov 14 '18 at 17:06