Subscribe For Free Updates!

We'll not spam mate! We promise.

Showing posts with label HTML සරලව. Show all posts
Showing posts with label HTML සරලව. Show all posts

Monday, March 17, 2014

HTML Fonts



Font face and color depends entirely on the computer and browser that is being used to view your page. But the <font> tag is used to add style, size, and color to the text on your site. You can use a <basefont> tag to set all of your text to the same size, face, and color.
The font tag is having three attributes called size, color, and face to customize your fonts.
To change any of the font attributes at any time within your page, simply use the <font> tag. The text that follows will remain changed until you close with the </font> tag. You can change any or all of the font attributes at the one time, by including all the required changes within the one <font> tag.
NOTE: The font and basefont tags are deprecated and it is supposed to be removed in a future version of HTML. So it should not be used. Its is suggested to use css styles to manipulate your font.

Font Size:

You can set the size of your font with size attribute. The range of accepted values is from 1(smallest) to 7(largest). The default size of a font is 3.
Example:
<font size="1">Font size="1"</font>
<font size="2">Font size="2"</font>
<font size="3">Font size="3"</font>
<font size="4">Font size="4"</font>
<font size="5">Font size="5"</font>
<font size="6">Font size="6"</font>
<font size="7">Font size="7"</font>
This will produce following result:
Font size="1"
Font size="2"
Font size="3"
Font size="4"
Font size="5"
Font size="6"
Font size="7"
SPECIFY THE RELATIVE FONT SIZE. <font size="+n"> or <font size="-n">:
You can specify how many sizes larger or how many sizes smaller than the preset font size should be.
Example:
<font size="-1">Font size="-1"</font>
<font size="+1">Font size="+1"</font>
<font size="+2">Font size="+2"</font>
<font size="+3">Font size="+3"</font>
<font size="+4">Font size="+4"</font>
This will produce following result:
Font size="-1"
Font size="+1"
Font size="+2"
Font size="+3"
Font size="+4"

Font Face:

You can set any font you like using face attribute but be aware that if the user viewing the page doesn't have the font installed, they will not be able to see it. Instead they will default to Times New Roman of your font with size attribute. See below few examples on using different font face
Example:
<font face="Times New Roman" size="5">Times New Roman</font>
<font face="Verdana" size="5">Verdana</font>
<font face="Comic sans MS" size="5">Comic Sans MS</font>
<font face="WildWest" size="5">WildWest</font>
<font face="Bedrock" size="5">Bedrock</font>
This will produce following result:
Times New Roman
Verdana
Comic Sans MS
WildWest
Bedrock

Specify alternate font faces:

A visitor will only be able to see your font if they have that font installed on their computer. So, it is possible to specify two or more font face alternatives by listing the font face names, separated by a comma.
Example:
<font face="arial,helvetica">
<font face="Lucida Calligraphy,Comic Sans MS,Lucida Console>
When your page is loaded, their browser will display the first font face that it has available. If none of your selections are installed....then it will display the default font face Times New Roman.
Check a complete list of HTML Standard Fonts.

Font Color:

You can set any font color you like using color attribute. You can specify the color that you want by either the color name or hexadecimal code for that color. Check a complete list of HTML Color Name with Codes.
Example:
<font color="#FF00FF">This text is hexcolor #FF00FF</font>
<font color="red">This text is red</font>
This will produce following result:
This text is hexcolor #FF00FF
This text is red
To Become more comfortable - Do Online Practice

The <basefont> Element:

The <basefont> element is supposed to set a default font size, color, and typeface for any parts of the document that are not otherwise contained within a <font> element. You can then use the <font> elements to override the <basefont> settings.
The attributes that the <basefont> element takes are exactly the same as for the <font> element. You can also set the size of fonts relative to the size of the <basefont> by giving them a value of +1 for a size larger or -2 for two sizes smaller
NOTE: This element is deprecated in HTML 4 and will be removed from HTML, the preferred option is to use CSS styles. Your browser may not have support for this tag.

Example:

