Beginners HTML Tutorial – Web Design Basics

November 1, 2008 by admin  
Filed under CSS and XHTML

Are you new to the world of Web Design?, this tutorial is just what you need to get started, it’s aimed at the beginner and assumes no prior knowledge.

What is HTML?

HTML is the most crucial building block of a website. There are many other tools you’ll hear from people talking about making websites – Javascript, PHP, ASP, SQL to name a few – but without HTML you can’t even get started.

HTML is a “markup language” – a structured way of controlling layout and appearance of text, graphics and other elements on a web page. More recently it has developed into “XHTML” which is essentially a stricter and more uniform set of rules for writing HTML. All our code in these articles will be written to the latest XHTML standards, and we’ll use the terms HTML and XHTML interchangeably.

The other thing we’ll be covering in these articles is CSS. This is a way of controlling the style – color, size, font, position, and so on – of various aspects of your page. Its real advantage is that it allows you to alter these properties of more than one area of your page at once, so that you don’t have to set everything individually many times over. We’ll look more at this later on.

What is HTML not?

HTML only allows for static content. That is, pages that do not change in response to user’s commands, and do not draw data out of another source like a database. We’ll look at the best way to achieve “dynamic” pages later on.

HTML is not perfect!

Like anything HTML has its flaws. Over the years the HTML specification has been expanded and altered to take into account users’ demands. However the various internet browsers – Internet Explorer, FireFox, etc – have occasionally made modifications of their own. Some of these were intentional and some were not (i.e. bugs!). As a result, there may be differences between the way a page displays in one browser and another (or even between different versions of the same browser).

Fortunately, today this is less of an issue as all the browsers move towards full and proper compliance with the published standards. However there are still plenty of users who have older versions of the browsers on their computers. You need to be aware of this problem but don’t worry too much for now. We’ll address it as and when it comes up.

What do you need to get started?

An Editor

This is a program to write your code in. Any text editor will do the job, for example Notepad (which you can probably find under Accessories in your Start menu).

However many developers choose to use something a bit more advanced. It can be really useful, particularly when you’re learning, to have an editor that automatically color codes your work to help you tell the code apart from the content. There are lots of editors available that do this. My favourite is EditPlus, which you’ll see in the screenshots in these articles, and is available on a free trial at www.editplus.com.

You may be familiar with programs like Dreamweaver which will write most of the code for you. These are called “WYSIWYG” editors – What You See Is What You Get. They certainly have their place as they can save a lot of time. However they will never be able to do everything that you need them to – so are no substitute for understanding the code behind the scenes. It’s best to learn to write the code properly to start with, and then, if you want to, use a program like Dreamweaver to remove the monotonous tasks, we do offer some excellent Dreamweaver Tutorials for users who decide to go this route.

A Browser

