Saturday, 8 December 2012
Saturday, 8 December 2012 by Unknown
html
Immediately after the doctype comes the
html
element—this is the root element of the document tree and everything that follows is a descendant of that root element.
If the root element exists within the context of a document that’s identified by its doctype as XHTML, then the
html
element also requires an xmlns
(XML Namespace) attribute (this isn’t needed for HTML documents):<html xmlns="http://www.w3.org/1999/xhtml">
Here’s an example of an XHTML transitional page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Page title</title>
</head>
<body>
</body>
</html>
head
The
head
element contains meta data—information that describes the document itself, or associates it with related resources, such as scripts and style sheets.
The simple example below contains the compulsory
title
element, which represents the document’s title or name—essentially, it identifies what this document is. The content inside the title
may be used to provide a heading that appears in the browser’s title bar, and when the user saves the page as a favorite. It’s also a very important piece of information in terms of providing a meaningful summary of the page for the search engines, which display the title
content in the search results. Here’s the title
in action:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Page title</title> </head> <body> </body> </html>
In addition to the
title
element, the head
may also contain:- basedefines base URLs for links or resources on the page, and target windows in which to open linked content
- linkrefers to a resource of some kind, most often to a style sheet that provides instructions about how to style the various elements on the web page
- metaprovides additional information about the page; for example, which character encoding the page uses, a summary of the page’s content, instructions to search engines about whether or not to index content, and so on
object
represents a generic, multipurpose container for a media object- scriptused either to embed or refer to an external script
style
provides an area for defining embedded (page-specific) CSS styles
All of these elements are optional and can appear in any order within the
head
. Note that none of the elements listed here actually appear on the rendered page, but they are used to affect the content on the page, all of which is defined inside the body
element.
body
This is where the bulk of the page is contained. Everything that you can see in the browser window (or viewport) is contained inside this element, including paragraphs, lists, links, images, tables, and more. The
body
element has some unique attributes of its own, all of which are now deprecated, but aside from that, there’s little to say about this element. How the page looks will depend entirely upon the content that you decide to fill it with; refer to the alphabetical listing of all HTML elements to ascertain what these contents might be.
Subscribe to:
Post Comments (Atom)
0 Responses to “ ”
Post a Comment