Basic HTML Tags
The most important tags in HTML are tags that define headings, paragraphs and line breaks.
_______________________________________________________________________________
► Headings
Headings are defined with the <h1> to <h6> tags. <h1> defines the largest heading. <h6> defines the smallest heading.
<h1>This is a heading</h1> <h2>This is a heading</h2> <h3>This is a heading<h3> <h4>This is a heading</h4> <h5>This is a heading</h5> <h6>This is a heading</h5> |
HTML automatically adds an extra blank line before and after a heading.
_______________________________________________________________________________
► Paragraphs
Paragraphs are defined with the <p> tag.
<p>This is a paragraph</p> <p>This is another paragraph</p> |
HTML automatically adds an extra blank line before and after a paragraph.
_______________________________________________________________________________
► Don't Forget the Closing Tag
You might have noticed that paragraphs can be written without end tags :
<p>This is a paragraph <p>This is another paragraph |
The example above will work in most browsers, but don't rely on it. Future version of HTML will not allow you to skip ANY end tags.
Closing all HTML elements with an end tag is a future proof way of writing HTML. It also makes the code easier to understand (read and browse) when you to mark both where an element starts and where it ends.
_______________________________________________________________________________
► Line Breaks
The <p> tag is used when you want to break a line, but don't want to start a new paragraph. The tag forces a line break wherever you place it.
<p>This <br> is a para <br> graph with line breaks</p> |
The <br> tag is an empty tag. It has no end tag like </br>, since a closing tag doesn't make any sense.
_______________________________________________________________________________
► <br> or <br/>
More and more often you will see the <br> tag written like this: <br/>
Because the <br> tag has no end tag (or closing tag), it breaks one of the rules for future HTML (the XML based XHTML), namely that all elements must be closed.
Writing it like <br/> is a future proof way of closing (or ending) the tag inside the opening tag, accepted by both HTML and XML.
_______________________________________________________________________________
► Comments in HTML
The comment tag is used to insert a comment in the HTML source code. A comment will be ignored by the browser. You can use comments to explain your code, which can help you when you edit the source code at a later date.
<!-- This is a comment --> |
Note that you need an exclamation point after the opening bracket, but not before the closing bracket.
_______________________________________________________________________________
► Basic HTML Tags
If you lookup the basic HTML tags in the reference below, you will see that the reference contains additional information about tag attributes.
You will learn more about HTML tag attributes in the next chapter of this tutorial.
Tag | Description |
---|---|
<html> | Defines an HTML document |
<body> | Defines the document's body |
<h1> to <h6> | Defines header 1 to header 6 |
<p> | Defines a paragraph |
<br> | Inserts a single line break |
<hr> | Defines a horizontal rule |
<!--> | Defines a comment |
Text Formatting Tags
Tag | Description |
---|---|
<b> | Defines bold text |
<big> | Defines big text |
<em> | Defines emphasized text |
<i> | Defines italic text |
<small> | Defines small text |
<strong> | Defines strong text |
<sub> | Defines subscripted text |
<sup> | Defines superscripted text |
<ins> | Defines inserted text |
<del> | Defines deleted text |
<s> | Deprecated. Use <del> instead |
<strike> | Deprecated. Use <del> instead |
<u> | Deprecated. Use styles instead |
"Computer Output" Tags
Tag | Description |
---|---|
<code> | Defines computer code text |
<kbd> | Defines keyboard text |
<samp> | Defines sample computer code |
<tt> | Defines teletype text |
<var> | Defines a variable |
<pre> | Defines preformatted text |
<listing> | Deprecated. Use <pre> instead |
<plaintext> | Deprecated. Use <pre> instead |
<xmp> | Deprecated. Use <pre> instead |
Citations, Quotations, and Definition Tags
Tag | Description |
---|---|
<abbr> | Defines an abbreviation |
<acronym> | Defines an acronym |
<address> | Defines an address element |
<bdo> | Defines the text direction |
<blockquote> | Defines a long quotation |
<q> | Defines a short quotation |
<cite> | Defines a citation |
<dfn> | Defines a definition term |
Regards:-
Manan Saini.
No comments:
Post a Comment