<basefont face="arial, verdana, sans-serif" size="2" color="#ff0000">
<p>This is the page's default font.</p>
<h2>Example of the &lt;basefont&gt; Element</h2>
<p><font size="+2" color="darkgray">Here is some darkgray text
two sizes larger</font></p>
<p><font face="courier" size="-1" color="#000000">Here is a courier
font, a size smaller, in black</font></p>
This will produce following result:

This is the page's default font.

Example of the <basefont> Element

Here is some darkgray text
two sizes larger
Here is a courier
font, a size smaller, in black
As you can see, the default font now takes on the properties specified in the <basefont> element. It is red, size 2, and uses the Arial typeface.
The paragraph after the <h2> element uses a font size two sizes larger than the default size and is gray text, whereas the following paragraph uses a font one size smaller than the default font. You can also see that the color of this font is black (overriding the default).


HTML Comments




Comments are piece of code which is ignored by any web browser. It is good practice to comment your 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.
HTML Comment lines are indicated by the special beginning tag <!-- and ending tag --> placed at the beginning and end of EVERY line to be treated as a comment.
Comments do not nest, and 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.
For example: Given line is a valid comment in HTML
<!--   This is commented out -->
But following line is not a valid comment and will be displayed by the borwser. This is because there is a space between the left angle bracket and the exclamation mark.
< !--   This is commented out -->
Be careful if you use comments to "comment out" HTML that would otherwise be shown to the user, since some older browsers will still pay attention to angle brackets inside the comment and close the comment prematurely -- so that some of the text that was supposed to be inside the comment mistakenly appears as part of the document.

Multiline Comments:

You have seen how to comment a single line in HTML. You can comment multiple lines by the special beginning tag <!-- and ending tag --> placed before the first line and end of the lastline to be treated as a comment.
For example:
<!--   
This is a multiline comment <br />
and can span through as many as lines you like.
-->

Conditional Comments :

Conditional comments only work in Explorer on Windows, and are thus excellently suited to give special instructions meant only for Explorer on Windows. They are supported from Explorer 5 onwards, and it is even possible to distinguish between 5.0, 5.5 and 6.0.
Conditional comments work as follows:
<!--[if IE 6]>
Special instructions for IE 6 here
<![endif]-->
  • Their basic structure is the same as an HTML comment (<!-- -->). Therefore all other browsers will see them as normal comments and will ignore them entirely.
  • Explorer Windows, though, has been programmed to recognize the special <!--[if IE]> syntax, resolves the if and parses the content of the conditional comment as if it were normal page content.
  • Since conditional comments use the HTML comment structure, they can only be included in HTML files, and not in CSS files.

Using Comment tag

There are few browsers who supports <comment> tag to comment a part of code.
<p>This is <comment>not</comment> Internet Explorer.</p>

Commenting Scripts and Style Sheets:

If you are using Java Script or VB Script in your HTML code then it is recommended to put that script code inside proper HTML Comments to make old browser works properly.
For example:
<script>
<!-- 
document.write("Hello World!")
//-->
</script>
Similarly if you are using Casecading Style Sheet in your HTML code then it is recommended to put that style sheet code inside proper HTML Comments to make old browser works properly.
For example:
<style>
<!-- 
img{
  border:0px;
}
//-->
</style>

HTML Phrase Tags



While some of these phrase elements are displayed in a similar manner to the <b>, <i>, <pre>, and <tt> elements you have already seen, they are designed for specific purposes. For example, the <em> and <strong> elements give text emphasis and strong emphasis respectively and there are several elements for marking up quotes.
We will see all phrase tags in this section with examples.

Emphasized Text - The <em> Element:

The content of an <em> element is intended to be a point of emphasis in your document, and it is usually displayed in italicized text. The kind of emphasis intended is on words such as "must" in the following sentence:
<p>You <em>must</em> remember to close elements in XHTML.</p>
This will produce following result:
You must remember to close elements in XHTML.
To Become more comfortable - Do Online Practice

Strong Text - The <strong> Element:

