Basic HTML Tutorial.

Damien

Seasoned Veteran
Joined
Apr 29, 2007
Messages
3,232
Reaction score
0
FP$
6
Hi, In this tutorial I'll be showing you all the basic HTML advice and showing you how to do some simple stuff.

To start with, HTML is the language that websites/web pages are made from (Along with other languages not covered in this tutorial). HTML stand for Hyper Text Markup language and once you have a basic knowledge of it you can do some cool stuff.

Before we start i must say that the basic lay out for a HTML page is as follows.

Code:
<html>
<head>
</head>
     <body>
 All page code and content in here.
    </body>
</html>

(I'll take more about the head section in other tutorials, but just for short its for the information of the page such as page title, meta tags, stylesheets, attaching java scrips and more...

Okay, lets start with some basic text changes.

Bold

italic

underlined

Before I go to explain how you make text bold, underlined or italic I have to start by explaining about tags. For this I'm going to use making text bold as an example so to do this i would do the following..

Code:
<b>this is bold text</b>

Notice that to open this tag I had to do this <b> now the thing to remember is to close the tag with a / before the text in the tag other wise you will find the text from there on will all be bold until you close the tag, so is i wanted just half the text to be bold i would do the following..

Code:
This is <b>bold text</b>

and that will give you this..

This is bold text

Now here's a list of HTML commands for you to try and experiment with..

BOLD = <b>BOLD</b>

ITALIC - <i>ITALIC</i>

UNDERLINE - <u>UNDERLINE</u>

RED TEXT = <font color="#FF0000">RED TEXT</font>

(Scrolling text) = <marquee>This is Scrolling text</marquee>


= <hr />

Well there you are, some basic commands and a little information about how it works and rules to go by when using them, remember to experiment with them put them together and see what you get!

Feel free to comment on this tutorial if you wish, anyway I can make it better I will.

Thanks
Dark Evil
 
Um, should I correct you on some stuff that I don't agree with and that is definitely not W3C compliant?

1) Not a mistake but <i></i> can also be <em></em> if anyone was interested.
2) for the <hr> tag it should only be <hr /> just like the <br />
3) for the font, I would suggest using a span tag so it should be something like this:

Code:
<span style="color:#FF0000;">RED TEXT</span>
 
I suppose there are different ways of doing things, never the less they all work ;-)

Tutorial edited XD

Thanks
Dark Evil
 
Can someone please put the [Tutorial] bit on the title of this tutorial.
 
Haha cool. Once you've done this then you need to add a CSS file and more html. 😀 I use <strong>text</strong> for Bold. Dunno why. :lol:
 
<strong></strong> is the proper way to do it and is the proper way to do it, a few of the things he mentioned in here are not the proper way to do it, well, they can be done, but don't work and are not as compatible as the other way.
 
I am going to take a moment and try to give you some basics of coding.

HTML Cheat Sheet

The first thing you have to do is ensure you have all the correct elements present when creating a page to be displayed on the internet.

HTML Elements:

<html>
<head>
<title>Title of page</title>
</head>
<body>
This is my first homepage. <b>This text is bold</b>
</body>
</html>

Example Explained

The first tag in your HTML document is <html>. This tag tells your browser that this is the start of an HTML document. The last tag in your document is </html>. This tag tells your browser that this is the end of the HTML document.

The text between the <head> tag and the </head> tag is header information. Header information is not displayed in the browser window.

The text between the <title> tags is the title of your document. The title is displayed in your browser's caption, at the very top of the browser window.

The text between the <body> tags is the text that will be displayed in your browser.

The text between the <b> and </b> tags will be displayed in a bold font.

Notice

For every tag listed above, there was an opening tag and a closing tag. For example, the bold tag that created the bold text. There was an opening <b>, then some text followed by a closing tag, or rather, </b>.

It is extremely important you close all open tags!

I would also like to add that you should always use lowercase tags in your code. Yes, you will find many sites that use uppercase tags, like this <B>, but If you want to follow the latest web standards, you should always use lowercase tags. The World Wide Web Consortium (W3C) recommends lowercase tags in their HTML 4 recommendation, and XHTML (the next generation HTML) demands lowercase tags.

Let's continue . . .

The most important tags in HTML are tags that define headings, paragraphs and line breaks.

The best way to learn HTML is to work with examples. Thanks to the W3C, they have created a very nice HTML editor for you. With this editor, you can edit the HTML source code if you like, and click on a test button to view the result.

Try it Yourself - Examples

A very simple HTML document
This example is a very simple HTML document, with only a minimum of HTML tags. It demonstrates how the text inside a body element is displayed in the browser.

Simple paragraphs
This example demonstrates how the text inside paragraph elements is displayed in the browser.

Headings

Headings are defined with the <h1> to <h6> tags. <h1> defines the largest heading. <h6> defines the smallest heading.

<h1>This is a heading</h1>
<h2>This is a heading</h2>
<h3>This is a heading</h3>
<h4>This is a heading</h4>
<h5>This is a heading</h5>
<h6>This is a heading</h6>

HTML automatically adds an extra blank line before and after a heading.

Paragraphs

Paragraphs are defined with the <p> tag.

<p>This is a paragraph</p>
<p>This is another paragraph</p>

HTML automatically adds an extra blank line before and after a paragraph.

Don't Forget the Closing Tag

You might have noticed that paragraphs can be written without end tags </p>:

<p>This is a paragraph
<p>This is another paragraph

The example above will work in most browsers, but don't rely on it. Future version of HTML will not allow you to skip ANY end tags.

