HTML Basics Tutorial
Ranked #1,106 in Internet, #61,182 overall
What's HTML?
Previews added!
How to create a HTML webpage?
Knowing this, we can start writing HTML inside of this file. Open the HTML file with notepad. Now we're ready to write HTML inside of this file. A HTML webpage usually starts and ends with the HTML tag. In general tags are formed with the < and > symbol, where < opens the tag and > ends the tag and between it we write the name of the tag. However: some ( or should I say: many ) HTML tags consist of a start and end tag. The 'end tag' has a slashforward (/) in it. So in general:
<begin tagname>
</end tagname>
<html>
</html>
<html>
<head>
</head>
<body>
</body>
<footer>
</footer>
</html>
<title> My First HTML Webpage! </title>
We have to put this inside of the head part - inbetween of the head tags. We can also give the webpage a background color by adding the bgColor attribute to the body tag of the webpage, all together:<html>
<head>
<title> My First HTML Webpage! </title>
</head>
<body bgColor="blue">
This text will be displayed on my webpage! The background color is now blue, how wonderful. For color codes check out this webpage.
</body>
<footer>
This text will be displayed on my webpage, as well! Just on the same place as the other text, so the foot tags are just for the style of the code and do not have any effect on the text put in between of it. Therefore the footer tag isn't used a lot, more essential are the html, head and body tags.
</footer>
</html>
Preview: Click here
Marking up text.
b tag
The b tag makes the text that's put in between of the begin and end tag bold:
<b>This text is bold now.</b>
which outputs:This text is bold now.
i tag
The i tag makes text that's put in between of the begin and end tag italic:
<i>This text is italic now.</i>
which outputs:This text is italic now.
u tag
The u tag makes text that's put in between of the begin and end tag underlined:
<u>This text is underlined now.</u>
which outputs:This text is underlined now.
del tag
The del tag makes text that's put in between of the begin and end tag crossed out (line through it):
<del>This text is put a line through now - 'deleted'.</del>
Click here for previewCreating blank lines and paragraphs.
This is line 1. <br /> This is line 2.
which outputs:This is line 1.
This is line 2.
Note: Simply putting a blank line into the code won't work in HTML and therefore the br tag is required to put a blank line inbetween different sentences. At squidoo the text filled into the textareas is automaticly converted and blank lines are therefore automaticly converted to br tags.
To add extra spaces in between words the syntax is used ( simply hitting spaces won't work unless the text is put between pre tags - the same goes for enters ). E.g.:
this will work:
word1 word2 <br /> word3 word4
but this will work too:<pre>word1 word2
word3 word4</pre>
<p>This is a heading.</p>
which outputsThis is a paragraph.
Note: the p begin tag can also be used alone ( without an end tag nor text ) to create a larger blank line.
Creating links.
<a href="url" target="target">link text</a>
Where 'url' is the url the link points to and 'link text' is the text to be displayed for the link. The target attribute is optional: if you like to have the link opened in a new window for example, you could use target="_blank". You can also leave the target attribute out of it and it will just open the link in the current tab. So for example:< a href="http://www.squidoo.com">Click here to go to Squidoo.com!</a>
outputs:Click here to go to Squidoo.com!
Creating lists.
- ul - creates an unordered list.
- ol - creates an ordered list.
- li - adds a list item to the unordered or ordered list.
So for example we could create an unordered list with 3 items in it:
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
- Item 1
- Item 2
- Item 3
But we could also make it an ordered list:
<ol>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ol>
- Item 1
- Item 2
- Item 3
Creating forms.
<form method="method" action="action" name="name">
</form>
However a form would be pretty useless without any input fields and fortunately these can be created with the input tag:
<input type="type" name="name" value="value">
where type = the type of input field, which can be for example:- text - a text input field (most common type
- submit - submit button to submit the form with
- radio - clickable circle, in one form only 1 radio input field can be selected
- checkbox - clickable square, in one form multiple checkboxes can be checked
- hidden - a hidden input field that cannot be seen by the user (nor altered) but IS submitted by the form
Note: there are more html input types which are not mentioned ( as they're less common or more 'complicated' ) such as files, images and reset.
further the name and value of the input field are optional; the name however is pretty essential for the submission as input fields are submitted by their name and corresponding value. The value that can be set for the input field is just a beginvalue (that can be changed by the user that fills in the input field).
To make an input field uneditable the READONLY attribute can be added to the input tag. To actually disable an input field (=uneditable AND not sent through form submission) use the DISABLE attribute. For example:
<input type="text" name="field1" value="test" READONLY>
<input type="text" name="field2" value="test" DISABLED>
test.html
<form method="POST" action="test.html">
<input type="text" name="test">
<input type="submit" name="submit_button" value="Submit Form!">
</form>
Creating headings.
<h1>This is a large heading!</h1>
<h6>This is a very small heading</h6>
Click here for a previewCreating images.
<img src="img path or url" border="px size">
where 'img path or url' is the path from the current directory to the img ( for example: images/my_image.jpg ) or the url to the img ( for example: somewebsite.com/images/my_image.jpg ). The border is not necessary to be set but is optional. An example of usage:<img src="http://img98.imageshack.us/img98/3513/wlogo.png">
which outputs:
It's also possible to set a width and height attribute for the image. If only the width attribute is set, the height is automaticly generated ( keeping the same width:height relation as the original image ):
<img src="http://img98.imageshack.us/img98/3513/wlogo.png" width="50">
which outputs:
We could also combine the a href tag and the img tag to create a link for the image:
<a href="http://www.squidoo.com/lensmasters/webcodez"><img src="http://img98.imageshack.us/img98/3513/wlogo.png" border="0"></a>
which outputs:
Note: We set the border=0 attribute for the image because when linking an image it automaticly gets a border which isn't desired in this case.
Creating iframes.
<iframe src="url" width="px width" height="px height"></iframe>
Where url is the url of the webpage to display within the iframe and px width/px height is the size of the iframe in pixels (optional).Creating tables.
Anyway, tables in HTML can still be useful for displaying data easily within a table. To initially create a table use:
<table border="px border" width="px width" height="px height">
</table>
<table border="1">
<tr>
<td>Row1 Cell1</td>
<td>Row1 Cell2</td>
<td>Row1 Cell3</td>
</tr>
<tr>
<td>Row2 Cell1</td>
<td>Row2 Cell2</td>
<td>Row2 Cell3</td>
</tr>
</table>
Creating divs.
<div id="optional id">
</div>
Some examples of styles that can be set for a div are: width, height, border, background(-color) and float (=position of divs relative to eachother, e.g. left from the previous divs or just below them). The usage is:
<div style="...">
</div>
<div style="width: 500px; height: 250px; border: 1px solid black;">
Some text for the div to display,
</div>
Creating meta tags.
<meta name="name" content="content" lang="lang">
where name is the name of the meta tag ( e.g. keywords ), content is the 'value' of the meta tag ( e.g. keyword1,keyword2,keyword3 ) and lang is the language in which the content of the meta tag is written ( e.g. en ). So, we could for example have a meta tag supplying the search engine with keywords for our webpage like this:<meta name="keywords" content="keyword1, keyword2, keyword3" lang="en">
More types of commonly used meta tags are (by name):- description - for supplying the search engines with a description of your webpage, e.g.:
<meta name="description" content="This is a description for my webpage." lang="en">
- author - for supplying the search engines with the author of the webpage, e.g.:
<meta name="author" content="Webcodez" lang="en">
- robots - If you wish your website not to be crawled by search engines, then the robots meta tag can be used which can have multiple values, most importantly: none ( website won't be index and links on webpages won't be followed by crawler ), index or noindex (crawler will or will not index the webpage), follow or nofollow (crawler will or will not follow the links on the webpage):
<meta name="robots" content="(no)index, (no)archive, (no)follow">
You might also like ...
Learn more HTML from books
Learn more CSS from books
Comments & Questions
Got any questions about the tutorial or just want to comment? This is the place to do so.
-
-
Ladymermaid
Feb 25, 2012 @ 12:18 pm | delete
- There is always so very much to learn when you work online. I have definitely got to write it all down one day because I am always loosing the html code that I need.
-
-
-
StaCslns
Feb 16, 2012 @ 7:49 am | delete
- Thank you! You made this easy to understand! It's obvious you took your time to help us understand html.
-
-
-
cffutah
Feb 7, 2012 @ 8:34 am | delete
- Some great tips for others, well done.
-
-
-
JeriBaker Nov 15, 2011 @ 8:21 am | delete
- Great information. I am teaching myself as I go along, and I have bookmarked your lens. I am sure I will refer to it often. Thank you.
-
-
-
canoz
Oct 18, 2011 @ 4:59 am | delete
- Thank you so much for this information. It's a simple and basic explanation for me to start with that wasn't too overwhelming! Gives me a lot to play with while I'm finding my way with lots of other new things as well! ;-)
-
- Load More
by webcodez
"Give a man a program and you'll frustrate him for one day. Teach a man to program and you'll frustrate him for a whole lifetime."
webcodez
GameHeroes
more »
- 21 featured lenses
- Winner of 14 trophies!
- Top lens » PHP & MySQL Poll System Tutorial
Explore related pages
- PHP basics tutorial PHP basics tutorial
- MySQL Basics Tutorial MySQL Basics Tutorial
- Free Images and How to Use Them Free Images and How to Use Them
- Make Recipe Cards For Your Site Using Advanced HTML Tables Make Recipe Cards For Your Site Using Advanced HTML Tables
- Squidoo Lenses I Wish I Had Written Squidoo Lenses I Wish I Had Written
- Meta Tags Meta Tags