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 trialBen Moore
2,628 PointsMy nav element is being overwritten by the footer element
In the code below, the nav properties, namely text-align are being overwritten by the footer element and the code inside the nav's curly braces are not taking effect. When I place the nav element under footer in my .css document, the nav is centered on the screen and the footer is set back to the default left position. Because they are different elements with different tags, I don't know why they are effecting one another.
Code:
/******************************************** \ \ CSS Styling File \ Last Edited: 7/22/2014 \ Written By: Ben Moore \ *********************************************/
/******************************************** General ********************************************/
body { font-family: 'Open Sans', sans-serif; }
wrapper
{ max-width: 940px; margin: 0 auto; padding: 0 5%; }
a { text-decoration: none; }
/******************************************** Heading ********************************************/
logo
{ text-align: center; margin: 0; }
h1 { font-family: 'Changa One', sans-serif; margin: 15px 0; font-size 1.75em; font-weight: normal; line-height: 0.8em; }
h2 { font-size: 0.75em; margin: -5px 0 0; font-weight: normal; };
/******************************************** Navigation ********************************************/
nav { text-align: center; padding: 10px 0; margin: 20px 0 0; }
/******************************************** Footer ********************************************/
footer { font-size: 0.75em; text-align: center; padding-top: 50px; color: #cccccc; }
/******************************************** Colors ********************************************/
/* Site Body */ body { background-color: #ffffff; color: #999999; }
/Green Header/ header { background: #6ab47b; border-color: #599a68; }
/naigation Background/ nav { background: #599a68; }
/Name/Occupation Text/ h1, h2 { color: #ffffff; }
/Anchors/ a { color: #6ab47b; }
/Color For A Nav Link/
nav a, nav a:visited
{
color: #ffffff;
}
/Selected/Hovered Nav Link/ nav a.selected, nav a:hover { color: #32673f; }
2 Answers
Ben Moore
2,628 PointsI found the answer: There was an unnecessary ";" after the h2 closing curly bracket. When I removed this, the code executed as expected. I apologize for such a silly error. Thank you for your assistance.
Jason Anello
Courses Plus Student 94,610 PointsGlad you figured it out. I missed it but it looks like Derrick had found it. The end of the code block mentions a stray semicolon was removed.
It looks like this caused the browser to ignore the following rule and continue on with what's next.
Derrick Mull
18,518 PointsThose pesky semi-colons.
Derrick Mull
18,518 Points /******************************************** \
\ CSS Styling File \ Last Edited: 7/22/2014 \ Written By: Ben Moore \ *********************************************/
/******************************************** General ********************************************/
body {
font-family: 'Open Sans', sans-serif;
}
wrapper {
max-width: 940px;
margin: 0 auto;
padding: 0 5%; }
a {
text-decoration: none;
}
/******************************************** Heading ********************************************/
logo {
text-align: center; margin: 0;
}
h1 {
font-family: 'Changa One', sans-serif;
margin: 15px 0; font-size 1.75em;
font-weight: normal;
line-height: 0.8em;
}
h2 {
font-size: 0.75em;
margin: -5px 0 0;
font-weight: normal;
}
/******************************************** Navigation ********************************************/
nav {
text-align: center;
padding: 10px 0;
margin: 20px 0 0;
}
/******************************************** Footer ********************************************/
footer {
font-size: 0.75em;
text-align: center;
padding-top: 50px;
color: #cccccc;
}
/******************************************** Colors ********************************************/
/* Site Body */
body {
background-color: #ffffff;
color: #999999;
}
/Green Header/
header {
background: #6ab47b;
border-color: #599a68;
}
/**** navigation Background ****/
nav {
background: #599a68;
}
/*** Name/Occupation Text ***/
h1, h2 {
color: #ffffff;
}
/***Anchors***/
a {
color: #6ab47b;
}
/***Color For A Nav Link***/
nav a, nav a:visited {
color: #ffffff;
}
/***Selected/Hovered Nav Link***/
nav a.selected, nav a:hover {
color: #32673f;
}
```
maybe this will help with some code cleanup... found a stray semicolon that was removed.
Derrick Mull
18,518 PointsSeeing the HTML would be helpful to diagnose.
Jason Anello
Courses Plus Student 94,610 PointsIf the stray semicolon you removed was after the h2 then I think that was the problem.
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsHi Ben,
What does your html look like?
Here's a thread on how to post code in the forums: https://teamtreehouse.com/forum/posting-code-to-the-forum