The <strong> element is intended to show strong emphasis for its content; stronger emphasis than the <em> element. As with the <em> element, the <strong> element should be used only when you want to add strong emphasis to part of a document.
<p>You <strong>must</strong> remember to close elements in XHTML.</p>
This will produce following result:
You must remember to close elements in XHTML.
To Become more comfortable - Do Online Practice

Text Abbreviation - The <abbr> Element :

You can indicate when you are using an abbreviated form by placing the abbreviation between opening <abbr> and closing </abbr> tags.
<p>I have a friend called <abbr title="Abhishek">Abhy</abbr>.</p>
This will produce following result:
I have a friend called Abhy.
To Become more comfortable - Do Online Practice

Using Acronym - The <acronym> Element :

The <acronym> element allows you to indicate that the text between an opening <acronym> and closing </acronym> element is an acronym.
When possible use a title attribute whose value is the full version of the acronyms on the <acronym> element, and if the acronym is in a different language, include an xml:lang attribute in XHTML documents.
<p>This chapter covers marking up text in <acronym title="Extensible Hypertext Markup Language">XHTML</acronym>.</p>
This will produce following result:
This chapter covers marking up text in XHTML.
At present, the major browsers do not change the appearance of the content of the <acronym> element.
To Become more comfortable - Do Online Practice

Special Terms - The <dfn> Element :

The <dfn> element allows you to specify that you are introducing a special term. Its use is similar to the words that are in italics in the midst of paragraphs in this book when new key concepts are introduced.
Typically, you would use the <dfn> element the first time you introduce a key term and only in that instance. Most recent browsers render the content of a <dfn> element in an italic font.
<p>This tutorial teaches you how mark up your documents for the web using <dfn>XHTML</dfn>.</p>
This will produce following result:
This tutorial teaches you how mark up your documents for the web using XHTML.
To Become more comfortable - Do Online Practice

Quoting Text - The <blockquote> Element :

When you want to quote a passage from another source, you should use the <blockquote> element.
Text inside a <blockquote> element is usually indented from the left and right edges of the surrounding text, and sometimes uses an italicized font.
<p>The following description of XHTML is taken from the W3C Web site:</p>

<blockquote> XHTML 1.0 is the W3C's first Recommendation for XHTML, following on from earlier work on HTML 4.01, HTML 4.0, HTML 3.2 and HTML 2.0. </blockquote>
This will produce following result:
The following description of XHTML is taken from the W3C Web site:
XHTML 1.0 is the W3C's first Recommendation for XHTML, following on from earlier work on HTML 4.01, HTML 4.0, HTML 3.2 and HTML 2.0.
You can use the cite attribute on the <blockquote> element to indicate the source of the quote.
<p>The following description of XHTML is taken from the W3C Web site:</p>

<blockquote cite="http://www.w3.org/markup/"> XHTML 1.0 is the W3C's first Recommendation for XHTML, following on from earlier work on HTML 4.01, HTML 4.0, HTML 3.2 and HTML 2.0. </blockquote>
To Become more comfortable - Do Online Practice

Short Quotations - The <q> Element :

The <q> element is intended to be used when you want to add a quote within a sentence rather than as an indented block on its own.
<p>Amit is in Spain, <q>He is their at my home. I think I am wrong</q>.</p>
This will produce following result:
Amit is in Spain, He is their at my home. I think I am wrong.
The <q> element can also carry the cite attribute. The value should be a URL pointing to the source of the quote.
To Become more comfortable - Do Online Practice

Citations - The <cite> Element :

If you are quoting a text, you can indicate the source placing it between an opening <cite> tag and closing </cite> tag
As you would expect in a print publication, the content of the <cite> element is rendered in italicized text by default.
<p>This HTML Tutorial is derived from <cite>World Wide Web Standard for HTML</cite>.</p>
This will produce following result:
This HTML Tutorial is derived from World Wide Web Standard for HTML.
To Become more comfortable - Do Online Practice

Computer Code - The <code> Element :

Any code to appear on a Web page should be placed inside a <code> element. Usually the content of the <code> element is presented in a monospaced font, just like the code in most programming books.
<h1> <code>This is inside code element</code></h1>
This will produce following result:

