Thursday 15 January 2015

Elements and Tags - HTML5 Tutorial 2


Tutorial 2: Elements and Tags

You are now ready to learn the essence of HTML: elements.
Elements give structure to a HTML document and tell the browser how you want your website to be presented. Generally elements consist of a start tag, some content, and an end tag.

What are tags?

Tags are labels you use to mark up the beginning and end of an element.
All tags have the same format: they begin with a less-than sign "<" and end with a greater-than sign ">".
Generally speaking, there are two kinds of tags — opening tags: <html> and closing tags: </html>. The only difference between an opening tag and a closing tag is the forward slash "/". You label content by putting it between an opening tag and a closing tag.
HTML is all about elements. To learn HTML is to learn and use different tags.

Can you show me some examples?

Okay, the element em makes text italic. All text between the opening tag <em> and the closing tag</em> is emphasised in the browser by making it display in italics. ("em" is short for "emphasis".)

Example 1:
<em>Emphasised text.</em>

Will look like this in the browser:

Emphasised text.
The elements h1h2h3h4h5 and h6 is used to make headings (h stands for "heading"), where h1is the first level and normally the largest text, h2 is the second level and normally slightly smaller text, and h6 is the sixth and last in the hierarchy of headings and normally the smallest text.

Example 2:
<h1>This is a heading</h1>

<h2>This is a subheading</h2>

Will look like this in the browser:

This is a heading

This is a subheading

So, I always need an opening tag and a closing tag?

As they say, there's an exception to every rule and in HTML the exception is that there are a few elements that both open and close in the same tag. These so-called void elements are not connected to a specific passage in the text but rather are isolated labels. For example, a line break creates an extra line between the last piece of text and the next piece of text and its tag is<br>.

Should tags be typed in uppercase or lowercase?

Most browsers might not care if you type your tags in upper, lower or mixed cases. <HTML><html> or <HtMl> it will normally give the same result. However, the correct way is to type tags in lowercase. So get into the habit of writing your tags in lowercase.

Where do I put all these tags?

You type your tags in an HTML document. A website contains one or more HTML documents. When you surf the Web, you merely open different HTML documents.

If you would keep pace with us then in the Next Document you will learn how to create an HTML5 Website.

Written by

is one of the Team Member of Programmer vs Hacker. He has written many articles on this website and is a patner of this website.

0 comments:

Post a Comment

We’re eager to see your comment. However, Please Keep in mind that comments are moderated manually by our human reviewers according to our comment policy, and all the links are nofollow. Using Keywords in the name field area is forbidden. Let’s enjoy a personal and evocative conversation.

© 2015 Programmer vs Hacker. All rights resevered.