Thursday, January 6, 2011

The img Element

The img element is used to insert an image into an (X)HTML page. It is an inline replaced element. It is an empty element. The URI of the image is defined by the src attribute. Any image format that the browser supports can be used. Common formats are JPEG, PNG and GIF.

The src and alt attributes are required.

Attributes

Core Attributes
The core attributes can be applied to this element.
align
This is a deprecated attribute. It specifies the alignment of the image. Its value can be bottom, or left, or middle, or right, or top. Since this a presentational attribute, it is preferable to use CSS instead.
bottom
Aligns the image to the baseline
middle
Aligns the vertical middle of the image to the baseline
top
Aligns the top of the image to the top of the line box.
left
Aligns the image to left edge of the line box
right
Aligns the image to the right edge of the line box
alt
This is a required attribute. The value of this attribute is a short description of the image. It is displayed when the image cannot be loaded. It may also be used by non-visual browsers.
border
This is a deprecated attribute. Its value is a number that specifies the width of the border in pixels that surrounds the image. Since this is a presentational attribute, it is preferable to use the CSS border property instead.
height
This attribute specifies the height of the image. Using this attribute may speed up the rendering of the page because the browser can allocate space for the image before it is fully loaded. Since this is a presentational attribute, it is preferable to use the CSS height property instead.
hspace
This is a deprecated attribute. Its value is a number that specifies the width in pixels of the right and left margins of the image. Since this is a presentational attribute, it is preferable to use the CSS margin property instead.
ismap
This attribute takes only one value and is specified as follows: ismap="ismap". It indicates that the image is part of an server-side image map.
longdesc
The value of this attribute is a URL to a document that has a description of the image. This will help those who are browsing the document non-visually. However, visual browsers such as Firefox, Internet Explorer, etc. do not provide any method to view the document specified in longdesc.
name
This attribute is deprecated in XHTML. It is better to use the id or class attribute in both HTML and (X)HTML documents.
src
This is a required attribute. Its value is the URI of the image that is to be embedded.
usemap
This attribute is used to specify the map element that contains the client-side image map information of the iamge. The value of this attribute is the name (in case of HTML) or the id (in case of XHTML), prefixed with a hash (#) of the map element.
vspace
This is a deprecated attribute. Its value is a number that specifies the width in pixels of the top and bottom margins of the image. Since this is a presentational attribute, it is preferable to use the CSS margin property instead.
width
This attribute specifies the width of the image. Using this attribute may speed up the rendering of the page because the browser can allocate space for the image before it is fully loaded. Since this is a presentational attribute, it is preferable to use the CSS width property instead.

Inline Frames

Inline Frames, specified by the iframe element allow one to display files within an (X)HTML document. The inserted file can be another (X)HTML document or an image or text file etc. The inserted file, specified by the src attribute, is displayed in a rectangular frame.

iframe is an inline replaced element. It is also a flow element, therefore it can have block or inline child elements. The child elements and/or text content of the Inline Frame are displayed by browsers that do not support Inline Frames.

Only the transitional doctypes allow Inline Frames.

Attributes

Core Attributes
The core attributes can be applied to this element.
align
This is a deprecated attribute. It specifies the alignment of the Inline Frame within its parent element. It can have a value of top, or middle, or bottom, or left, or right. Since it is a presentational attribute, CSS should be used instead.
frameborder
This attribute can have a value of 1 or 0 which specifies if there should be a border around the frame or not. Since this is a presentational attribute, it is preferable to use the CSS border property instead.
height and width
This attribute can have a number or a percentage value. Number values specify the height (or width) of the Inline Frame in pixels and percentage values refer to the height (or width) of the parent element. Since this is a presentational attribute, it is preferable to use the CSS height or width property instead.
longdesc
The value of this attribute is a URL to a document that has a description of the content of the Inline Frame. This will help those who are browsing the frameset document non-visually. However, visual browsers such as Firefox, Internet Explorer, etc. do not provide any method to view the document specified in longdesc.
Example: <iframe src="fr.html" longdesc="frdesc.html">
marginheight
The value of this attribute, a number, specifies the top and bottom margins between the displayed contents of the source file of the Inline Frame and its inner edge.
marginwidth
The value of this attribute, a number, specifies the left and right margins between the displayed contents of the source file of the Inline Frame and its inner edge.
name
This attribute assigns a name to the Inline Frame so that it can be targetted by links having the target attribute.
scrolling
This attribute can take one of these values: yes,no or auto. With yes, scrollbars are always show whether they are needed or not. With no, scrollbars are never shown. With auto, scrollbars are shown when needed, this is the default.
src
The value of this attribute is a URL that specifies the initial file that will be displayed in the frame. The src attribute can refer to any file, even to another frameset document.

The i Element

This element causes its text content to be displayed in italics. It is an inline element. It is a non-semantic, purely presentational element, therefore its use is discouraged. When italics are needed for emphasis, the em or strong element should be used with the presentation handled by CSS.

Attributes

Core Attributes
The core attributes can be applied to this element.

The html Element

The html element is topmost in the hierarchy of (X)HTML elements and is known as the root element. Therefore all (X)HTML elements are descendants of the html element. The html element appears after the Document Type Declaration.

The head and the body elements, and, in the case of a Frameset document, the frameset element are the only child elements of html.

Example: <html lang="en">

Attributes

lang and xml:lang
These attributes specifiy the language of the contents of the document. See this page for more information.
dir
See this page.
id
This attribute is used to uniquely name the html element. It is allowed on the html element only when the doctype is XHTML.
version
This is a deprecated attribute. Its value is the Formal Public Identifier of the HTML Document Type Definition (DTD) of the document. This attribute should not be used because the DTD of the document is specified in the doctype.
xmlns
This is a required attribute in XHTML documents. It specifies the XML namespace of the document.

The hr Element

The hr element creates a horizontal rule. It is a block element. It is an empty element, that is, it cannot contain any other element or text. This is a presentational (X)HTML element. Therefore, it is preferable to use CSS borders to create horizontal rules instead of using the hr element.

Attributes

Core Attributes
The core attributes can be applied to this element.
align
This is a deprecated attribute. It can take the value center or left or right. This attribute is used to align the horizontal rule when its length is less than the content area of its parent element. Since it is a presentational attribute, CSS should be used instead.
noshade
This is a deprecated attribute. This attribute is specified as noshade="noshade". It displays the rule with one solid color, instead of the default 3D shade.
size
This is a deprecated attribute. Its value, a number, specifies the height (thickness) of the rule.
width
This is a deprecated attribute. Its value is a number or a percentage. If the value is a number, it specifies the width (length) of the rule in pixels. If the value is a percentage, it calculates the the width (length) of the rule as a percentage of the width of the parent element.

Wednesday, January 5, 2011

The head Element

The head element contains information that describes the (X)HTML document. This information is not considered part of the content of an (X)HTML page and is therefore not displayed in the viewport.

The head element must contain one title element.

These are the elements that head can contain:

  • title
  • base
  • meta
  • script
  • link
  • style
  • object

There can be only one title and base element. However, the other elements can be present multiple times.

Attributes

lang and xml:lang
These attributes specifiy the language of the contents of the head element. However, this attribute is more often specified for the html element. See this page for more information.
dir
See this page.
id
This attribute is used to uniquely name the head element. It is allowed on the head element only when the doctype is XHTML.
profile
The value of this attribute is the URI of a document that provides more information of the meta element's content attribute.

Here is the W3.org's HTML 4 specification page for the head element.

Tuesday, January 4, 2011

The h1, h2, h3, h4, h5 and h6 Elements

The h1, h2, h3, h4, h5 and h6 elements are used on headings. A heading is a short description of the document section it is in. Since a document can have many headings and sub-headings, HTML provides six elements from h1 to h6. h1 is at the top most of the hierarchy and h6 is at the lowest.

These are block elements that can only have inline elements as their child elements.

Since the various heading elements are used to indicate a hierarchy of headings and content, it doesn't make sense to skip levels. For example, after an h1 element, the next heading element should be h2 not any other heading element like h3.

An heading element can contain an image if the image's content describes the content of the document section.

Attributes
Core Attributes
The core attributes can be applied to this element.
align
This is a deprecated attribute. It can take as values either center, left, and right. The CSS property text-align should be used instead of this property.

Monday, January 3, 2011

The frameset, frame, and noframes Elements

With HTML frames one can display multiple HTML documents at once. Each HTML document is displayed in a frame. A frame is created using the frame element and usually occupies only a part of the viewport. The frame elements are contained within a frameset document. A frameset document specifies the dimensions and layout of the frames. A frameset document uses a frameset doctype:

HTML 4.01 Frameset Document Type Definition
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
XHTML 1.0 Frameset Document Type Definition
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

Instead of the body element, a frameset document contains the frameset element. This frameset element can contain the frame element, the noframes element or even more frameset elements.

The frameset Element

This element is the container for the frame elements of a frames document. In a framset document, it takes the place of the body element. Frameset elements can be nested within each other. Therefore, a frameset can contain both frame elements and frameset elements.

Example 1: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>A Frames Document</title> </head> <frameset rows="100,*"> <frame src="logo.html"> <frameset cols="200px,*"> <frame src="nav.html"> <frame src="content.html"> </frameset> </frameset> </html>

Attrbutes
Core Attributes
The core attributes can be applied to this element.
cols

The value of this attribute is a comma-separated list of numbers, and/or percentages, and/or relative lengths. This attribute specifies the number of columns and their widths.

Number values
Number values specify the widths of the columns in pixels. Example: <frameset cols="200,400,200">
Percentage Values
These specify the width of the columns as a percentage of the width of the viewport. Example: <frameset cols="20%,70%,10%">
Relative Length Values
An asterisk (*) specifies that the column should use all the available space.
Example: <frameset cols="100px,70%,*">
Asterisks that are prefixed with numbers are used to specify ratios.
Example: <frameset cols="2*,7*,*">
In the above example, the ratio of the widths of the three columns are 2:7:1.
Relative length values are useful when used together with number values, because they allow one to relatively divide the space remaining after allocating a fixed number of pixels.
Example: <frameset cols="200,5*,2*">
rows
This takes the same values as cols, but specifies the height of rows.
Example: <frameset rows="200,400,200">
The rows and cols attributes can be used together to specify both rows and columns in a frameset.
Example: <frameset cols="100,200" rows="50%,50%">
border
This is a nonstandard attribute. Its value is a number. This number is the pixel width of the frame borders. A value of zero removes the frame borders.
bordercolor
This is a nonstandard attribute. The value of this attribute is a color name or a hexadecimal notation color value. Opera does not support this attribute.
frameborder

This is a nonstandard attribute. However, this attribute is standard on the frame element. Therefore, it is preferable not to use this attribute on the frameset element.

The value of this attribute can be 1 or yes to display the borders, or 0 or no to hide the borders. Opera does not support this attribute.

The frame Element

The frame element is used to specify the initial source file of a frame in a frameset. This is an empty element. Apart from the initial file, the attributes of this element specify the presentation, behavior and semantics of the frame.

Attrbutes
Core Attributes
The core attributes can be applied to this element.
src
The value of this attribute is a URL that specifies the initial file that will be displayed in the frame. The src attribute can refer to any file, even to another frameset document.
Example: <frame src="../folder/file.html">
bordercolor
This is a nonstandard attribute. This attribute specifies the color of the frames borders. The bordercolor specified on the frame element overrides the color specified by bordercolor on the parent frameset element.
frameborder
This is a nonstandard attribute. The value of this attribute can be 1 or yes to display the borders, or 0 or no to hide the borders. Opera does not support this attribute. The value of this attribute on the frame element does not override the value specified on the frameset element.
longdesc
The value of this attribute is a URL to a document that has a description of the content of the frame. This will help those who are browsing the frameset document non-visually. However, visual browsers such as Firefox, Internet Explorer, etc. do not provide any method to view the document specified in longdesc.
Example: <frame src="fr.html" longdesc="frdesc.html">
marginheight
This specifies the top and bottom margin between the inside edge of a frame and its contents. It is a number value, which specifies the margin in pixels. The value has to be a positive number and greater than zero.
marginwidth
This specifies the left and right margin between the inside edge of a frame and its contents. It is a number value, which specifies the margin in pixels. The value has to be a positive number and greater than zero.
name
This attribute is used to name a frame. It allows links in one frame to load documents into another using the target attribute on a elements.
noresize
This attribute can have only one value, like this: noresize="noresize". When this attribute is present, it prevents the user from resizing the frame. Note that in a three-column or three-row layout, setting noresize="noresize" on the middle column or row prevents resizing of all the columns or rows.
scrolling
This attribute can take one of these values: yes,no or auto. With yes, scrollbars are always show whether they are needed or not. With no, scrollbars are never shown. With auto, scrollbars are shown when needed, this is the default.

The noframes Element

This is a block element whose contents are displayed only in browsers that do not support frames or have frames disabled. This element usually appears as the last child of frameset. noframes is a flow element and can therefore contain both block and inline elements.

In an XHTML frameset document, this element must contain the body element. In an HTML frameset document, body is an optional child element.

Nesting Framesets

Frames can be nested in each other. There are two ways of doing this:

Putting a frameset document in a frame
A frameset document can be specified in the src attribute of the frame tag.
The image above shows how a nested-frame webpage looks.
There is one major disadvantage to this method: The nested frameset is independent of the parent frameset. Therefore, the nested frames cannot be targeted by links in the parent frameset frames.
Nesting frameset Elements
<frameset cols="18%,64%,18%"> <frame src="mefra1.html" name="navigation" noresize="noresize" /> <frameset rows="18%,64%,18%"> <frame src="header.html" /> <frame src="all_tags.html" name="content" scrolling="yes" /> <frame src="footer.html" /> </frameset> <frame src="mefra3.html" name="copyright" title="copyright" /> </frameset>
There is no difference in the appearance of the nested frameset document using either of the two methods. The difference is all frames - nested and otherwise - can be targeted by links anywhere in the document. Therefore, this method is superior to the first method.

Problems with frames

Bookmarking
When browsing a frameset, the URL in the address bar never changes. This is because new web pages load within the frames of the frameset. Therefore, if you click a link in any of the frames of a website and then bookmark it, you bookmark only the URL of the frameset (the URL displayed in the address bar). You cannot return to the page you were looking at using the bookmark.
Linking
With plain HTML and CSS, it is not possible for a link to load a frameset along with specific pages in its frames. A link can load a frameset, which will always load its default pages into its frames. Search engine users who arrive at a page on a website using frames will only see a single page of a frame, not the frames page within its frameset.
Latency
Framesets are slow to load because many files have to be downloaded to fill up one screen. Each HTML file requires an HTTP request to be sent, this makes framesets much slower than ordinary web pages.