Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

CSS Layout Help

Featured Replies

Hello

 

I am learning how to create/design websites and am really stuck on layouts! Can any one help me with code for creating a basic web page layout. i.e. Header, Nav bar at top, two columns in the main section and a footer.

 

I have some simple code I have attached along with the css file. Like I said i am very new to this so its very simple!

 

Any help on expading this and creating the columns and footer would be amazing.

 

Thanks :)

Practice.html

style.css

From your HTML I can see that you know what a <div> is. From that we can create a website.

 

I'll teach you what margins are, passings, width, height, borders and colours.

 

Margins are used to position you website from the four sides. Top, Bottom, Left and right. So, If I wanted to have a 10px gap from the left, I would use this code;

 

html

<div id="wrapper">

</div>

You already know this, so moving to the CSS

CSS

#wrapper  {
 margin-left:10px;
}

 

This code will create a 10px gap from the left, but lets advance on this with a background colour, a border and also some dimensions for the size.

 

CSS

#wrapper  {
 background-color:#FFFFFF
 width:600px;
 height:900px
 border: 1px solid #000000;
 margin-left:10px;  
}

 

Paddings are used for content. When putting content in a div box they are automatically pushed up to the box, so having a little padding moves it away, for example

 

CSS

#wrapper  {
 background-color:#FFFFFF
 width:600px;
 height:900px
 border: 1px solid #000000;
 margin-left:10px; 

    padding:10px;
}

 

If you want to change the margins to you have them at the top, botton, left and right just adapt the code so it looks like this;

 

margin-left:

margin-right:

margin-top;

margin-bottom;

 

I hope this helps, and for a more in-depth look at a div box, just go here;

http://www.w3schools.com/css/css_boxmodel.asp

Edited by Tweezy

  • Author

Thank you for this, helps alot!

Positioning is the main problem where I have been getting stuck.

 

So if I was to create two columns in the main section would I create two separate Div tags for these or?

Hi Peart, try putting your code online, http://jsfiddle.net/ works well, for more responses.

 

Don't worry about positioning, it trips everyone up at the beginning, it'll click eventually. You'll have plenty of "wtf" moments :)

 

This is a nice explanation to css positioning. Try to get your head around the box model, Google it, it'll help once you get it.

 

And yea, sure, that'll create two columns.

 

Goodluck,

~evu.

Edited by evu

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.