Thursday, April 12, 2012

HTML Beginner tutorial 11 HTML Images

The <img> Tag and the Src Attribute
In HTML, images are defined with the <img> tag. The <img> tag is empty, which means that it contains attributes only, and has no closing tag.
To display an image on a page, you need to use the src attribute. Src stands for "source". The value of the src attribute is the URL of the image you want to display.
Syntax for defining an image:

<img src="url" alt="text here"/>

The URL points to the location where the image is stored. An image named "boat.gif", located in the "images" directory on "www.yoursite.com" has the URL: http://www.yoursite.com/images/boat.gif.

The browser displays the image where the <img> tag occurs in the document. If you put an image tag between two paragraphs, the browser shows the first paragraph, then the image, and then the second paragraph.

The Alt Attribute
The required alt attribute specifies an alternate text for an image, if the image cannot be displayed. The value of the alt attribute is an author-defined text.

<img src="boat.gif" alt="Big Boat" />

The alt attribute provides alternative information for an image if a user for some reason cannot view it (because of slow connection, an error in the src attribute, or if the user uses a screen reader).

Set Height and Width of an Image
The height and width attributes are used to specify the height and width of an image. The attribute values are specified in pixels by default.

<img src="img.jpg" alt="rock" width="300" height="220" />

It is a good practice to specify both the height and width attributes for an image. If these attributes are set, the space required for the image is reserved when the page is loaded. However, without these attributes, the browser does not know the size of the image. The effect will be that the page layout will change during loading (while the images load).

Basic Notes
If an HTML file contains ten images - eleven files are required to display the page right. Loading images takes time, so my best advice is, Use images carefully.

When a web page is loaded, it is the browser, at that moment, that actually gets the image from a web server and inserts it into the page. Therefore, make sure that the images actually stay in the same spot in relation to the web page, otherwise your visitors will get a broken link icon. The broken link icon is shown if the browser cannot find the image.

HTML Beginner tutorial 12 : HTML Tables  >>
<<  HTML Beginner tutorial 10 : HTML Links

Wednesday, April 11, 2012

HTML Beginner tutorial 10 HTML Links

HTML Hyperlinks
A hyperlink is a word, group of words, or image that you can click on to jump to a new document or a new section within the current document.
When you move the cursor over a link in a Web page, the arrow will turn into a little hand. Links are specified in HTML using the <a> tag.
The <a> tag can be used in two ways:
  • To create a link to another document, by using the href attribute
  • To create a bookmark inside a document, by using the name attribute

HTML Link Syntax
The HTML code for a link is simple. It looks like this:

<a href="url">Some text here</a>

The href attribute specifies the destination of a link.
For example

<a href="http://webdesignpluscode.blogspot.com/">Visit Tutorials</a>

which will display like this: Visit Tutorials
Clicking on this hyperlink will send the user to Web design plus code's homepage.
The "Link text" doesn't have to be text. It can be an image or any other HTML element.

HTML Links - The target Attribute
The target attribute specifies where to open the linked document. The example below will open the linked document in a new browser window or a new tab.

<a href="http://www.w3schools.com/" target="_blank">Visit W3Schools!</a>

HTML Links - The name Attribute
The name attribute specifies the name of an anchor. The name attribute is used to create a bookmark inside an HTML document.
The upcoming HTML5 standard suggests using the id attribute instead of the name attribute for specifying the name of an anchor. Using the id attribute actually works also for HTML4 in all modern browsers.
Bookmarks are not displayed in any special way. They are invisible to the reader.
For example
A named anchor inside an HTML document:

<a name="tips">Useful Tips Section</a>

Create a link to the "Useful Tips Section" inside the same document:

<a href="#tips">Visit the Useful Tips Section</a>

Or, create a link to the "Useful Tips Section" from another page:

<a href="http://www.yoursite.com/html_links.htm#tips">Visit the Useful Tips Section</a>

Basic Notes
Always add a trailing slash to subfolder references. If you link like this: href="http://www.site.com/html", you will generate two requests to the server, the server will first add a slash to the address, and then create a new request like this: href="http://www.site.com/html/".
Named anchors are often used to create "table of contents" at the beginning of a large document. Each chapter within the document is given a named anchor, and links to each of these anchors are put at the top of the document.

HTML Beginner tutorial 11 : HTML Images  >>
<<  HTML Beginner tutorial 9 : HTML Styles

Tuesday, April 10, 2012

HTML Beginner tutorial 9 HTML Styles

Styling HTML with CSS
CSS is used to style HTML elements.
CSS was introduced together with HTML 4, to provide a better way to style HTML elements.
CSS can be added to HTML in the following ways:
  • in Cascading Style Sheet files (CSS files)
  • in the <style> element in the HTML head section
  • in the style attribute in single HTML elements

Using the HTML Style Attribute

It is time consuming and not very practical to style HTML elements using the style attribute.
The preferred way to add CSS to HTML, is to put CSS syntax in separate CSS files.
However, in this HTML tutorial we will introduce you to CSS using the style attribute. This is done to simplify the examples.

HTML Style  - Background Color

The background-color property defines the background color for an element:
For example

html style background color
html style background color.


The background-color property makes the "old" bgcolor attribute obsolete.


HTML Style - Font, Color and Size

The font-family, color, and font-size properties defines the font, color, and size of the text in an element:
For example

html style font color size
html style font color size.


The font-family, color, and font-size properties make the old <font> tag obsolete.


HTML Style - Text Alignment

The text-align property specifies the horizontal alignment of text in an element:
For example

html style text alignment
html style text alignment.


The text-align property makes the old <center> tag obsolete.


HTML Beginner tutorial 10 : HTML Links  >>

<<  HTML Beginner tutorial 8 : HTML Fonts

HTML Beginner tutorial 8 HTML Fonts

The HTML <font> Tag Should NOT be Used
The <font> tag is deprecated in HTML 4, and removed from HTML5.
The World Wide Web Consortium (W3C) has removed the <font> tag from its recommendations.
In HTML 4, style sheets (CSS) should be used to define the layout and display properties for many HTML elements.
The example below shows how the HTML could look by using the <font> tag:

html fonts
html fonts.


The Right Way to Do It, is using Styles. Which 'll be discuss in next tutorials.

HTML Beginner tutorial 9 : HTML Styles  >>
<<  HTML Beginner tutorial 7 : HTML Text Formatting

HTML Beginner tutorial 7 HTML Text Formatting

HTML Formatting Tags

html formatting tags
html formatting tags.


HTML uses tags like <b> and <i> for formatting output, like bold or italic text.
These HTML tags are called formatting tags.
Often <strong> renders as <b>, and <em> renders as <i>.
However, there is a difference in the meaning of these tags:
<b> or <i> defines bold or italic text only.
<strong> or <em> means that you want the text to be rendered in a way that the user understands as "important".
Today, all major browsers render strong as bold and em as italics. However, if a browser one day wants to make a text highlighted with the strong feature, it might be cursive for example and not bold!

HTML Text Formatting Tags


<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

HTML "Computer Output" Tags



<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

HTML Citations, Quotations, and Definition Tags


<abbr>            Defines an abbreviation

<acronym>       Defines an acronym
<address>    Defines contact information for the author/owner of a document
<bdo>            Defines the text direction
<blockquote>    Defines a long quotation
<q>                    Defines a short quotation
<cite>            Defines a citation
<dfn>            Defines a definition term

HTML Beginner tutorial 8 : HTML Fonts  >>

<<  HTML Beginner tutorial 6 : HTML Paragraphs