A HTML + CSS Basic Tutorial

Zenax

Active Member
Messages
1,377
Reaction score
4
Points
38
I know there are quite a few on here but heres mine, and I hope to help others with this tutorial. It will basically be on HTML and CSS so it will cover background colours to Divs, for the more advance person.

I will try and expalin in "Lamens Terms" (Simple as Possable) for the begginners!

HTML Basics:

First off, when ever you start to write your web page you have to put

Code:
[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]<html>[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]<head>[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1][/SIZE][/FONT] 
[FONT=Tahoma][SIZE=1]</head>[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]<body>[/SIZE][/FONT]
[FONT=Tahoma]
[SIZE=1]</body>[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]<html>[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]

All HTML tags must be marked placed inbetween < > brackets. If you miss of one of the end of one of your tags, it will mess up your page!

In between the Head tags is the parts of the page, that you want to be read "first", so to speak. So in there you would place stuff like javascript, if told to, and also you would place your style in there, which we shall cover later on in the tutorial.

In between the body tags is what you want on the page, so this will contain all your content and so it will contain DIVS (also covered later) and tables etc.

So a list of basic HTML tags that might be useful for you to know, as basics, are as follows, as we will cover other ways to place these in later on!

  • <b></b> --> Anything that is placed in between these tags will become bold!
  • <i></i> --> Anything that is placed in between these tags becomes italic!
  • <u></u> --> Anything that is placed in between these tags becomes underlined!
  • <marquee></marquee> --> Anything that is in between these tags will scroll from right to left! However this tag is hardly used any more, and javascript/DHTML marquees are more common!
Now you can mix these tags together so you get multiple effects, such as bold and italic! Here is a few examples:

Code:
[/SIZE]
[SIZE=1]<b>Hello World!</b>[/SIZE]
[SIZE=1]

Creates this effect:
Hello World!

Code:
[/SIZE]
[SIZE=1]<i>Hello World</i>[/SIZE]
[SIZE=1]

Creates this effect:
Hello World!

Code:
[/SIZE]
[SIZE=1]<b><i>Hello World!</i></b>[/SIZE]
[SIZE=1]

Creates this effect:
Hello World!

That is basically what these tags are used for and what happens when you mix them together!

Now we come on to comments in HTML! To place a comment in a web page you put the following:

Code:
[/SIZE]
[SIZE=1]<html>[/SIZE]
[SIZE=1]<head>[/SIZE]
[SIZE=1][/SIZE] 
[SIZE=1]<title>Blah</title>[/SIZE]
[SIZE=1][/SIZE] 
[SIZE=1]</head>[/SIZE]
[SIZE=1]<body>[/SIZE]
[SIZE=1][/SIZE] 
[SIZE=1]<!-- This is a comment -->[/SIZE]
[SIZE=1][/SIZE] 
[SIZE=1]</body>[/SIZE]
[SIZE=1]</html>[/SIZE]
[SIZE=1]

Now we come on to CSS!

Now CSS stands for Cascading Style Sheet! and this is what defines the properties for your document!

There are two ways of putting CSS into your page! There is the inline style, which is where you place the CSS within the header tags of your web page, and there is external CSS which is where you place all your CSS in a global stylesheet!

In this tutorial I will be using the inline style, as I can't place an external stylesheet onto this thread, but I can show you how it is done!

For an inline style you would do the following:
Code:
[/SIZE]
[SIZE=1]<html>[/SIZE]
[SIZE=1]<head>[/SIZE]
[SIZE=1][/SIZE] 
[SIZE=1]<style>[/SIZE]
[SIZE=1]body[/SIZE]
[SIZE=1]{[/SIZE]
[SIZE=1]background-color: black[/SIZE]
[SIZE=1]}[/SIZE]
[SIZE=1]</style>[/SIZE]
[SIZE=1][/SIZE] 
[SIZE=1]... rest of html code[/SIZE]
[SIZE=1]

That bit of CSS shows that the background colour of the web page is black. Now for professional web design, you use hex colours or RGB in the folowing form:

#000000 - This is black in Hex

rgb(0,0,0) - This is black in RGB code

Now if you have a lot of pages, and a lot of CSS then it is normally best to place your style in an external page. Not only is this easier, as it makes the changes to all the pages, it saves a lot of room on the page!

This is how it is done:

Code:
[/SIZE]
[SIZE=1][/SIZE] 
[SIZE=1]<html>[/SIZE]
[SIZE=1]<head>[/SIZE]
[SIZE=1][/SIZE] 
[SIZE=1]<title>whatever your page title is</title>[/SIZE]
[SIZE=1][/SIZE] 
[SIZE=1]<link rel="stylesheet" href="where the stylesheet is" type="text/css" />[/SIZE]
[SIZE=1][/SIZE] 
[SIZE=1]... rest of code[/SIZE]
[SIZE=1][/SIZE] 
[SIZE=1]



Now when I prefer to code using the External Stylesheet method, and I think that you should as well.

Now for the basics of CSS you have the following:
  • background-color: #000000 ---> This leaves the background colour of the page Black
  • colour: #FFFFFF ---> This sets the pages font colour to white
  • font-family: Tahoma ---> This sets the pages font to Tahoma
  • font-size: 10px ---> This sets the font size of the page to 10px




I shall finish this tutorial at a later date, due to the fact I have to go watch a football match right now!



Regards,
Zenax
 
Last edited:

Zenax

Active Member
Messages
1,377
Reaction score
4
Points
38
Finishing from where I left off!

Before we move onto the divs I must insist on showing you how to place a comment inside your stlyesheet!