This is inside code element

To Become more comfortable - Do Online Practice

Keyboard Text - The <kbd> Element :

When you are talking about computers, if you want to tell a reader to enter some text, you can use the <kbd> element to indicate what should be typed in, as in this example.
The content of a <kbd> element is usually represented in a monospaced font rather like the content of the <code> element.
<h1> <kbd>This is inside kbd element</kbd></h1>
This will produce following result:

This is inside kbd element

To Become more comfortable - Do Online Practice

Programming Variables - The <var> Element :

This element is usually used in conjunction with the <pre> and <code> elements to indicate that the content of that element is a variable that can be supplied by a user.
<p><code>document.write("<var>user-name</var>")</code></p>
This will produce following result:
document.write("user-name")
To Become more comfortable - Do Online Practice

Program Output - The <samp> Element :

The <samp> element indicates sample output from a program, script, or the like. Again, it is mainly used when documenting programming concepts. For example:
<p>Result produced by the program is <samp>Hello World</samp></p>
This will produce following result:
Result produced by the program is Hello World
To Become more comfortable - Do Online Practice

Addresses - The <address> Element :

The <address> element is used to contain any address. For example:
<address>304, Menna Colony, Hyderabad - INDIA, 500032</address>
This will produce following result:
304, Menna Colony, Hyderabad - INDIA, 500032
To Become more comfortable - Do Online Practice

Block and Inline Elements:

We can categories all the elements into two sections:
  • Block-level elements - Block-level elements appear on the screen as if they have a carriage return or line break before and after them. For example the <p>, <h1>, <h2>, <h3>, <h4>, <h5>, <h6>, <ul>, <ol>, <dl>, <pre>, <hr />, <blockquote>, and <address> elements are all block level elements. They all start on their own new line, and anything that follows them appears on its own new line.
  • Inline elements - Inline elements, on the other hand, can appear within sentences and do not have to appear on a new line of their own. The <b>, <i>, <u>, <em>, <strong>, <sup>, <sub>, <big>, <small>, <li>, <ins>, <del>, <code>, <cite>, <dfn>, <kbd>, and <var> elements are all inline elements.
The elements which we have not discussed till now, will be discussed in subsequent chapters.

HTML Formatting Tags




If you want people to read what you have written, then structuring your text well is even more important on the Web than when writing for print. People have trouble reading wide, long, paragraphs of text on Web sites unless they are broken up well.
This section will teach you basic text formatting elements like heading elements and paragraph elements.

Whitespace and Flow:

Before you start to mark up your text, it is best to understand what HTML does when it comes across spaces and how browsers treat long sentences and paragraphs of text.
You might think that if you put several consecutive spaces between two words, the spaces would appear between those words onscreen, but this is not the case; by default, only one space will be displayed. This is known as white space collapsing. So you need to use special HTML tags to create multiple spaces.
Similarly, if you start a new line in your source document, or you have consecutive empty lines, these will be ignored and simply treated as one space. So you need to use special HTML tags to create more number of empty lines.

Create Headings - The <hn> Elements:

Any documents starts with a heading. You use different sizes for your headings. HTML also have six levels of headings, which use the elements <h1>, <h2>, <h3>, <h4>, <h5>, and <h6>. While displaying any heading, browser adds one line before and after that heading.
Example:
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
<h4>This is heading 4</h4>
<h5>This is heading 5</h5>
<h6>This is heading 6</h6>
This will display following result:

This is heading 1

This is heading 2

This is heading 3

This is heading 4

This is heading 5
This is heading 6
To Become more comfortable - Do Online Practice

Create Paragraph - The <p> Element:

