Help designing my first website

Hey guys,

I’m starting simple on my first ever website from scratch and any help would be greatly appreciated. Here is the current version. Here are the issues I’m trying to fix:

  1. Top image is kind of wonky. On smaller screens it shows a horizontal scroll bar. Ideally I would like the image to be centered and take up the full width of the browser, and on smaller screens less of the image would show up (without squishing the image).

  2. Mobile friendly.

a) I would like the cooking image meme (cooking challenge accepted) to be resized as the viewport gets smaller.

b) the clock icon and ingredients should stack overtop of one another as the viewport gets smaller

c) the text should not go off screen as the viewport gets smaller

I would love any feedback on a better or more elegant way to write the CSS or HTML. I am starting simple so that I can understand a simple website before trying anything more complex.

for reference, here is the code I am using. Thanks in advance for any help!

HTML:

   <!DOCTYPE html>
<head>
<title>Koo's Crispy Parmesan Brussel Sprouts</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>

<body>

<!--Banner Area Start-->
  <div class="banner">
  <img src="images/brussels.jpg" width="1000" height="501"  class="banner"/>
<div id="banner-text">Koo's Crispy Parmesan Brussel Sprouts</div></div>
  
  <div id="main_container">
  <!--Banner Area end-->
  
  <!--content Area Start-->
  <div id="content">
    <p>Forget everything you've ever heard about brussel sprouts being <em>too</em> healthy. Serve these puppies to your poker buddies and we guarantee they'll be coming back for more.</p>
    <img class="displayed" src="images/challenge.png" />
    <div id="Ingredients">
      <div class="left"><img src="images/time.png" width="302" height="233" /></div>
      <div class="right">
        <h3>Ingredients</h3>
        <ul>
          <li> 4 Cups of Raw Brussel Sprouts, halved </li>
          <li> 2 Tablespoons of Olive Oil </li>
          <li> 1 Cup of freshly grated parmesan </li>
          <li>Pinch of Salt & Pepper</li>
          <li> 1 Lemon</li>
        </ul>
      </div>
    </div>
  <div class="clear"></div>
  <div id="ingredients">
    <h2>Instructions:</h2>
    <ol>
      <li>Preheat Oven to 405 Degrees Farenheit.</li>
      <li>While the oven is preheating, cut the brussel sprouts in half and throw them in your big ass bowl. Add oil and a few pinches of salt and pepper and mix with your bare hands (like a real man).</li>
      <li>Spread the sprouts on a baking pan and leave them on middle rack for 45 minutes. <strong>*Flip them after 20 minutes</strong>.</li>
      <li>While those bad boys are cooking, grate the cheese and slice the lemon into quarters.</li>
      <li>Remove sprouts from oven and sprinkle parmesan cheese. Serve with lemon wedge.</li>
    </ul>
  </div>
</div>

  <!--content Area end-->
</body>
</html>

CSS:

body {
	font-family:Arial, Helvetica, sans-serif;
	color:#322e2e;
	margin:0px;
}
/* ************Main container *****************/
#main_container {
	width: 1000px;
	margin:auto;
}
/* ************Banner start *****************/
#main_container .banner {
	width: 1000px;
	height:500px;
	background:url(../images/brussels.jpg) no-repeat top;
}
#main_container .banner h1 {
	text-align:center;
	color: white;
	text-shadow: 2px 2px #666666;
	font-size: 40px;
	font-weight: lighter;
	padding-top: 200px;
	letter-spacing: 1px;
	margin-top:-4px;
}

/* ************Banner start *****************/
#banner-container{
	width:100%;
	position:relative;
	
	
	
}

#banner-text{
	text-align:center;
	color: black;
	text-shadow: 2px 3px #cccccc;
	font-size: 40px;
	font-weight: lighter;
	padding-top: 50px;
	letter-spacing: 1px;
	margin: auto;
	/* position: absolute; */
	/* left: 289px; */
	/* top: 33px; */
	
	
	
}

 img.banner {
	width: auto;
	height:500px;
	
	
}

 img.banner h1 {
	text-align:center;
	color: white;
	text-shadow: 1px 1px #666666;
	font-size: 40px;
	font-weight: lighter;
	padding-top: 200px;
	letter-spacing: 1px;
	margin-top:-4px;
	
}
/* ************Banner end *****************/

