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

General Discussion

Liliana Leyva
Liliana Leyva
3,711 Points

How can I organize this code better?

I am doing a website to practice.

body {
    margin:  0 auto;




}

/*************************************
**HEADER*****************************/
.heading {
    padding-top: 10px;
    height: 300px;
    background: #fcf5c1;
    background-size: cover;




}

.heading img {
    display: block;

    width: 280px;
    margin: 0 auto;

    padding: 300px 100px -100px 100px;

}

h1 {

    font-family: 'Spirax', cursive;
    font-size: 1.2rem;
    text-align: center;
    color: brown;
    font-weight: normal;
    margin-top: 5px;
    margin-left: 6px;
   }






/*************************************
**NAVIGATION*******************/

nav {
    color: deeppink;
    float:  left;
    padding-top: -14px;
    padding-left: -10px;
    background: #fcf5c1;
    width: 100%;
    border-bottom: 6px dotted pink;


    font-size: 1.2rem;



}

nav li {
     display: inline-block;
     padding-right: 15px;
     padding-left: 15px;




}

nav ul{

    list-style: none;
  margin: 0 0;
  padding: 0px;
  padding-bottom: -10px;


}

2 Answers

Dominiks Laukmanis
PLUS
Dominiks Laukmanis
Courses Plus Student 2,829 Points

What do you mean by better? For mē it would look like this:

/***************************************
MAIN
******************************************/



body {
    margin:  0 auto;
}


/***************************************
HEADER
******************************************/



.heading {
    padding-top: 10px;
    height: 300px;
    background: #fcf5c1;
    background-size: cover;
}

.heading img {
    display: block; /* Displays as block element */
    width: 280px; /*  Sets the width */
    margin: 0 auto; /* Centers the content */
    padding: 300px 100px -100px 100px; /* Padding Top/Left/Bottom/Right */
}

h1 {
    font-family: 'Spirax', cursive;
    font-size: 1.2rem;
    text-align: center;
    color: brown;
    font-weight: normal;
    margin-top: 5px;
    margin-left: 6px;
}


/***************************************
NAVIGATION
******************************************/



nav {
    color: deeppink;
    float:  left;
    padding-top: -14px;
    padding-left: -10px;
    background: #fcf5c1;
    width: 100%;
    border-bottom: 6px dotted pink;
    font-size: 1.2rem;   /* 1.2 * rootfontsize */
}

nav li {
     display: inline-block;
     padding-right: 15px;
     padding-left: 15px;
}

nav ul{
   list-style: none;
  margin: 0 0;
  padding: 0px;
  padding-bottom: -10px;
}
Liliana Leyva
Liliana Leyva
3,711 Points

Thank you for your answer. I posted the question because I though I had a mess.