Closing all HTML elements with an end tag is a future proof way of writing HTML. It also makes the code easier to understand (read and browse) when you to mark both where an element starts and where it ends.

Line Breaks

The <br> tag is used when you want to break a line, but don't want to start a new paragraph. The <br> tag forces a line break wherever you place it.

<p>This <br> is a para<br>graph with line breaks</p>

Try it yourself

The <br> tag is an empty tag. It has no end tag like </br>, since a closing tag doesn't make any sense.

<br> or <br />

More and more often you will see the <br> tag written like this: <br />

Because the <br> tag has no end tag (or closing tag), it breaks one of the rules for future HTML (the XML based XHTML), namely that all elements must be closed.

Writing it like <br /> is a future proof way of closing (or ending) the tag inside the opening tag, accepted by both HTML and XML.

Comments in HTML

The comment tag is used to insert a comment in the HTML source code. A comment will be ignored by the browser. You can use comments to explain your code, which can help you when you edit the source code at a later date.

<!-- This is a comment -->

Note that you need an exclamation point after the opening bracket, but not before the closing bracket.

Basic Notes - Useful Tips

When you write HTML text, you can never be sure how the text is displayed in another browser. Some people have large computer displays, some have small. The text will be reformatted every time the user resizes his window. Never try to format the text in your editor by adding empty lines and spaces to the text.

HTML will truncate the spaces in your text. Any number of spaces count as one. Some extra information: In HTML a new line counts as one space.

Using empty paragraphs <p> to insert blank lines is a bad habit. Use the <br> tag instead. (But don't use the <br> tag to create lists. Wait until you have learned about HTML lists.)

HTML automatically adds an extra blank line before and after some elements, like before and after a paragraph, and before and after a heading.

More Examples

More paragraphs
This example demonstrates some of the default behaviors of paragraph elements.

Line breaks
This example demonstrates the use of line breaks in an HTML document.

Poem problems
This example demonstrates some problems with HTML formatting.

Headings
This example demonstrates the tags that display headings in an HTML document.

Horizontal rule
This example demonstrates how to insert a horizontal rule.

Hidden comments
This example demonstrates how to insert a hidden comment in the HTML source code.

Text Formatting Tags
Tag Description
<b> Defines bold text
<u> Defines underline text
<big> Defines big text
<em> Defines emphasized text
<i> Defines italic text
<small> Defines small text
<strong> Defines strong text
<sub> Defines subscripted text
<sup> Defines superscripted text
<ins> Defines inserted text
<del> Defines deleted text

Let me add . . .

I can not possibly list every single tag that is available, so if you want to jump ahead, here is a link to a really good HTML Quick List.

Do You Want to Try It?

If you are running Windows, start Notepad.

If you are on a Mac, start SimpleText.

In OSX start TextEdit and change the following preferences: Open the the "Format" menu and select "Plain text" instead of "Rich text". Then open the "Preferences" window under the "Text Edit" menu and select "Ignore rich text commands in HTML files". Your HTML code will probably not work if you do not change the preferences above!

Type in the following text (copy/paste should work also):

Code:
<html>
<head>
<title>Example Page</title>
</head>
<body>
<h1>My Example Page</h1>
<p>Hello there.</p>
Some text here <br />
and some more
</body>
</html>

Save the file as "mypage.htm".

Start your Internet browser. Select "Open" (or "Open Page") in the File menu of your browser. A dialog box will appear. Select "Browse" (or "Choose File") and locate the HTML file you just created - "mypage.htm" - select it and click "Open". Now you should see an address in the dialog box, for example "C:\MyDocuments\mypage.htm". Click OK, and the browser will display the page.

Congratulations, you have created your very first webpage!

Now I'm certain you want to do more to your page, for instance say you want to add a picture!

This requires the <img> tag. Makes sense doesn't it? image = img !!!

Anyway, to add an image you need a few things first. I'll write a correctly written link to an image and then I'll explain it.

<img src="http://i.imgur.com/F0m0Ckz.png" width="32" height="32" border="0" alt="Star" />

<img = begin our image tag
src = where to get our image
width = width of image
height = height of image
border = 0 means none, 1 and on is thickness with the border increasing as does the number
alt = text to show if you don't show the picture
/> = the image tag is a self closing tag, just like the <br /> tag is

When it's all put together correctly, you will show:

F0m0Ckz.webp

But where to put this image code? In your example page you created, mypage.htm, you can place it almost anywhere, between the <body></body> tags.

Preferably, not in the middle of heading tags, however!

Now what if you want to put a text link to another page on your site. Well, let's not stop now, we've come so far now!

Again, let me code a correct link, and then I'll explain it:

<a href="http://www.tierrahosting.com" title="Tierra Hosting">Tierra Hosting</a>

<a = start of the tag, referred to as an Anchor tag
href = the address your linking to
title = suggested title for the document to be opened
</a> = closing tag for the anchor, unlike the <img> tag, an anchor is NOT self closing

When put all together correctly, you'll end up with:

Tierra Hosting

being displayed on your webpage.

As with all the tags of HTML, there are many (and I mean MANY) variables that you can add to modify your code. For instance, with the above anchor/link code I wrote I could of modified it with any of the following:

target="_blank" --> opens linked address in new window
target="_parent" --> works like "_top", but I don't recommend "_parent"
taget="_self" --> opens linked address in this (current) window (same as if you used no target='s at all)
target="_top" --> opens linked address in same window on top of anything being displayed

Overall, I hope you visit the HTML Quick List to get a better grasp on your HTML.

I will post again next time on how to create tables and position of them on your new webpage.

Until next time . . .
 
Back
Top Bottom