/* ************content start *****************/
#content {
	margin: 50px 50px 200px 50px;
}
p {
	font-family:Arial, Helvetica, sans-serif;
	color:#322e2e;
	font-size:19px;
	text-align:left;
}
img.displayed {
	display: block;
	/* margin-left: auto; */
	/* margin-right: auto
; */
	/* margin-top: 50px; */
	margin: 100px auto 120px auto;
	border: 1px solid black;
	border-radius: 10%;
}
#Ingredients {
	margin-top:100px;
}
#Ingredients .left {
	margin:0px;
	float:left;
	width:280px;
	margin: 0px 10px 0px 100px;
}
#Ingredients .right {
	margin-left: 10px;
	float:left;
	width:500px;
}
#Ingredients h3 {
	margin:0px;
	font-family:Arial, Helvetica, sans-serif;
	color:#000000;
	font-size:22px;
	margin:0px 0px 20px 40px;
}
#Ingredients h2 {
	margin:0px;
	font-family:Arial, Helvetica, sans-serif;
	color:#000000;
	font-size:26px;
	margin:0px 0px 0px 0px;
	text-align:center;
}
#Ingredients ul {
	margin:0px;
}
#Ingredients ul li {
	margin:0px;
	font-family:Arial, Helvetica, sans-serif;
	color:#000;
	font-size:20px;
	list-style:none;
	padding:0px;
}
/* ************Banner end *****************/
.clear {
	clear:both;
}

li {
padding-top: 20px;
}

div#ingredients {
margin-top: 120px;
}

#Ingredients .left img:hover {transform: scale(1.1); 
}
#Ingredients .left img {transition: all .2s ease-in-out; }

Here is a very crude example:

<!DOCTYPE html>
    
    <head>
      <title>Koo's Crispy Parmesan Brussel Sprouts</title>
    
      <!--I added this for responsiveness to work -->
      <meta name="viewport" content="width=device-width initial-scale=1" />
    
      <!--I included the styles in the <head> for easier editing on my part -->
      <style type="text/css">

        /* --- these styles apply at all widths unless override in the media query below ---*/
        body {
          font-family: Arial, Helvetica, sans-serif;
          color: #322e2e;
          margin: 0px;
        }
        #main_container {
          width: 90% !important;
          padding: 20px;
        }
        #main_container,
        #main_container .banner {
          width: 100%;
          margin: 0 auto;
        }
        #banner-text {
          text-align: center;
          color: black;
          text-shadow: 2px 3px #cccccc;
          font-size: 40px;
          font-weight: lighter;
          padding-top: 0;
          letter-spacing: 1px;
          margin: auto;
          /* position: absolute; */
          /* left: 289px; */
          /* top: 33px; */
        }
        img {
          max-width: 100%;
          margin: 0 auto 1em auto;
        }
        img.displayed {
          border: 1px solid black;
          border-radius: 10%;
        }
        /* --- I added this media query for larger displays so that the styles needed for
    them are only applied when the browser has a min width of 1000px
    the browser will do most of the work for you below that.
    The styles that apply then are above this media query ---*/
    
        @media screen and (min-width: 1000px) {
          /* ************Main container *****************/
    
          #main_container {
            width: 100%;
            margin: auto;
          }
          /* ************Banner start *****************/
    
          #main_container .banner {
            width: 100%;
          }
          #main_container .banner h1 {
            text-align: center;
            color: white;
            text-shadow: 2px 2px #666666;
            font-size: 40px;
            font-weight: lighter;
            padding-top: 200px;
            letter-spacing: 1px;
            margin-top: -4px;
          }
          /* ************Banner start *****************/
    
          #banner-container {
            width: 100%;
            position: relative;
          }
    
          #banner-text {
            padding-top: 50px;
          }
          img.banner {
            width: auto;
          }
          /* ************Banner end *****************/
          /* ************content start *****************/
    
          #content {
            margin: 50px 50px 200px 50px;
          }
          p {
            font-family: Arial, Helvetica, sans-serif;
            color: #322e2e;
            font-size: 19px;
            text-align: left;
          }
          img.displayed {
            max-width: 520px;
            display: block;
            /* margin-left: auto; */
            /* margin-right: auto
        ; */
            /* margin-top: 50px; */
    
            margin: 100px auto 120px auto;
          }
          #Ingredients {
            margin-top: 100px;
          }
          #Ingredients .left {
            margin: 0px;
            float: left;
            width: 280px;
            margin: 0px 10px 0px 100px;
          }
          #Ingredients .right {
            margin-left: 10px;
            float: left;
            width: 500px;
          }
          #Ingredients h3 {
            margin: 0px;
            font-family: Arial, Helvetica, sans-serif;
            color: #000000;
            font-size: 22px;
            margin: 0px 0px 20px 40px;
          }
          #Ingredients h2 {
            margin: 0px;
            font-family: Arial, Helvetica, sans-serif;
            color: #000000;
            font-size: 26px;
            margin: 0px 0px 0px 0px;
            text-align: center;
          }
          #Ingredients ul {
            margin: 0px;
          }
          #Ingredients ul li {
            margin: 0px;
            font-family: Arial, Helvetica, sans-serif;
            color: #000;
            font-size: 20px;
            list-style: none;
            padding: 0px;
          }
          /* ************Banner end *****************/
    
          .clear {
            clear: both;
          }
          li {
            padding-top: 20px;
          }
          div#ingredients {
            margin-top: 120px;
          }
          #Ingredients .left img:hover {
            transform: scale(1.1);
          }
          #Ingredients .left img {
            transition: all .2s ease-in-out;
          }
        }
      </style>
    </head>
    
    <body>
    
      <!--Banner Area Start-->
      <div class="banner">
