When I was learning HTML, I prepared small documents about it, in order to refer to it when I forget some HTML concepts. Now the first part of this simple hints or tutorial is ready and I post it here for those who want to learn HTML. I hope that it could be useful for you.
A simple HTML page has the following elements,
- doctype
- html
- head
- title
- body
Below code, is a simple code of an HTML page.
<!DOCTYPE html>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
</body>
</html>
The use of doctype is to determines the version of HTML used in the source. This tag is a guideline for browsers for rendering the web page. In above code, the document type is restricted version of XHTML 1.0. Doctype tag should be existed in every HTML page before any tags even before white space or break line.
HTML tag has one attribute which is called as xmlns
. The xmlns attribute is required in XHTML, but is invalid in HTML. The xmlns attribute specifies the xml namespace for a document.
The tags which do not need closing tags are called as self closing tags. For instance, br and meta tags are two types of self closing tags.
Meta tag is used inside of head tag to express more information about the documents. For instance, met tag could contain a short description about the page or author of the page. This tag could be good guide line for web browser and could be effective for search engines. Look at below meta tag,
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
The above meta tags determines the user character set in the document.
For making list in HTML web page, two types of tags are available. One for ordered list and the other for unordered list. For ordered list ol
(ordered list) tag should be used and for unordered list ul
should be used. For items or elements of the list li
tag is used.
<ol>
<li>Hi</li>
<li>There!</li>
</ol>
<ul>
<li>I’m</li>
<li>happy</li>
</ul>
You can put comment in your HTML code like other programming language, take a look at the below example,
<!-- This is comment. - - >
Before starting writing anything in the website, firstly p
tag should be used. This means that br
, em
, i
, b
, etc. tags should be inside of p
tag. Otherwise, the web page is not validated by W3 website.
It can be assume that em
(emphasize) tag and i
(italic) tag have no difference with each other at all.
Using >
and <
symbols are not possible with simply write those symbols since X/HTML considers them as tag, therefore, you can use entities in the text instead of those symbol. Look at the following table to learn about most used entities in X/HTML.
Entity |
Symbol |
> |
> |
< |
< |
& |
& |
£ |
£ |
© |
© |
™ |
TM |
|
space |
is used when you want to make more than one space consecutively.