You’ll already have one of these if you are reading this article! Popular browsers include Internet Explorer (http://www.microsoft.com/ie) and FireFox (http://www.mozilla.com/en-US) , but there are lots more. It doesn’t really matter which you use but just make sure if you can that whatever browser you are using is a recent version (current versions are Internet Explorer 7 and FireFox 3).

That’s it – we’re ready to get started!

Writing your first HTML page

HTML uses “tags” to control display of your content. A tag is a word or letter enclosed by angular brackets – e.g. <p> is the tag for a new paragraph, and <title> is the tag for the title of your page.

Every tag must be opened and closed. This is especially important to remember – a lot of the time the page will still work if you don’t add the closing part, but results will be unpredictable, particularly in older browsers. It’s best to get into the habit now.

To close a tag, add a slash before the word in the tag. E.g. </p> or </title>. For example, to make a paragraph of text:

<p> Text goes here </p>

Outline of the page

Every page needs a few tags before you can think about having any content. Look at the example below then we’ll go through it line by line.

<html>

<head>

<title>Page Title</title>

</head>

<body>

</body>

</html>

The <html> tag is fairly self explanatory! It’s important though so don’t forget it. Below that we have the <head> tag which starts a section where you can include various pieces of information about the page.

The <title> tag tells the browser what the heading of the whole page is. This is displayed in the title bar at the top of the browser,

<image 1 >

not actually on the page itself. Put something sensible in here – this is a key thing that the search engines look at when ranking your page. Rather than just putting something like “Home” or “Welcome” try to have a heading that includes some key words about your site.

After the title we need to close this tag with </title>, then finally close the header section with </head>.

<body> is the section of the page that includes all the content visible to the user. At the moment we don’t have any content so this is followed by the </body> tag to close this section.

Then the </html> means it’s the end of the page.

HTML is hierarchical

Take another look at the code above. Every tag is opened and closed, and is fully enclosed within its parent (<head> is a child of <html>, and <head> is a parent of <title>).

It is important to make sure the closing tag comes in the right place. E.g. <head><title> </title></head> is right but <head><title> </head></title> is not. You need to make sure that when you write a closing tag, all other tags that you started within it are also closed.

To make this a bit easier to keep up with, developers use tabs and spacing to make the code simpler to read. You’ll see from the code above that each time we write a parent tag, the next line is tabbed further in than the previous line. So all tags that are horizontally lined up are children of the same parent. This isn’t strictly necessary but it makes things a lot easier when you’re trying to read what you’ve written.

It’s also worth noting that spacing and lines don’t matter. You could leave a dozen lines between each tag if you wanted to and it would make no difference. Content within tags (for example a paragraph of text) can also span multiple lines.

Let’s add some text

For now we’ll just put in a single paragraph of text. The tag for a paragraph is <p>. As you know we need to close the tag as well, so the format for a paragraph is:

<p> text here </p>

This needs to go inside the body section of your page – between the <body> and </body> tags. So your page will end up like the one below (remember to use the tab key to make things easier to read):

<html>

<head>

<title>Page Title</title>

</head>

<body>

<p>

This is my first web page!

</p>

</body>

</html>

Save the page

Now it’s time to save the page. Browsers expect the main page of a website to be called “index.html”. This is how you can type an address like http://www.google.com into your browser and end up at http://www.google.com/index.html.

Make sure that you are saving your page with the “.html” extension. In an HTML editor like EditPlus you will need to choose “HTML” from the “file type” box, or in something like Notepad you will need to choose “All files”. Then type “index.html” in the file name box and click save.

Does it work?

Find your saved page and double-click it to open it up in your internet browser. You should see something like this:

It’s not pretty, but it works. We’ll get to making it look nicer in the next article.

This page is actual being served from your own machine, therefore only up can see it , if we wanted this page to be visible to the world it would need to be upload to a web server using a protocol called FTP ( File Transfer Protocol ), this sounds complicated, it’s not, it’s no harder than sending an email and we will cover this in a later tutorial.

Reference

  • <html> – must go at the start and end of every page
  • <head> – defines the “header” of a page which contains various pieces of information about the page, that do not actually appear on it
  • <title> – the title of a page as viewable in the browser’s title bar
  • <body> – the main body of the page – the part visible to the user
  • <p> – a paragraph of text

Don’t forget, all of the above tags need a closing tag too. As I said earlier the page will quite possibly work if you forget the closing tags but it will create problems for you later on. Get in the habit now!

Beginners HTML Tutorial part 2:
look at some formatting options to give a bit more life to your page, by introducing CSS.

CSS Tutorial – Roll Over Button

October 28, 2008 by admin  
Filed under CSS and XHTML, Featured Tutorials

Pre-loaded Hover-state Images

In this XHTML CSS tutorial you’ll learn how to create a button for a web page using Photoshop, XHTML and CSS. More specifically, you’ll learn how to create a button who’s hover state image is preloaded. The advantage to this technique is that upon hovering over your button, the user won’t have to wait for it’s hover state image to appear; there’ll be no ‘graphic-less’ moment while the image loads, all without a single line of JavaScript.

Open up a blank XHTML document with a style statement within the <head> tags. This is where we’ll place out CSS code.

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″ />
<title>button</title>
<style></style>
</head>
<body>
</body>
</html>

We’ll begin by setting out the XHTML markup for our button, between the <body> tags:

<a href=”" class=”button”>Hover over me!</a>

Notice the button has been given the class of ‘button’.

Now we’ll set up some basic CSS to establish some styles in our document. Place the following between the <style> tags:

body {
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:12px;
color:#333333
}

Now some attributes for what will be our button, identifiable by it’s class ‘button’. Firstly, it has a width of 100px, a height of 20px and some extra padding to increase it’s dimensions further.

a.button {
display: block;
width: 100px;
height: 20px;
padding: 15px 20px 10px 45px;
color:#666666;
text-decoration: none;
}

The above statement dictates that the button has padding of 15px at the top, 20px on the right, 10px at the bottom and 45px on the left. This extra padding on the left will make room for an icon on our button. The total dimensions of our button are now 160px wide and 45px high. You’ll also see that I’ve given any text within the button a color of #666666, that it’s displayed as ‘block’ (making it adhere to the dimensions we’ve set) and that I’ve removed the default underline by stating that there will be no text decoration. Now lets make a graphic for it with Photoshop.

Open up a new document in Photoshop with the dimensions of our button.

Copy a design something along the lines of what you see below. I’ve chosen to use one of the many icons freely available from famfamfam.com and placed it on the left.

Now alter your canvas size (Image > Canvas Size…). Double it’s height to 90px from the top edge. This will give you the following result:

Now duplicate all the elements you’ve drawn and position them at the bottom of your canvas. This copy will be your button’s hover-state.

Your two button images need to be different in some way – perhaps a completely different color, different icon or perhaps something more subtle. I’ve chosen to alter the transparency of my top image making it fainter than the hover-state. The button will appear darker when hovered over.

When you’re satisfied with your image, save (File > Save for Web & Devices…) in whatever format you choose.

Now let’s use this image as a background for our button by further defining our ‘button’ class in the CSS.

background:url(button.jpg) no-repeat 0px 0px;

This states that the image we’ve chosen will be used as the background for our button, that the image won’t be repeated (it won’t be tiled), that it will be positioned 0px from the left and 0px from the top. Of course, when the page is loaded and the button background is also loaded, the whole thing is placed in your browser’s cache, even the part of your button image which isn’t yet visible. Check your button in a web browser, it should look like this:

Now we need to add the final CSS statement, defining what happens when our button is hovered over.

a.button:hover {
color:#333333;
background:url(button.jpg) no-repeat 0px -45px;
}

This simple statement dictates that the hover-state of our ‘button’ link will have a slightly darker color of #333333 and that the background image will be our button.jpg. The difference this time is that the background position has been set at 0px from the left and -45px from the top – or, said in another way, that the background image is raised 45px. Our hover-state graphic will therefore instantly fill the button when hovered over. Try it yourself! Finished CSS Example

Download all the files used in this CSS Tutorial

XHTML Tutorial CSS Tabbed Menu

October 28, 2008 by admin  
Filed under CSS and XHTML, Featured Tutorials

Tabbed menu

One hugely useful way of displaying your menu items is in the form of tabs. The following tutorial will take you through some simple steps to build your own tabbed menu, without so much as a .gif or line of JavaScript in sight…

Open up a blank XHTML document with a style statement within the <head> tags. This is where we’ll place out CSS code.

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″ />
<title>button</title>
<style>
</style>
</head>
<body>
</body>
</html>

Now let’s set out the XHTML markup for our menu, between the <body> tags:

<ul class=”menu_tabbed”>
<li><a href=”">tab one</a></li>
<li><a href=”">tab two</a></li>
<li><a href=”">tab three</a></li>
<li><a href=”">tab four</a></li>
</ul>

This is a straight-forward unordered list which we’ve given the class of ‘menu_tabbed’. Within it are four list items, each one of which contains a link.

That’s it for the markup, now let’s set up some CSS to give our document some basic styles. Place the following between the <style> tags:

body {
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:12px;
color:#333333;
padding: 30px;
}

This just gives our document a default text color (#333333), font and font size. I’ve also just given the documents ‘body’ a padding of 30px in order for our menu to be held away from the page edges. This will make it all slightly easier to view on our part.

Now some attributes for our unordered list, identifiable by it’s class ‘menu_tabbed’. Firstly, it has no list-style. This removes the bullet points from the list items – in all circumstances, in all browsers. Secondly it has a solid border along it’s bottom edge of 1px and the color #999999. Lastly some padding at the bottom in order to hold the border away from our tabs as we’ll soon see.

ul.menu_tabbed {
list-style: none;
border-bottom: 1px #999999 solid;
padding-bottom: 10px
}

Test it in a browser, your menu should now look something like this:

Now let’s style our list items, identifiable as ‘li’ within the ‘ul’ which has a class of ‘menu_tabbed’.

ul.menu_tabbed li {
display: inline;
margin-right: 5px;
}

We’ll display the list items ‘inline’ which will distribute them horizontally across the page. Each one has a margin on the right of 5px in order to hold it away from the previous list item. Now your menu should now look something like this:

Having dealt with our list and the list items within it, we can now turn our attention to the links, identifiable as the ‘a’ within the ‘li’ within the ‘ul’ which has a class of ‘menu_tabbed’. Place the following within your CSS code:

ul.menu_tabbed li a {
color:#999999;
text-decoration: none;
background: #f7f7f7;
border: 1px #CCCCCC solid;
border-bottom: none;
padding: 10px 14px;

}

There’s a little more styling involved here as most of the visual effects are tied to the links. First give the text a faint color of #999999 and remove the underline by stating no text-decoration. Then give a background of #f7f7f7 and a solid 1px border of #CCCCCC. There’ll be no border on the bottom, as this is catered for by the border on the bottom of our unordered list.

Lastly, give the links some padding; 10px at the top and bottom and 14px left and right. The 10px padding at the bottom will allow the links’ bottom edge to meet with the bottom edge of the unordered list which we also gave a padding of 10px.

Check your menu again in a browser:

Now let’s give our tabs some styling for their hover state, one simple line of CSS:

ul.menu_tabbed li a:hover {
padding: 14px 14px 10px 14px;
}

This padding overrides the padding for the links which we’ve previously set. It differs only by giving an extra 4px padding at the top which gives the tabs the impression of being lifted like so:

Finally we’re going add some style for when one of the menu items is selected. Add the class ’selected’ to your second list item:

<li><a href=”" class=”selected”>tab two</a></li>

Now let’s add some CSS to determine what the selected tab looks like:

ul.menu_tabbed li a.selected {
color:#666666;
background:#FFFFFF;
border: 1px #999999 solid;
border-bottom: 1px #FFFFFF solid;
padding: 14px 14px 10px 14px;
}

We’ve darkened the text to make it stand out, the background is white, as is it’s bottom border. This will cover the bottom border of the unordered list giving the impression that the tab is ‘connected’ to the page underneath. The padding will match the padding we’ve given to the link hover state; slightly raising the tab.

That’s it! Check your final menu in a browser!

It should look like this: CSS Tabbed Example »

Beginners Flash Tutorial – Creating Dynamic Text

October 20, 2008 by admin  
Filed under CSS and XHTML, Flash Tutorials

High Quality Flash Tutorial Videos – Taught by Experts
We also have extensive Adobe Flash Tutorials in high quality video format. These are ideal for beginners who need to master Flash quickly

Title / Free Demo : Adobe Flash CS3 Tutorial Videos
Author:
James Gonzalez
Duration:
11 Hours – Lessons: 125

Creating Dynamic Text with Flash

This tutorial has been prepared with relation to Flash 8, although the principles covered apply to all versions; the code included is based on ActionScript 2.0

This Flash tutorial introduces the creation, editing and formatting of dynamic text and embedding fonts.

There are two main ways to create a dynamic text field in Flash, one using the flash interface and the other using ActionScript, this flash tutorial will give you a fundemental understanding of this works.

Create a textfield using the interface

Open a new flash document, and select the text tool:

text tool

Click and drag on the stage to create your text field, then type something in to start with. On the Properties panel (select Window > Properties > Properties if it isn’t already visible), select Dynamic Text from the first drop-down list and give the textfield the instance name ‘my_txt’:

textfield

Now, create a new layer in your flash movie by clicking the Insert Layer icon on the timeline:

new layer

This is the layer where we will put our ActionScript code, you can rename the layer ‘actions’ by double clicking on it (where it currently reads Layer 2) to keep your flash file well organised.

With the new layer selected, open the Actions panel either by pressing F9, clicking on the Actions tab if it is visible, or choosing Window > Actions. Type the following code into the actions panel:


Select All

 my_txt.text="new text" 

textfield code

Now test your movie by pressing CTRL+Enter or choosing Control > Test Movie

test text

You’ll see that your original text has been replaced with the text you specified in the code. However, you might also notice that the text appears less clear than it does when the textfield is static. To demonstrate this, go back to the layer with your textfield on it and create a new one, only this time choose static from the drop-down list. Enter ‘new text’ as the text and test the movie again, you should see a difference between the two fields:

static vs dynamic text

In order to make your dynamic text have a clear appearance, you have to embed the font in it. This means that information about the font will be included in your final exported SWF movie, so that the text will be displayed consistently wherever the file is viewed. Another advantage to doing this is that, if you use a font that the user viewing your SWF doesn’t have installed on their machine, the appearance of your movie will still be preserved, as the SWF contains the font information, telling the user’s machine how the text should be displayed. To embed the font, you have one of the following two options:
  1. Select your dynamic textfield on the stage and click the Embed button on the Properties panel, then choose Basic Latin (select OK):
    embed control
  2. On the library panel (Window > Library if it isn’t open) select the options button:
    options

    Select New Font and enter the following details:

    new font

    Press OK and you’ll see your font appear in the library. Right-click (CTRL+Click for Macs) on the font in the library and choose Linkage. Click the checkbox next to ‘Export for ActionScript’:

    linkage

    This allows you to refer to the font in your ActionScript code (the procedure is the same for any library item that you want to control using ActionScript). Select your code (‘actions’) layer and enter the following code (after your existing line)

    :


    Select All

     my_txt.embedFonts=true var tf:TextFormat=new TextFormat() tf.font="myfont" my_txt.setTextFormat(tf) 

    embed code

After following one of these two options, test the movie and you should see that the appearance of your text has improved. You should note that embedding fonts in your flash will increase the file size of your SWF, so only do it if necessary, particularly if your file is going to be viewed over the Web.

Tutorial on Creating a dynamic textfield using ActionScript

You can also create your dynamic textfield using ActionScript. To do this, enter the following code at the end of your script:


Select All

 var other_txt:TextField = _root.createTextField("other_txt", _root.getNextHighestDepth(), 20, 20, 200, 50) other_txt.text="other text" 
The parameters for the createTextField command are as follows:


Select All

 createTextField(instanceName, depth, xPosition, yPosition, width, height) 

Try not to be put off by the code if you’re not familiar with ActionScript. A good way to familiarise yourself with it is to experiment by changing some of the parameters (e.g. change the y position to 100 and you’ll see the text appear further down). To format this text, you need to use the ActionScript approach outlined above.