Tutorial Psdtohtmlcss21
Tutorial Psdtohtmlcss21
HTML Tutorial
by Steven Snell
on February 9, 2010
in Tutorials
Last week we published a tutorial for designing a basic corporate website layout in Photoshop, and in
this tutorial we will walk through the process of coding that design in HTML and CSS. Here is a look
at the design that we will be coding (click the image to see it in full-size).
In order to work though this tutorial you will need the PSD file from the first tutorial which can be
downloaded here. Id also recommend saving a backup copy of the PSD in case something that we do
messes up the file that you are working with.
With that area selected, go to Edit Copy Merged. Then create a new file (File New) that is 100
pixels wide and 321 pixels high. In the new file, go to Edit Paste to paste in what you have copied.
Save this file in the images folder as bg.jpg.
Next, well work on the logo. Set vertical guides at 227 pixels and 440 pixels. Set horizontal guides at
11 pixels and 130 pixels.
In the layers palette, deactivate all of the layers in the header folder except the two text layers that make
up the logo. Also deactivate the background layer in the background folder.
Then you should have something that looks like this.
Back in the layers palette, select both of the text layers of the logo (hold ctrl + click to select both), go
to Layer Merge Layers and both of the text layers will be combined. Now, select the crop tool and use
the guides to crop just the area of the logo. It should be 213 pixels wide and 113 pixels high.
With that area selected, go to Edit Copy Merged. The open a new file that is 1400 pixels wide by 170
pixels high and paste in the selection.
With both layers highlighted, go to Layers Merge Layers. With the merged layer highlighted in the
layers palette, go to Select All, and then Edit Copy. Create a new file that is 262 pixels wide and 52
pixels high, with a transparent background. Then paste in the button that you copied.
Home
Services
About Us
Case Studies
Contact Us
Company News
The next thing were going to do is style the wrapper. The wrapper div contains every other part of
content on the page that we have not styled already, except for the footer.
[cc lang="css"]
#wrapper {
width: 960px;
background: #fff;
border: solid 1px #cccfcc;
margin: 39px auto 0;
}[/cc]
The wrapper has a width of 960 pixels and were using the auto margin on the left and right to center it.
Heres how it looks after that small change.
Now well work on the teaser section that includes some text and the get in touch button.
[cc lang="css"]
#teaser {
width: 900px;
height: 68px;
background: url(images/teaser-bg.jpg) repeat-x top;
margin: 10px;
padding: 10px 20px;
border: solid 1px #646464;
}
#teaser p {
width: 635px;
float: left;
font-size: 16px;
margin: 10px 0 0 0;
display: inline;
}
#teaser img {
float: right;
margin-top: 8px;
}
.largeText {
font-size: 20px;
}[/cc]
Were giving this div a width of 900 pixels with 20 pixels of padding on the sides and a 10 pixel
margin. The margin creates the whitespace inside of the wrapper div. Were also giving the teaser div a
background image that will give the section the gradient background from our design.
The text of this section is inside of paragraph tags, so well give the paragraph a width of 635 pixels
and float it to the left. There is a span with a class of largeText and this is being styled to be 20 pixels
instead of 16 pixels. The button is floated to the right.
Here is a preview.
Below the teaser area is the featured div, which we will style next.
[cc lang="css"]
#featured {
width: 900px;
height: 212px;
background: #3c3934 url(images/featured-bg.jpg) repeat-x top;
margin: 10px;
padding: 10px 20px;
border: solid 1px #312f2b;
}
h2 {
width: 670px;
font-size: 30px;
font-weight: normal;
color: #f8fcf8;
margin: 10px 0;
}
#featured p {
width: 670px;
float: left;
font-size: 16px;
line-height: 24px;
color: #cfd1cf;
margin: 0;
}
.featured-button {
margin: 30px 45px 0 0;
}
.featured-icon {
float: right;
margin: 0 36px 0 0;
display: inline;
}[/cc]
Like the teaser div, the featured div is also given the same with, padding, and margin. Were also using
CSS to give it the linear gradient background image that repeats horizontally.
Were then styling the h2, which is contained in the featured div, and the paragraph of text. Were
giving it a light color to be readable on the background. As with the teaser area, we are giving the
paragraph a width and floating it to the left. The icon is then floated to the right. Were giving the
buttons a top and right margin to space them properly.
At this point our page looks like this.
The next area to tackle is the main content.
[cc lang="css"]
#mainContent {
width: 580px;
float: left;
display: inline;
margin: 30px 30px;
}
h3 {
font-size: 18px;
font-weight: normal;
color: #112002;
}[/cc]
Here we are giving the mainContent div a width of 580 pixels and floating it to the left. Were also
setting the necessary margins, and in a minute we will float the sidebar to the right. Here we are also
styling the h3 tage to have larger text and a dark green color.
Here is a look.