The <p> element offers a way to structure your text. Each paragraph of text should go in between an opening <p> and closing </p> tag as shown below in the example:
<p>Here is a paragraph of text.</p>
<p>Here is a second paragraph of text.</p>
<p>Here is a third paragraph of text.</p>
This will produce following result:
Here is a paragraph of text.
Here is a second paragraph of text.
Here is a third paragraph of text.
You can use align attribute to align your paragraphs.
<p align="left">This is left aligned.</p>
<p align="center">This is center aligned.</p>
<p align="right">This is right aligned.</p>
<p align="justify">This is jutified. This works when you have multiple lines in your paragraph and you want to justfy all the lines so that they can look more nice.</p>
This will produce following result:
This is left aligned.
This is center aligned.
This is right aligned.
This is jutified. This works when you have multiple lines in your paragraph and you want to justfy all the lines so that they can look more nice.
To Become more comfortable - Do Online Practice

Create Line Breaks - The <br /> Element:

Whenever you use the <br /> element, anything following it starts on the next line. This tag is an example of an empty element, where you do not need opening and closing tags, as there is nothing to go in between them.
Note: The <br /> element has a space between the characters br and the forward slash. If you omit this space, older browsers will have trouble rendering the line break, while if you miss the forward slash character and just use <br> it is not valid XHTML
Example:
Hello<br />
You come most carefully upon your hour.<br />
Thanks<br />
Mahnaz
This will produce following result:
Hello

You come most carefully upon your hour.

Thanks

Mahnaz
To Become more comfortable - Do Online Practice

Centring Content - The <center> Element:

You can use <center> tag to put any content in the center of the page or any table cell.
Example:
<p>This is not in the center.</p>
<center>
<p>This is in the center.</p>
</center>
This will produce following result:
This is not in the center.
This is in the center.

Nonbreaking Spaces:

Suppose you were to use the phrase "12 Angry Men." Here you would not want a browser to split the "12" and "Angry" across two lines:
A good example of this technique appears in the movie "12 Angry Men."
In cases where you do not want the client browser to break text, you should use a nonbreaking space entity (&nbsp;) instead of a normal space. For example, when coding the "12 Angry Men" paragraph, you would use something similar to the following code:
<p>A good example of this technique appears in the movie "12&nbsp;Angry&nbsp;Men."</p>

Soft Hyphens:

Occasionally, you will want to allow a browser to hyphenate long words to better justify a paragraph. For example, consider the following code and its resulting output.
<p style="text-align: justify;"> The morbid fear of the number 13, or triskaidekaphobia, has plagued some important historic figures like Mahamiya and Nanao.</p>
In cases where you want a client browser to be able to hyphenate a word if necessary, use the soft hyphen entity (&shy;) to specify where a word should be hyphenated. So above example should be written as follows:
<p style="text-align: justify;"> Example for soft hyphen - The morbid fear of the number 13, or tri&shy;skai&shy;deka&shy;phobia, has plagued some important historic figures like Mahamiya and Nanao.</p>
This will produce following result:
Example for soft hyphen - The morbid fear of the number 13, or tri­skai­deka­phobia, has plagued some important historic figures like Mahamiya and Nanao.
NOTE: This may notwork with some web browsers.

Preserve Formatting - The <pre> Element:

Sometimes you want your text to follow the exact format of how it is written in the HTML document. In those 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.
<pre>
function testFunction( strText ){
   alert (strText)
}
</pre>
This will produce following result:
function testFunction( strText ){
   alert (strText)
}
To Become more comfortable - Do Online Practice

Horizontal Rules - The <hr /> Element

Horizontal rules are used to visually break up sections of a document. The <hr> tag creates a line from the current position in the document to the right margin and breaks the line accordingly.
For example you may want to give a line between two paragraphs as follows:
<p>This is paragraph one and should be on top</p>
<hr />
<p>This is paragraph two and should be at bottom</p>
This will produce following result:
This is paragraph one and should be on top

This is paragraph two and should be at bottom
Again <hr /> tag is an example of an empty element, where you do not need opening and closing tags, as there is nothing to go in between them.
Note: The <hr /> element has a space between the characters br and the forward slash. If you omit this space, older browsers will have trouble rendering the line break, while if you miss the forward slash character and just use <hr> it is not valid XHTML
To Become more comfortable - Do Online Practice

Presentational Tags:

If you use a word processor, you are familiar with the ability to make text bold, italicized, or underlined; these are just three of the ten options available to indicate how text can appear in HTML and XHTML.

Bold Text - The <b> Element:

Anything that appears in a <b>...</b> element is displayed in bold, like the word bold here:
<p>The following word uses a <b>bold</b> typeface.</p>
This will produce following result:
The following word uses a bold typeface.
To Become more comfortable - Do Online Practice

Italic Text - The <i> Element:

Anything that appears in a <i>...</i> element is displayed in italicized, like the word italicized here:
<p>The following word uses a <i>italicized</i> typeface.</p>
This will produce following result:
The following word uses a italicized typeface.
To Become more comfortable - Do Online Practice

Underlined Text - The <u> Element:

Anything that appears in a <u>...</u> element is displayed with underline, like the word underlined here:
<p>The following word uses a <u>underlined</u> typeface.</p>
This will produce following result:
The following word uses a underlined typeface.
To Become more comfortable - Do Online Practice

Strike Text - The <strike> Element:

Anything that appears in a <strike>...</strike> element is displayed with strikethrough, which is a thin line through the text:
<p>The following word uses a <strike>strikethrough</strike> typeface.</p>
This will produce following result:
The following word uses a strikethrough typeface.
To Become more comfortable - Do Online Practice

Monospaced font - The <tt> Element:

The content of a <tt> element is written in monospaced font. Most fonts are known as variable-width fonts because different letters are of different widths (for example, the letter m is wider than the letter i). In a monospaced font, however, each letter is the same width.
<p>The following word uses a <tt>monospaced</tt> typeface.</p>
This will produce following result:
The following word uses a monospaced typeface.
To Become more comfortable - Do Online Practice

Superscript Text - The <sup> Element:

The content of a <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.
<p>The following word uses a <sup>superscript</sup> typeface.</p>
This will produce following result:
The following word uses a superscript typeface.
To Become more comfortable - Do Online Practice

Subscript Text - The <sub> Element:

The content of a <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.
<p>The following word uses a <sub>subscript</sub> typeface.</p>
This will produce following result:
The following word uses a subscript typeface.
To Become more comfortable - Do Online Practice

Larger Text - The <big> Element:

The content of the <big> element is displayed one font size larger than the rest of the text surrounding it.
<p>The following word uses a <big>big</big> typeface.</p>
This will produce following result:
The following word uses a big typeface.
To Become more comfortable - Do Online Practice

Smaller Text - The <small> Element:

The content of the <small> element is displayed one font size smaller than the rest of the text surrounding it.
<p>The following word uses a <small>small</small> typeface.</p>
This will produce following result:
The following word uses a small typeface.
To Become more comfortable - Do Online Practice

Grouping - The <div> and <span> Elements :

The <div> and <span> elements allow you to group together several elements to create sections or subsections of a page.
For example, you might want to put all of the footnotes on a page within a <div> element to indicate that all of the elements within that <div> element relate to the footnotes. You might then attach a style to this <div> element so that they appear using a special set of style rules.
The <div> element is used to group block-level elements together:
<div id="menu" align="middle" >
<a href="/index.htm">HOME</a> | 
<a href="/about/contact_us.htm">CONTACT</a> | 
<a href="/about/index.htm">ABOUT</a>
</div>

<div id="content" align="left" bgcolor="white">
<h5>Content Articles</h5>
<p>Actual content goes here.....</p>
</div>
This will produce following result:
Content Articles
Actual content goes here.....
The <span> element, on the other hand, can be used to group inline elements only. So, if you had a part of a sentence or paragraph you wanted to group together you could use the <span> element.
<div><p>This is the example of <span style="color:green">span tag</span> and the <span style="color:purple">div tag</span> alongwith CSS</p></div>
This will produce following result:
This is the example of span tag and the div tag alongwith CSS
These tags are commonly used with CSS to allow you to attach a style to a section of a page.
To Become more comfortable - Do Online Practice
For a complete list of HTML Tags and related attributes please check reference to HTML Tags Reference.