![]() |
|
![]() |
||
![]() |
![]() |
|
HTML ElementsAn HTML element (also known as HTML tags) are the fundamental building blocks of all Web pages think of them as labels that tell the Web browser information about a document's structure and layout. For example, an HTML element might say: "This is a title", or "this is a heading", or "This is a paragraph", etc. This section covers the basic rules for constructing and using HTML elements. HTML Element SyntaxIn order to be understood by a Web browser, HTML elements must adhere to some basic syntax rules. All elements start with an opening tag (or start tag) and end with a closing tag (or end tag), for example, the <title> element, a common HTML element is shown here: Code Sample:
Note that the only difference between an element's opening tag and its' closing tag is the leading slash character (i.e. the "/"). An HTML element may contain text and/or other nested elements, or they can be empty. An empty element looks like an abbreviated combination of both an opening and closing tag, for example, the HTML <img> tag, used to display images on a Web page, as shown here: Code Sample:
HTML Element Syntax Tip
In HTML, the closing tag is optional and the element name is not case sensitive, where as in XHTML,
the closing tag is required, and the element name is case sensitive.
Empty elements like the <img> tag for displaying images do not surround any body content. Rather, they consist of a single tag which acts as both an opening and closing html element. Think of an empty HTML element as a placeholder for something atomic, like an image, a line break, etc. Parent and Child ElementsIf an element contains other elements, it is considered to be the parent of the enclosed child element(s). Any elements contained in the child element are considered to be the descendants of the outer, parent element, as shown here: Code Sample:
A Webpage can therefore be thought of as structured hierarchical relationships of elements flowing throughout a document. When elements contain child elements, each element must be properly nested, i.e., they must be fully enclosed by its parent. Whenever you use a closing tag, it should correspond to the last unclosed, opening tag. In other words, first open A then open B, then close B, and then close A. HTML Elements: SummaryIn this HTML element tutorial, you learned:
|
|
||||||||||||||||||||||||||||