| | | |
|---|
Comments, Questions, Suggestions, or Opinions Tutorials Lesson:
Exercises For every lesson:
My accounts:
|
HTML documents are defined by HTML elements. HTML ElementsAn HTML element is everything from the start tag to the end tag:
* The start tag is often called the opening tag. The end tag is often called the closing tag. HTML Element Syntax
Tip: You will learn about attributes in the next chapter of this tutorial. Nested HTML ElementsMost HTML elements can be nested (can contain other HTML elements). HTML documents consist of nested HTML elements. ![]() HTML Document Example
<!DOCTYPE html> <html> <body> <p>This is my first paragraph.</p> </body> </html> The example above contains 3 HTML elements. HTML Example ExplainedThe <p> element:
<p>This is my first paragraph.</p> The <p> element defines a paragraph in the HTML document. The <body> element:
<body> <p>This is my first paragraph.</p> </body> The <body> element defines the body of the HTML document. The <html> element:
<html> <body> <p>This is my first paragraph.</p> </body> </html> The <html> element defines the whole HTML document. Don't Forget the End TagSome HTML elements might display correctly even if you forget the end tag:
<p>This is a paragraph <p>This is a paragraph The example above works in most browsers, because the closing tag is considered optional. Never rely on this. Many HTML elements will produce unexpected results and/or errors if you forget the end tag . Empty HTML ElementsHTML elements with no content are called empty elements. <br> is an empty element without a closing tag (the <br> tag defines a line break). Tip: In XHTML, all elements must be closed. Adding a slash inside the start tag, like <br />, is the proper way of closing empty elements in XHTML (and XML). HTML Tip: Use Lowercase TagsHTML tags are not case sensitive: <P> means the same as <p>. Many web sites use uppercase HTML tags. W3Schools use lowercase tags because the World Wide Web Consortium (W3C) recommends lowercase in HTML 4, and demands lowercase tags in XHTML. Attributes provide additional information about HTML elements. HTML Attributes
Attribute ExampleHTML links are defined with the <a> tag. The link address is specified in the href attribute: Always Quote Attribute ValuesAttribute values should always be enclosed in quotes. Double style quotes are the most common, but single style quotes are also allowed.
HTML Tip: Use Lowercase AttributesAttribute names and attribute values are case-insensitive. However, the World Wide Web Consortium (W3C) recommends lowercase attributes/attribute values in their HTML 4 recommendation. Newer versions of (X)HTML will demand lowercase attributes. HTML Attributes ReferenceA complete list of legal attributes for each HTML element is listed in our: HTML Tag Reference. Below is a list of some attributes that can be used on any HTML element:
For more information about global attributes: HTML Global Attributes Reference.
Click here to take the exercises of this lesson -->
|