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

HTML How to Make a Website Adding Pages to a Website Make an About Page

styling questions

Hello!

1) When would you use just the background property over background-color?

2) The instructor said that by '-5px 'in 'margin: -5px 0 0;' we are pulling the element closer to the other element near it. The margins on elements aren't that wide, so how would you know that margin: h2{ margin -5px 0 0} is better for your code than h2 {margin -8px 0 0 }?

3) In the lecture video, Nick resizes the browser,and he says 'If We resize our browser, we can see our mobile website coming together'. Does it mean that I should keep resizing my broswer when I am designing the layout of my page? What is the benefit of doing that?

4) When we are designing a navigation with UL in it, why do we place the style rule: 'list-style:none' in nav ul? why not place it in the LI like this: nav ul li { list-style:none; display: in-block}

Cheers!!

2 Answers

Jonas Mørkeby
Jonas Mørkeby
3,530 Points

Hello.

1) For example the background-color property is very specific to setting the color of the background, and the background-repeat is specific to setting if you want the background (if it is an image) to be repeated and how. Within the background property you will be able to specify multiple values like this:

body {
background: #00ff00 url('smiley.gif') no-repeat;
}

This will give you the image background (with no repeat) if possible and the color background as a fallback. There is no right or wrong here, so just choose the one you like.

2) You wouldn't know if one margin is better than the other without trying. I guess that Nick just uses the margin he knows will work for his layout. So just change it and see what happens... You can always change it back if -5px turned out to be the better choice.

3) When you are designing a responsive web page, then you need media queries to give your web page another layout, if the device it is opened on has another width than your standard computer screen. Media queries will make the layout fit the screen size. This means that you could either build your web page and then open it on every device you would like it to work on. Or you could simply resize your browser on your computer screen to force the web page to shift layouts. This is only for the sake of easier testing. The media queries are set to shift layout if the browser width is within a given range. Therefore changing the browser's width will change the layout on the web page.

4) You could use the style="list-style:none;" on the li instead of the ul... It would give the same effect to the list. But if you look at it this way:

<ul style="list-style:none;">
<li>1</li>
<li>2</li>
</ul>
<ul>
<li style="list-style:none;">1</li>
<li style="list-style:none;">2</li>
</ul>

The first one makes more sense because you would have less code.

I hope this helps...

Regards, Jonas

thanks Jonas!!!!