Please check out the new Help Developer forum

Show Sidebar

Part 4/4: Design and Code a site with Gimp, HTML and CSS

June 18, 2008

Welcome to the fourth and final part of my series on designing and coding a website in the Gimp, HTML and CSS. At this point I would like to thank everyone who has been following this series and I hope that you continue to use Help Developer. In this part I am going to show you how to finish off the template we have been creating, we are going to style the textual elements such as the h1, h2 and hyperlink tags and we are going to also create the long awaited rollover menu.

Continues below...


-

Step 1

First of all we are going to add the logo to the header area. Open the style.css file and add the following:

a.logo {
width:353px;
height:102px;
float:left;
background-image:url(images/logo.png);
}

This will style the hyperlink that has a class attribute of “logo”. Change the width value to the width of the logo image you cut out earlier.

-

Step 2

Open the index.html file and add the following line between the <div id=”header”> and </div>:

<a href="./index.html" class="logo"></a>

It should now look like this:

-

Step 3

Now we are going to style the h2 tags which we will use to create the titles on the pages and sidebar. Go to the style.css file and add the following code:

h2 {
font-size:20px;
color:#333333;
font-weight:bold;
}

and this to the index.html file directly underneath the <div id=”contentarea”> tag:

<h2>Welcome</h2>

This will create something like this:

Using h2 tags is good for SEO because Google’s bot looks at the h2 tags to determine what your site is about. Also notice that there is no dot (.) or hash (#) before the h2 in the CSS, this is because it is a formatting option and it is not a div (#) or a class (.)

Continues below...


-

Step 4

Next is to style the hyperlinks in the text, first add a hyperlink to the index.html file. (<a href=”link_here”>text_to_display_here</a>), notice it will use the default browser settings:

To style this add the following to the style.css file:

a {
font-weight:bold;
color:#333333;
text-decoration:none;
}

Now it looks like this:

You can style it further by adding a hover style, for example, I added the following code:

a:hover {
color:#389ccb;
text-decoration:underline;
}

and this was the outcome when I hover over the link:

Also just a quick note, if you want to change the style of an element like a hyperlink in a certain area only, for example to the footer area then in the style.css file change the a { to #footer a {

-

Step 5

And now, what you have all being waiting for, the rollover menu links. This is done in a similar way to what you see above in step 4 using the a and a:hover options in CSS.

When doing this on your own sites/templates you will need to use trial and error to get the measurements right in order for it to look right, but in this example the elements are all the same as the tutorial (if you have been following the other parts correctly of course).

Add the following in the index.html file under the <div id=”menulinks”>:

<a href="#">Home</a>
<a href="#">About</a>
<a href="#">Services</a>
<a href="#">Contact</a

Here is the CSS for the menulinks rollover item:

#menulinks a {
padding-top:15px;
padding-left:15px;
padding-right:15px;
height:27px;
float:left;
text-decoration:none;
color:#FFFFFF;
font-weight:bold;
font-size:14px;
margin-top:1px;
}

OK, a bit of an explanation for the code below. It uses padding to make the text inside the link centred and the height property just makes it fill the area. When you are using this on other templates the padding-top and the height property are going to be the properties that you need to keep changing until it looks right. I have used float:left; so that the elements are displayed next to each other. I have changed the colour to white (FFFFFF), the font to bold and size 14px. I have also added a margin-top of 1px because for some reason it looked out of place without it, the margin-top property just pushed the element down or up if you use a negative value.

To add the hover effect all you have to do is this:

#menulinks a:hover {
background-image:url(images/menuhover.png);
}

Simple!

You should now have something like this:

Unhovered

Hovered

-

Step 6

Finally, all that is left to do is move the links to the right a bit, as you can see from the images above the links come off the edge. To move the links to the right go to the style.css file and find the #menulinks property and change it to:

#menulinks {
width:930px;
padding-left:30px;
height:44px;
background-image:url(images/menulinks.png);
clear:both;
}

I have added a padding-left attribute with a value of 30px and in order to not mess up your layout, ensure that you remove the same amount from the width attribute because padding is added onto the width.

-

Result

That’s it, you should now have something that looks like this:

You can download all of the files by clicking here.

Finally, I would like to thank all of you for following this tutorial and I hope it has helped you considerably in learning how to design a website in the Gimp and then code it. You will now be able to move onto harder websites using the same techniques used in this tutorial and keep an eye out on Help Developer for tutorials on more advanced techniques such as nicer hover effects. You can subscribe to my RSS feed here.

