Thursday, March 6, 2014

HTML Elements

The whole HTML programming language is defined using HTML Elements. It is the main building part of HTML document. An HTML document is everything from start tag to the end tag. You will better understand this by seeing an example of this.

Example :-
Start Tags* The HTML Document End Tag*
<p>This is a paragraph</p>
<a href="homepage.html"This Is a Link</a>
<br>


* The start tag is often called opening tag and end tag is often called closing tag by webmasters. It’s nothing serious although, you can call your tags whatever name you like easily. But professionally speaking we suggest you to use documented terms.

General HTML Syntax :-
We have taught you the general HTML syntax in the last example in very detail. But here is a quick check list of important points to remember and keep in mind.
1. An HTML element starts will always start with start tag/opening tag.
2. An HTML element will always start with end tag/closing tag.
3. The element content is everything between the start and the end tag.
4. There are some HTML Elements which are absolutely empty, meaning that they have empty content.
5. Empty Elements are closed in the start tag.
6. Almost every HTML element has some attributes.
Note : we will discuss HTML attributes with more detail in the next chapter.

Nested HTML Elements :
HTML documents consist of nested HTML tags. It means that on HTML tag can contain other HTML tags. For more explanation, see the example below.

HTML Document Example :

<!Doctype html>
<html>
<body>
<p> This Is My First Paragraph. </p>
</body>
</html>

The HTML document example above has 3 HTML tags nested inside each other. See the explanation below for more understanding.
HTML Example Explained :
The <p> Element :
<p> This Is My First Paragraph. </p>
The <p> element defines a paragraph element in an HTML document.
The <p> element has a starter tag <p>.
The <p> element has an end tag </p>.
The element content is : This Is My First Paragraph.

The <body> Element :
<body>
<p> This Is My First Paragraph. </p>
</body>
The <body> element defines the body of the HTML document.
The element has a start tag <body>.
The element has an end tag </body>.
The element content is another HTML element a <p> element or you can say a paragraph element.

The <HTML> Element :
<html>
<body>
<p> This Is My First Paragraph. </p>
</body>
</html>

The <html> element defines the whole HTML document as described in this lesson : HTML Document Type Declaration.
The element has a start tag <html>.
The element has an end tag </html>.
The element content is another HTML element (the body element) which contains entire HTML page code.

Don't Forget The End Tag :
Some HTML Elements might display correctly even if you forget the end tag. See example below.
<p>This Is A Paragraph.
<p>This Is A Paragraph.
The example above works in most browsers, because the closing tag is considered optional. But it is highly recommended that you always use both closing and opening tags. HTML language changes its specifications and this change can cause problems if you use previous tags of older versions of HTML. Never rely on this. Many HTML Elements will produce unexpected results and/or errors if you forget the end tag.

Empty HTML Elements :
HTML Elements with no content are called empty Elements. Some of these tags are used for defining style information like break line tags.  <br> is an empty element without a closing tag.
(The <br> tag defines a line break).

Tip : in XHTML, all Elements must be closed. Adding a slash inside the start tag, like <br/>, is the proper way of closing empty Elements in XHTML (and xml).

HTML Tip : Use Lowercase Tags :
HTML tags are not case sensitive at all. You can use both uppercase and lowercase letters in writing HTML tags but it is highly recommended that you use only lowercase letters in writing HTML code because some of the browsers might not render HTML with uppercase letters correctly. <p> means the same as <p>. Many web sites use uppercase HTML tags. But we discourage this practice for your own safety and flexibility.
It is also recommended by w3c organization that all web developers must use lowercase letters while writing HTML Web Pages.


No comments:

Post a Comment

All comments are subjected to moderation therefore they may take some time to appear. Thanks for your patience.