<!--i changed the widths of all images to 100% and got rid of the height attribute-->
        <img src="http://woodhabits.com/images/brussels.jpg" width="100%" class="banner" />
      </div>
    
      <div id="main_container">
    
        <div id="banner-text">Koo's Crispy Parmesan Brussel Sprouts</div>
        <!--Banner Area end-->
    
        <!--content Area Start-->
        <div id="content">
          <p>Forget everything you've ever heard about brussel sprouts being <em>too</em> healthy. Serve these puppies to your poker buddies and we guarantee they'll be coming back for more.</p>
          <img class="displayed" src="http://woodhabits.com/images/challenge.png" width="100%" />
          <div id="Ingredients">
            <div class="left"><img src="http://woodhabits.com/images/time.png" width="100%" />
            </div>
            <div class="right">
              <h3>Ingredients</h3>
              <ul>
                <li> 4 Cups of Raw Brussel Sprouts, halved </li>
                <li> 2 Tablespoons of Olive Oil </li>
                <li> 1 Cup of freshly grated parmesan </li>
                <li>Pinch of Salt & Pepper</li>
                <li> 1 Lemon</li>
              </ul>
            </div>
          </div>
          <div class="clear"></div>
          <div id="ingredients">
            <h2>Instructions:</h2>
            <ol>
              <li>Preheat Oven to 405 Degrees Farenheit.</li>
              <li>While the oven is preheating, cut the brussel sprouts in half and throw them in your big ass bowl. Add oil and a few pinches of salt and pepper and mix with your bare hands (like a real man).</li>
              <li>Spread the sprouts on a baking pan and leave them on middle rack for 45 minutes. <strong>*Flip them after 20 minutes</strong>.</li>
              <li>While those bad boys are cooking, grate the cheese and slice the lemon into quarters.</li>
              <li>Remove sprouts from oven and sprinkle parmesan cheese. Serve with lemon wedge.</li>
              </ul>
          </div>
        </div>
    
     <!-- you were missing a closing <div> here-->
      </div>
    
      <!--content Area end-->
    </body>
    </html>

Hope it helps in some way. :smile:

bpartch has helped with most of your issues but it is important to remember that the viewport meta tag that was added is very important for mobile devices otherwise the media queries will not work as you expect on smaller devices

I also notice a small error in that you start the list as an ‘ol’ but finish it as a ‘ul’! Make your mind up :smile:

If you want to support IE8 then you should also had the html5shiv and either respond.js or css3mediaqueries.js so that media queries and html5 elements work in IE8 and under.

This is how I would start the head of a document these days.

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Koo's Crispy Parmesan Brussel Sprouts</title>

<!-- force IE8+ into standards mode -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="css/style.css" rel="stylesheet" type="text/css" />

<!-- must have viewport meta tag for mobile support -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<!-- the next script is the html5shiv for html5 support in IE8 and under -->
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

<!-- for media query support in ie8 and under download either respond.js or css3 media queries
https://github.com/scottjehl/Respond
https://code.google.com/p/css3-mediaqueries-js/
-->

</head>

Thanks @PaulOB and @bpartch. I’m revising my code now and trying to digest the material.

Appreciated!

@PaulOB

Just a general question… Do you usually rewrite the head of a document from scratch every time? Or do you keep the code written in a doc that you can just copy/paste from?

No, I use that snippet I posted above most of the time (along with the resources I mention in the comments).

For the default css I usually start with something like this:

