Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
brandonlind2
7,823 PointsWhy isn't my main-title and active classes working?
The css properties I'm applying to the main-title and active classes aren't working for some reason
!DOCTYPE HTML>
<html>
<head>
<title>TEST</title>
<meta charset="utf-8">
<link rel="stylesheet" href="css/main.css">
</head>
<body>
<header>
<h1 class="main-title">This Is a Test</h1>
<nav>
<ul>
<li class="main-nav" class="active"><a href="index.html">HOME</a></li>
<li class="main-nav">
<span> Content 1 </span>
<ul class="sub-nav">
<li><a href="page1.html">Page 1</a></li>
<li><a href="page2.html">Page 2</a></li>
<li><a href="page3.html">Page 3</a></li>
</ul>
</li>
<li class="main-nav">
<span> Content 2 </span>
<ul class="sub-nav">
<li><a href="page4.html">Page 4</a></li>
<li><a href="page5.html">Page 5</a></li>
<li><a href="page6.html">Page 6</a></li>
</ul>
</li>
<li class="main-nav">
<span> Content 3 </span>
<ul class="sub-nav">
<li><a href="page7.html">Page 7</a></li>
<li><a href="page1.html">Page 8</a></li>
<li><a href="page1.html">Page 9</a></li>
</ul>
</li>
</ul>
</nav>
</header>
<section>
</section>
<footer>
</footer>
</body>
</html>
html{
font-size: 1em;
}
body {
margin: auto;
padding: 0;
max-width: 100%;
}
header {
margin: auto;
padding: 0;
max-width: 100%;
}
/***********************this isnt working
.main-title {
font-size: 2em;
}
********************************************/
nav {
color: white;
background-color: orange;
margin: auto;
padding: 0;
max-width: 100%;
}
nav li > span, nav a{
font-size: 1.5em;
}
nav ul {
text-align: right;
max-width: 100%;
margin: auto;
padding: 0 5% 0 0;
}
nav li {
border-style: solid;
border-width: 0 1px 0 0;
border-color: rgba(0,0,0,.1);
display: inline-block;
list-style: none;
margin: 3px;
padding: 2px;
max-width: 100%;
}
nav a {
text-decoration: none;
}
nav a:visited {
color: white;
/**************************this isnt working
.active {
background-color: grey;
}
***********************************************/
.main-nav {
position: relative;
}
.sub-nav{
position: absolute;
display: none;
}
.main-nav:hover .sub-nav{
display: block;
}
section {
margin: auto;
padding: 0;
max-width: 100%;
}
footer {
margin: auto;
padding: 0;
max-width: 100%;
}
2 Answers
brandonlind2
7,823 PointsI figured it out I added two class attributes intead of putting two values in one class attribute for example class="main-nav active" vs class="main-nav" class="active"
alastair cooper
30,618 PointsThey both work in my browser. However, I had to add a closing brace to the css rule before .active to get it to work, and I had to add an opening brace to the DOCTYPE declaration to get the .main-title to work.
I expect these were just copy and paste errors to the question post, but it's worth checking in case that is where your problem lies.
Nice drop down navs by the way.
brandonlind2
7,823 Pointsyeah those were copy and paste error, that's weird I wonder why its working in your browser but not mine. Are you using chrome? Thanks :)