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

Kevin Faust
15,353 Pointsfirst time building a website help
Hey everyone,
so I finished the How to build a website, CSS basics, and CSS selectors part and now im attempting to build a simple website. However i came across a few things:
what are some things I should always have in my head tag? aside from my title, i have a "meta charset="utf-8" tag, a link tag to my css, and a link tag to my normalize.css. is there anything else I should include?
also when i put an image as my header background, there is a white space above my image 50px tall. so right now im forced to make my margin-top: -50px. but i dont think this is supposed to happen so im just wondering if anyone knows?
one last thing is that when i center my text and put a bottom border, the border runs across the entire page which again isnt supposed to happen. the border should only be confined to the length of the text.
im using treehouse workspace to build my website.
any ideas? thanks
2 Answers

Kevin Korte
28,149 PointsYou'll have to use your dev inspector to solve these sorts of things. I'll tell you what's going on, and you'll have to use your own dev inspector to verify the solution.
The white bar up top, it's coming from default browser styling. More specifically, the <ul>
tag. Because you don't have a margin set, the browsers kindly I say sarcastically set a 16px margin top and bottom. If you zero out the margin on the list, the white bar goes away.
The extra padding is coming from your style.css file, specifically line 45. You have this rule
#nav a, #nav li {
font-size: 1.5rem;
text-decoration: none;
display: inline-block;
list-style-type: none;
margin: 15px 0 0 15px;
font-family: cursive;
}
Which means for every list item, and every anchor in a nav element, add all these styles. So the list item gets its white background from the selected class, but it also gets margin: 15px 0 0 15px
. You archor element nested inside of the list item, get these exact same rules, so it gets another margin: 15px 0 0 15px
.
When you hover and your anchor gets pushed down, it's because your adding a 3px border to a hovered anchor item. The box model by default adds that extra 3 px each side outside of any padding, but inside the margin, which means your element grows, and pushes the elements around it.
To combate this, I might add a `3px solid transparent
border around the element when not hovered, so the extra border space is taken into account when the page is painted, so when you hover and see the border, box models don't collide since the space was already taken, just invisible before.
So to I might try this
#nav a {
border: 3px solid transparent;
}
To get your H1 tags correct, we need to modify your HTML and CSS. We will need to introduce a wrapper div, so we want to add this to your CSS
.welcome {
display: inline-block;
}
Now your bottom border should behave as you want, but the text isn't centered, right? So, we need a parent to contain it. So you'll need to wrap your H1 in a div, I chose a div with the class of center, like so
<div class="center">
<h1 class="welcome">Welcome to Korea</h1>
</div>
And to make our div do something, all we have to do at this point is set our text align, and it'll align it's children, so
.center {
text-align: center;
}
And that should be what you want.

Kevin Korte
28,149 PointsAwesome for building your first site. Seeing your workspace will help, but in general you have a good start with your head. Later on you'll probably end up adding some more meta tags to help with SEO, javascript tags, etc. Don't feel you have to bloat your head though.
As far as your mysterious white space, I'd look and see if you have a body margin somewhere, or a collapased div with a margin. Inspecting with your Chrome dev tools should help you.
As far as your text border, it depends on the structure. It sounds like you're applying the border to a block level element which is spanning the length of the page. You may need to slightly modify your html or css to make sure that the element that is getting the border is an inline element, not a block element.

Kevin Faust
15,353 PointsHey Kevin,
I checked around and Im really not sure. It must be something that im probably overlooking or theres something wrong in my code.
heres a screenshot of my workspace: https://w.trhou.se/m9qpjllas2
i added a menu in the top but there are problems there now as well. i added a white background color to the "selected" class but its acting weird as if theres left and top padding. also when i hover over the menu links, the text shifts downwards and pushes the things below it.
i tried changing the welcome class (the one with the border problem) to inline but then it ignored my text-align property.
Kevin Faust
15,353 PointsKevin Faust
15,353 PointsHey Kevin, Thanks so much. I see now where I went wrong and what I had to do to fix it. I also never knew about using a transparent border to fix it.
cheers