@charset "utf-8";
/* apply a natural box layout model to all elements */
*, *:before, *:after {
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
}
html, body, table {
    margin: 0;
    padding: 0;
    font-size: 100%;
}
object, iframe, blockquote, h1, h2, h3, h4, h5, h6, p, dl, dt, dd, ol, ul, fieldset, form, legend, table, caption, th, td {
    margin: 0;
    padding: 0;
    border:none;
}
article, aside, figure,figcaption footer, header, nav, section, details, summary, main {
    display: block;
}
ol {
    list-style:outside decimal;
    margin-left:1.5em
}
ul {
    list-style:outside disc;
    margin-left:1.5em
}
table {
    border-collapse: separate;
    border-spacing: 0;
}
caption, th, td {
    text-align: left;
    font-weight: normal;
    vertical-align:top;
}
/* clearing technique */
.clearfix:after{
    content:".";
    display:block;
    height:0;
    clear:both;
    visibility:hidden;
    overflow:hidden;
}
.clearfix{zoom:1.0}
a img, img {/* remove borders from linked images*/
    border:none;
    display:block
}
a {text-decoration:none;}
a:link {color:#db750f}
a:visited {color:#db750f}
a:focus,input:focus {outline:1px dotted #ccc;box-shadow:none}
a:hover {text-decoration:underline;}
/* clear extra padding on moz inputs */
input[type="submit"]::-moz-focus-inner {
 padding: 0;
 border: none;
}
input, textarea, select, label,button {
    font-family: Arial, Helvetica, sans-serif;
    vertical-align:middle;
}
textarea {
    resize:vertical;
    overflow:auto
}
p, h1, h2, h3, h4, h5, h6, ul {
    margin:0 0 1em;
}
strong, b {font-weight:bold}
/* Prevents Mobile Safari from bumping up font sizes in landscape */
@media only screen and (max-device-width: 480px) {
    body {
        -webkit-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
    }
}
/* Main CSS Document */
body {
    line-height:1.4;
    font-family: Arial, Helvetica, sans-serif;
    color:#000;
    background:#fff;
    text-align:left;
}

That’s just a rough guide as its not set in stone.

Thanks so much for the help guys. I’ve gotten away with not learning how to code for way too long (just making basic superficial edits to pre-existing code).

I’ve finally decided that it’s time for me to learn this properly. I have a couple followup questions that I’ve been having trouble with. Please bear with me… I’m really trying to get a solid foundation instead of just being able to get a website to look how I want it to look by hacking away at the code. After I figure out below questions, I’m going to try to recreate my website from scratch.

(I’ve updated the new site here for reference)

  1. I still don’t quite understand when I would use an ID vs a Class. I understand that IDs are completely unique and one of a kind and class would be a repeating thing. But isn’t it just easier to use classes all the time? I mean, you never know if you’ll need to repeat it, right? What am I missing, what’s the logic here?

  2. Is there a trick to stay organized with your code? Like - how can you stay on top of missing </div> etc when you have so many nested elements?

  3. #main_container .banner is this referencing all classes of “banner” inside any ID’s of “main_container” ? Or is it referencing BOTH the ID “Main_container” and the class “banner”? I thought it was the former, and this CSS confused me because in my HTML .banner is not nested inside #main_container . They are ‘siblings’ in hierarchy.

  4. It seems really annoying to have to essentially build two sections in your CSS (one for greater than 1000px). Do you always have to do this? How would I intuitively know what elements need to be fixed for wider screen? What is your normal process for figuring this out? Why 1000px and not 980px (or any other width)?

  5. I’m getting confused with divs. I don’t know when it’s appropriate to use a new div or code within the existing div. One time, someone told me I had “divitis” because I was using divs way too much. I find myself adding divs when it probably isn’t necessary. Any advice on this or words of wisdom?

Thanks SO much for your help guys.

Yes its best to use classes for all your styling and use ids as hooks for javascript (and ids maybe to identify main page structure but still use classes for all the styling). It’s just handy to have some id hooks in the main sections for later on when you may want to use some js.

Yes format the code (most editors will format the code and missing tags become quite obvious). Or use the validator regularly to pick up missing and unclosed tags.
I also usually comment the opening and closing tags of sections when I am developing if there is a lot of nesting going on (and then remove them when going live). This helps to stop incorrect nesting.

I’ll answer the other questions later as I have to rush out now :smile: (unless bpartch want to finish them ;))

. #main_container .banner is this referencing all classes of “banner” inside any ID’s of “main_container” ? Or is it referencing BOTH the ID “Main_container” and the class “banner”? I thought it was the former, and this CSS confused me because in my HTML .banner is not nested inside #main_container . They are ‘siblings’ in hierarchy.

Yes #main_container .banner is targeting any elements with class of banner inside another element with an ID of #main_container

It seems really annoying to have to essentially build two sections in your CSS (one for greater than 1000px). Do you always have to do this? How would I intuitively know what elements need to be fixed for wider screen? What is your normal process for figuring this out? Why 1000px and not 980px (or any other width)?

I went with 1000px cause that was the width you had set. Normally I would not use 1000px in my media query. :stuck_out_tongue:

Really all you have to do is apply styles that are only needed for larger displays inside a media query that targets that size. So you don’t have to write it all twice, just some of it.

Like if I had a layout with a content area on the left and a sidebar on the right where the content area is floated left and the sidebar is margined to the right the same width as the content area. I would only need to remove the float, change the width and remove the left margin from the sidebar.

 @media screen and (min-width: 1000px) {
       .container{
         width:100%;
       }
      .content {
        float:left;
        width:70%;
      }
      .sidebar{
        margin-left:70%;
        width:30%;
      }
    }

All I would need to do to override that for smaller widths is to:

  .content {
    float:none;
  }
  .sidebar{
    margin-left:0;
  }
  .content,.sidebar{
    width:100%;
  }

But since the float, width and left margin are set in a media query that only targets viewports with a minimum width of 1000px or greater, anything smaller than that will never get them. So I would never need to write the second one. I hope that makes sense. Cause at this point I’m kinda confusing myself. (I’m better at doing it then explaining it)

I’m getting confused with divs. I don’t know when it’s appropriate to use a new div or code within the existing div. One time, someone told me I had “divitis” because I was using divs way too much. I find myself adding divs when it probably isn’t necessary. Any advice on this or words of wisdom?

This is kinda hard for me to explain.

Lets take an example from your file:

<div class="banner">
  <img src="images/brussels.jpg" width="1000" height="501"  class="banner"/>
  <div id="banner-text">Koo's Crispy Parmesan Brussel Sprouts</div>
</div>

The <div class="banner"> is great, but the <div id="banner-text"> would probably be better suited outside of an additional <div>

<div class="banner">
  <img src="images/brussels.jpg" width="1000" height="501"  class="banner"/>
  <h1 id="banner-text">Koo's Crispy Parmesan Brussel Sprouts</h1>
</div>

Though I would change that ID to a class:

<h1 class="banner-text">Koo's Crispy Parmesan Brussel Sprouts</h1>

Thank you so much . This is incredibly helpful.

I’m still a bit confused on the divs… Like when and why do I need to add a new one?

It is a way to group elements into an area (box) on a webpage. http://www.sitepoint.com/web-foundations/div-html-attribute/

Seems to me that you have taken it down for now?

Index of /
cgi-bin/ 
css/ 
images/  
Apache Server at woodhabits.com Port 80

No, I just moved it to www.getmanufactured.com

Ok just made a new site. Check it out:

http://getmanufactured.com/new/

I have two questions:

  1. How do I center the two divs (.left and .right) on the page?

  2. If you scroll to the bottom, I added a link with a hover effect. It seems pretty glitchy… What would be a better way to achieve this result (so that the link grows when you hover over it). Can I put it in a Div and grow the text when the div is hovered over?

  3. Any general tips or ways to improve this code based on what I’ve done?

Thanks!!

  1. Wrap both the left and right div in a parent <div>. Give that div text-align:center. Change both .left and .right to display:inline-block and get rid of hte float on it.
<!DOCTYPE html>
<html>
<head>
<style> 
.bottom a {
font-style: underline;
font-size:20px;
height: 300px;
transition: font-size 0.5s
}
.bottom a:hover
{
font-size:30px;
}
</style>
</head>
<body>
<div class="bottom">
<a href="#">text</a>
</div>

</body>
</html>

Also font-style:underline is invalid. If you want underline (which comes by default) then do text-decoration:underline

http://www.w3schools.com/cssref/pr_font_font-style.asp
You can see what values font-style accepts.

Perfect, thanks. Except how do I fix the fact that .left is now positioned below .right?

http://getmanufactured.com/new/

Nevermind… Just found the vertical-align solution. Thanks so much for your help @RyanReese

Glad you got everything working :slight_smile: . I was asleep, sorry I couldn’t help.