Quantcast
Channel: pguides.net » html
Viewing all articles
Browse latest Browse all 10

HTML Elements

$
0
0

Elements


An HTML document is really a tree of HTML elements which denote various semantic pieces of the document.

Element Structure

An HTML element begins with a start tag and may also have an end tag, content and attributes. [Tags][html/tags-and-attributes] are surrounded with angle brackets: <tag>.

One of the simplest elements is the br element which denotes a line break. This element consists of only a single tag and has no closing tag, content or attributes. It is written as follows:

1
<br />

A more typical element is the p element which denotes a paragraph. It consists of an open tag (<p>), a closing tag (</p>) and content:

1
<p>Here is the content.</p>

As we said earlier, elements may have some associated attributes. One of the most common cases where an attribute is used is the a element. Let’s have a look at an a element with an href attribute and value:

1
<a href="http://pguides.net">home page</a>

The above element has the attribute href which has the value http://pguides.net.

More information about attributes can be found in the [tags and attributes chapter][html/tags-and-attributes].

Most HTML elements may contain other HTML elements part of their content.

1
2
3
4
5
<html>
<body>
<p>This is my first paragraph</p>
</body>
</html>
  • The body element is a child of the html element
  • The p element is a child of the body element

Viewing all articles
Browse latest Browse all 10

Trending Articles