0% found this document useful (0 votes)
1 views5 pages

HTML Part2

The document explains the use of HTML comments, formatting tags, and attributes. It details the rules for valid comments, various formatting options like bold and italic, and core attributes such as id, class, and title. Additionally, it covers the purpose and use of HTML meta tags for providing metadata about a document.

Uploaded by

Rahul Das
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views5 pages

HTML Part2

The document explains the use of HTML comments, formatting tags, and attributes. It details the rules for valid comments, various formatting options like bold and italic, and core attributes such as id, class, and title. Additionally, it covers the purpose and use of HTML meta tags for providing metadata about a document.

Uploaded by

Rahul Das
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

HTML Comments: Comment is a piece of code which is ignored by any

web browser. It is a good practice to add comments into our HTML code,
especially in complex documents, to indicate sections of a document, and any
other notes to anyone looking at the code. Comments help you and others
understand your code and increases code readability.

HTML comments are placed in between <!-- ... --> tags. So, any content placed
with-in <!-- ... --> tags will be treated as comment and will be completely
ignored by the browser.

HTML comments are both single line and multi-line.

What are the valid rules of using comments in HTML?

Ans: Rules of a valid comment:

 We cannot nest comments


 The double-dash sequence "--" may not appear inside a comment except
as part of the closing --> tag
 You must also make sure that there are no spaces in the start-of comment
string.

Preserve Formatting: Sometimes, you want your text to follow the exact
format of how it is written in the HTML document. In these cases, you can use
the preformatted tag <pre>.

Any text between the opening <pre> tag and the closing </pre> tag will
preserve the formatting of the source document.
HTML Formatting: HTML has the ability to format how text and character
appear on a website. The following tags are used to format text in HTML.

Bold Tag: Anything that appears within <b>...</b> element, is displayed in


bold

Italics Tag: Anything that appears within <i>...</i> element is displayed in


italicized.

Underline Tag: Anything that appears within <u>...</u> element, is displayed


with underline.

Strike Tag: Anything that appears within <strike>...</strike> element is


displayed with strikethrough

Super Script: The content of a <sup>...</sup> element is written in


superscript; the font size used is the same size as the characters surrounding it
but is displayed half a character's height above the other characters.

Sub Script: The content of a <sub>...</sub> element is written in subscript;


the font size used is the same as the characters surrounding it, but is displayed
half a character's height beneath the other characters.

Larger Text: The content of the <big>...</big> element is displayed one font
size larger than the rest of the text

Smaller Text: The content of the <small>...</small> element is displayed one


font size smaller than the rest of the text surrounding.
HTML Attributes: An attribute is used to define the characteristics of an
HTML element and is placed inside the element's opening tag. All attributes are
made up of two parts − a name and a value.

The name is the property you want to set. For example, the paragraph <p>
element in the example carries an attribute whose name is align, which you can
use to indicate the alignment of paragraph on the page.

The value is what you want the value of the property to be set and always put
within quotations. The below example shows three possible values of align
attribute: left, center and right.

Core HTML attributes: HTML has 4 core attributes that can be used in
majority (although not all) HTML elements, they are:

 Id
 Class
 Title
 Style (will be discussed in CSS)
ID attribute: The id attribute of an HTML tag can be used to uniquely identify
any element within an HTML page. There are two primary reasons that you
might want to use an id attribute on an element –

 If an element carries an id attribute as a unique identifier, it is possible to


identify just that element and its content.
 If you have two elements of the same name within a Web page (or style
sheet), you can use the id attribute to distinguish between elements that
have the same name.

Title Attribute: (don’t confuse with title tag) The title attribute gives a
suggested title for the element. They syntax for the title attribute is similar as
explained for id attribute −The behavior of this attribute will depend upon the
element that carries it, although it is often displayed as a tooltip when cursor
comes over the element or while the element is loading.

Class attribute: The class attribute is used to associate an element with a style
sheet, and specifies the class of element. (This attribute will be discussed in
depth later in CSS).

HTML Meta Tags: HTML lets you specify metadata - additional important
information about a document in a variety of ways. The META elements can be
used to include name/value pairs describing properties of the HTML document,
such as author, expiry date, a list of keywords, document author etc.

The <meta> tag is used to provide such additional information. This tag is an
empty element and so does not have a closing tag but it carries information
within its attributes. You can add metadata to your web pages by placing
<meta> tags inside the header of the document which is represented by <head>
and </head> tags.

The meta tags are used for the following purposes:

1. Document description: You can use <meta> tag to give a short description
about the document. This again can be used by various search engines while
indexing your webpage for searching purpose.

Eg: <meta name= “description” content= “Cricket Live score Website” />
2. Specifying Keywords: You can use <meta> tag to specify important
keywords related to the document and later these keywords are used by the
search engines while indexing your webpage for searching purpose.

Eg: <meta name= “keywords” content= “Cricket, Live score, Fixture” />

3. Document Revision Date: You can use <meta> tag to give information
about when last time the document was updated. This information can be used
by various web browsers while refreshing your webpage.

Eg: <meta name= “revised” content= “[Link], 15/02/2022” />

4. Document refreshing: A <meta> tag can be used to specify a duration after


which your web page will keep refreshing automatically.

Eg: <meta http-eqiv = “refresh” content= “5” />

Or <meta http-eqiv = “refresh” content= “5; url= [Link] />

5. Specifying Character-set: You can use <meta> tag to specify character set
used within the webpage.

Eg: <meta http-eqiv = “Content-Type” content= “text/html; charset= UTF-8” />

You might also like