Code:
[/SIZE]
[SIZE=1][/SIZE] 
[SIZE=1]... code here[/SIZE]
[SIZE=1][/SIZE] 
[SIZE=1]<style>[/SIZE]
[SIZE=1][/SIZE] 
[SIZE=1][/SIZE] 
[SIZE=1]/* This is a comment in a stylesheet! */[/SIZE]
[SIZE=1][/SIZE] 
[SIZE=1]</style>[/SIZE]
[SIZE=1][/SIZE] 
[SIZE=1]... code here[/SIZE]
[SIZE=1]

Ok so now we come to divs!

Divs are now more commonly used in web design instead of tables. Apparrently as a proffessional web designer you are supposed to use Divs to create your website, and only use tables for tabular data!

So here is what you do to create a Div!

Code:
[/SIZE]
[SIZE=1]<html>[/SIZE]
[SIZE=1]<head>[/SIZE]
[SIZE=1][/SIZE] 
[SIZE=1]<title>Div Example</title> <!-- Gives the page the title "Div Example -->[/SIZE]
[SIZE=1][/SIZE] 
[SIZE=1] <!-- Again i reccomend external stylesheet but for this purpose the inline style is being used -->[/SIZE]
[SIZE=1][/SIZE] 
[SIZE=1]<style>[/SIZE][SIZE=1][/SIZE]
[SIZE=1].div1[/SIZE]
[SIZE=1]{[/SIZE]
[SIZE=1]background-color: #000000;[/SIZE]
[SIZE=1]color: #FFFFFF;[/SIZE]
[SIZE=1]}[/SIZE]
[SIZE=1][/SIZE] 
[SIZE=1]/*This Style is going to give Div1 a background colour of black and a font colour of white */[/SIZE]
[SIZE=1]</style>[/SIZE]
[SIZE=1][/SIZE] 
[SIZE=1]</head>[/SIZE]
[SIZE=1][/SIZE] 
[SIZE=1]<body>[/SIZE]
[SIZE=1][/SIZE] 
[SIZE=1]<div class="div1">[/SIZE]
[SIZE=1]Content in here[/SIZE]
[SIZE=1]</div>[/SIZE]
[SIZE=1][/SIZE] 
[SIZE=1]</body>[/SIZE]
[SIZE=1]</html>[/SIZE]
[SIZE=1][/SIZE] 
[SIZE=1]

So that is a div with a background color of black and a font colour of white. Now there are many more properties that you could add to this and I am going to show you some right now!

Code:
[/SIZE]
[SIZE=1][/SIZE] 
[SIZE=1]... code here[/SIZE]
[SIZE=1][/SIZE] 
[SIZE=1]<style>[/SIZE]
[SIZE=1][/SIZE] 
[SIZE=1].div1[/SIZE]
[SIZE=1]{[/SIZE]
[SIZE=1]background-color: #000000;[/SIZE]
[SIZE=1]color: #FFFFFF;[/SIZE]
[SIZE=1]width: 200px;[/SIZE]
[SIZE=1]margin-left: 50px;[/SIZE]
[SIZE=1]margin-top: 300px;[/SIZE]
[SIZE=1]}[/SIZE]
[SIZE=1][/SIZE] 
[SIZE=1]</style>[/SIZE]
[SIZE=1][/SIZE] 
[SIZE=1]</head>[/SIZE]
[SIZE=1][/SIZE] 
[SIZE=1]<body>[/SIZE]
[SIZE=1][/SIZE] 
[SIZE=1]<div class="div1">[/SIZE]
[SIZE=1]Content here[/SIZE]
[SIZE=1]</div>[/SIZE]
[SIZE=1][/SIZE] 
[SIZE=1].... code here[/SIZE]
[SIZE=1][/SIZE] 
[SIZE=1]

That is the same div as I coded earlier, however I added some extra properties to it! I made the width of the div 200 px (Ideal for navigation areas!) and I made it start 50px from the left and 300px from the top!

Now for those of you that don't know this already px stands for pixels. I always code my layouts using pixels, and so do many others, however there are others out there, which you can find on a different website! (Just Place w3schools.com into google and you will find it!)

So below are explained some of the other attributes that you can add to a div!

  • margin - Now the value you set on this will apply to all sides top, bottom, left and right! You can change it so it only applies to the one side e.g. margin-left applies it to the left hand side only
  • width - This sets the width of the div itself so a decent size for a navigational area I believe is 200px!
  • height - This sets the height of it, but this doesn't always need to be added as the div will expand to the height of its content!
  • position - This will determine the position of the Div! I believe you can get, absolute, static, and a few others
Now that is the end of the tutorial! I have covered the basics of HTML and the basics of CSS and I have shown you how to combine the two together!

Again I reccomment you use external stylesheets on all your websites, which makes it a hell of alot easier when your coding and making small tweaks to the layout etc!

This tutorial will soon available on my website as a whole!

Regards,
Zenax

A Link to colour code chart : Click Here
 
Last edited:

ryoko126

New Member
Messages
207
Reaction score
0
Points
0
And yet... It doesn't help a person if they can't pick good colors. I have a site like that but it's bare bones with whites and greys. Any good combination colors for a dark theme?
 

Banner

New Member
Messages
13
Reaction score
0
Points
0
I will have to study this for days but i have a simple questioin. Where do i actually put these codes?
 

frankfriend

Member
Messages
410
Reaction score
2
Points
18
Hi Zenax,

This is a really useful, simple, and clear tutorial. I think that in about four pages you have made clear what another guy in 150 pages [I've just read] made really murky!
 

GtoXic

x10 Support
Messages
636
Reaction score
17
Points
0
great tutorial, but you don't HAVE to put the <html> <head> etc etc (yet) but it is suggested seeing as though it's regarded invalid otherwise.
 
Top