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.