Submit to Stumbleupon Submit to Del.icio.us Submit to Google

SUBSCRIBE TO RSS

RSS FEED - EMAIL FEED

Comments RSS Feed

33 Comments

Comments Trackbacks

  1. lexor

    lexor Says:

    woot amazing result
    thanks simon

  2. Ooburii Says:

    Used this amazing tutorial to create my own site layout (with a few modifications), and I have to say it was very well explained and easy to understand! Well done, you did an excellent job on this :]


  3. noxstyle

    noxstyle Says:

    indeed… excellent tutorial.. even i can make layouts from now on… really appreciated.


  4. Simon

    Simon Says:

    If you are wanting to know how to add a second sidebar then you may find this helpful: http://help-developer.com/forum/viewtopic.php?f=9&t=17&p=34#p34

    Thanks

  5. matthew Says:

    thanks so much i used this tut on my site http://purejet.net/beta/ it worked well after changing some css and tinkering around


  6. Simon

    Simon Says:

    No probs, btw you can make the content stop hanging over the edge by adding a padding-right attribute, however remember to take the amount you set as the padding-right from the width.


  7. Samuel

    Samuel Says:

    Hi,

    Thank you for this amazing tutorial! I learned a lot with it (I’m a beginner)!

    I still have 2 questions:

    1. On the website template that you create in the tutorial, I would like that, when someone clics on the menu bar (ex. “About”), it would be redirected to the “About page” and that the background color of the menu behind the word “About” changes to another one.
    To give you an example of what I mean, look at http://www.apple.com/. The navigation bar is gray. When you clic on a word of the menu (let’s say “Store”) then the “Store” page is opened and the background color of the word “Store” in the navigation bar is dark gray.
    Can you explain me how to do this ?

    2. Can you explain to me how I could create a “two-lines navigation bar” like the one used in “http://www.behance.net/” ?

    Thank you a lot !


  8. Benji

    Benji Says:

    Thanks so much! This has been unbelievably helpful!

    I used in in conjunction with this: http://gimp-tutorials.net/websitetutorial
    to get something looking like this: http://benjiijneb.110mb.com/index.html
    and i am very happy! Thank you!


  9. Karl Robinson

    Karl Robinson Says:

    Hey there in this your logo goes near the center and by he header not overlapping onto the far left of the site do you know how i can edit the CSS so that the header goes where i want it. Thanks


  10. dj

    dj Says:

    Found tutorial to be very educational. Using GIMP to do the initial layout, cut it up, and then create the CSS is a nice way to see how it all fits together. I love GIMP :-)

    Thank you.

  11. Nate Says:

    Wow, awesome tutorial.


  12. Pammy

    Pammy Says:

    Simon, you rock! Thanks.


  13. vampz

    vampz Says:

    hi..
    nice tutorial there..im still new in linux n GIMP but im experienced with photoshop..currently, im using Quanta Plus to develop my website..

    i have some question for u:
    1. i designed my website but i can’t make the slice tool to work in GIMP..do u know how?
    2. is there any method to make the layer section not too crowded coz i’m getting confused sometimes which is the right layer..can the layers placed in a folder like photoshop?

    erm..i think that’s it for now..if i have any other question, may i ask u here again?

    thanks in advance.

  14. Simon North Says:

    Hi, vampz, in answer to your questions:

    1) Just use the select tool, select the region you want to slice (eg, the header area), and then go to Edit -> Copy Visible, then Edit -> Paste as -> New Image. Thats the way I do it and prefer to do it.

    2) I don’t know of a way to group layers yet, I am hoping that they bring that functionality into the next version but I am unsure at this stage, it certainly would be a good feature.

    You can ask questions here or you can use the forum here: http://help-developer.com/forum/viewforum.php?f=9

  15. Chisaku Says:

    Wow, thanks for this really helpful tutorial. Even doing it all for for free lightened my day up. Open source == <3.

    I never imagined this to be so easy, I love Gimp and now I’ve started to love creating web layouts. Your tutorial is very well written, I understood all of it. I’ve taken a little sneak peek on HTML and CSS before, but didn’t understand how it really worked, so this was kind of a savior from crushing my dreams. Hahah, that sounded so weird, but I’ve dreamt of learning these kind of things.

    Thanks for your tutorial, Simon!

    PS. I love the little line thing you got to make in the beginning. I just want to place them everywhere! xD


  16. vampz

    vampz Says:

    thanks simon for replying..

    i’ve sliced my design and now im trying to put it in the tag..on now the problem is dat my layout isn’t as same as u..
    my layout is like a table that have 1 row and 3 columns..and in the middle column have 2 rows..can u get the idea?i can’t get the tag to fit inside the main tag that holds them..i can post my code but i think that’s not suitable here..which part should i post in the forums?or should i make a new thread?

    regards,
    vampz.

  17. karl robinson Says:

    i need help with the logo again i got a logo i want in the middle of the page and i don’t want it overlapping the edge can you help me if so i will send a link of my files and the .xcf

  18. Simon North Says:

    Hi Karl, to center the logo follow these steps:

    1) When creating the design put the logo in the center of the header

    2) Select around the logo and select Edit -> Copy Visible and then Edit -> Paste as new, save the new image as the logo image

    3) In the style.css file, find the a.logo and remove the float:left; line, also change the width and height properties to the size of the new logo file. Now find #header and add a line saying text-align:center; In theory the logo should now be in the center, if it is not then you can use the margin-left property to put it in the right position using trial and error.

    I hope this helps.


  19. Digital

    Digital Says:

    Hey Simon, may I first add, great, GREAT tutorial.

    #menulinks a:hover {
    background-image:url(images/menuhover.png);
    }

    I’m a bit confused about this, the hover-over code. I have been trying to get this code for about over a month, but I never can get it. Can you explain just how to use this code for me a bit, I’d appreciate it, and it would help me accomplish my site, as the hover-over code is one of the few remaining codes left to complete it.

    Much thanks in advance. ^_^

  20. george Says:

    Hi guys,

    Awesome tutorial many thanks…

    Just one question:

    In the tutorial where the code is added, say to the css section or the index.html section, it often says
    ” The page should now look like this…”

    What are you using to view the page? I´m just copying and pasting the codes into notepad documents, am I gonna have to then put these files into another program like dreamweaver or something?

    I know its really basic, but I´m still very green to all this!

    Many thanks all,

    George


  21. Jamie

    Jamie Says:

    Hi,

    Many thanks for a great tutorial.

    Jamie

  22. marco Says:

    Thanks, really well done tutorial. Finally I got a grasp on css and can start writing my themes instead of using others!

  23. marco Says:

    Hi,

    I have a question: the image logo.png is not inserted as tag, thus doesn’t have an alt tag. That’s not ideal from a SEO point of view as Google and other crawlers won’t ’see’ the title of your homepage.
    I am not a css/html guru so I wonder:is a good idea to modify index.php as follow?

    Of course in style.css
    a.logo we’ll remove the background image.

    Thanks and keep up with the great job!

    Marco.

  24. marco Says:

    Well, comments don’t take html.
    Basically I want to use an img tag for logo.png in index.php instead of using background-image in style.css

    I know it’s good for SEO but not sure it’s good web design practice.

    Thank you.

  25. Simon North Says:

    @marco:

    What you could do is just remove the background-image line in the css for a.logo and instead add the image tag in between the http://pastie.org/291187 and http://pastie.org/291188 so it should read something like:

    http://pastie.org/291185

    Hope this helps

  26. Felipe Trombini Says:

    I’m from Brazil, and never saw a tutorial as good involving web design and GIMP.

    Thank you very much.

    PS: Sorry to inlgês. . .


  27. Erik

    Erik Says:

    I noticed that the hover/rollover effects for the menu stay on in IE6. Is there a way to fix it so that it works in that browser?


  28. Kevin

    Kevin Says:

    This is a good tutorial, it opens up many creative possibilities for making web design simpler, thanks, Simon.

    Like Erik I too noticed that the hover/rollover effect got stuck in IE 5 and 6, but its easy to fix: in the css file under the #menulinks code get rid of the image file for the hover effect and replace it with a background-color tag, eg: from:

    #menulinks a:hover {
    background-image:url(images/menuhover.png);
    }

    to:

    #menulinks a:hover {
    background-color:what color you want;
    }

    By the way Simon do you think you could do a tutorial on how to convert a html/css template into php so it could be used on wordpress or a CMS like Drupal? That would be great!


  29. dreamcat

    dreamcat Says:

    rawhgly watched over the 4 parts of your tut,caus`im starting designing my own hp,it seems to be very understandable.i think theres no book on the market which covers all those steps from design to scripting..even if i should not get it to work ( i lost mostly all my creative skills due to depressions and sleepdeprivation:o ) i must say-thanks and you have done a great job with that tut!!!!!!!

  30. joseph bupe Says:

    I appreciate your tutorial. I was looking for a way to do this.

    Thank you so much and live longer.



Leave a Reply