Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 47 - ClickGPT V4.0 C-5
P. 47

    TAGS AND ATTRIBUTES

                     As we know, HTML is a markup language. It uses tags to markup the content of the web pages. These
                     tags also have attributes. Let us learn more about tags and attributes.

                     Tags

                     Tags are the basic building blocks of a web page. They tell the browser how the information is to be displayed
                     on the web page. Tags do not appear in the browser window but they affect the display of the text and
                     non-text items within it. Each tag in HTML follows specific rules and syntax. HTML tags are not case-sensitive.

                     In HTML document, a tag name begins with an opening angular bracket (<) and  ends with closing
                     angular bracket (>). For example,

                                                <TagName> content </TagName>

                                                  Opening tag                    Closing tag

                     Both the opening and closing tags are the same. The only difference is that the closing tag contains
                     a forward slash before the  tag name. Most of  the  tags in  HTML  have opening  and  closing  tags. A
                     combination of an opening tag, content, and closing tag is called an element.

                     The HTML tags can be categorised as:
                        Container Tags: The tags that have both opening and closing tags are called Container Tags.
                        For example       <b> ...... </b>
                                                <head> ...... </head>

                         Empty Tags: Empty tags contain only an opening tag. They do not have a closing tag. These tags do
                       not enclose any data.
                        For example       <br>, <hr>, etc.
                     HTML tags can also be further classified as:

                         Block Level Tags: The block level tags take up the full width available and by default begin on a new
                       line. Some of the block level tags are Paragraph <P>, headings <H1> to <H6>, Horizontal Rule <HR>, etc.
                         Text Level Tags: The text level tags are used to mark up parts of the text. These tags do not start with
                       a new line. Some of the text level tags are Bold <B>, Superscript <sup>, Italic <i>, Subscript <sub>, etc.
                     Nesting of Tags

                     Nesting of tags means that you can start a new tag before closing the previous tag. The key point to
                     remember is that tags are nested based on the LIFO principle, that is, Last In First Out. This means that
                     the tag that has been opened last needs to be closed first. For example: <body> <h1> Happy Coding
                     ! </h1> </body>
                     Attribute

                     An  attribute is a property that provides  additional  information about  a tag. It  enhances  the
                     functionality  of a tag. It is always specified  inside  the opening  tag. All  attributes consist of
                     two parts—a name and a value.

                     The ‘name’ is the property that you want to set.
                     The ‘value’ is what you want for the respective property.

                                                                                        Introduction to HTML5 & CSS3    45

| 42 43 44 45 46 47 48 49 50 51 52 |