HTML Element Syntax
Nested Elements
<html>
<body>
<p>This is my first paragraph</p>
</body>
</html>
The <p> Element
1.The <p> element defines a new paragraph in the HTML document
2.The element has a start tag <p> and an end tag</p>
3.The element content is : This is my first paragraph
The <body> Element
1.The Element has a Start tag <body> and an end tag</body>
2.The element content is another HTML element ( one or more paragraphs).
There are usally dozens of elements within the body
The <html> Element
1.The element has a start tag <html> and an end tag </html>
2.The element content is another HTML element (the body)
Don't Forget the End Tag
<p>This is a paragraph
<p>This is another paragraph
The previous example will work in most browsers, but don't rely on it.
Forgetting the end tag can produce unexpected results or errors.
Empty HTML Elements
HTML elements without content are called empty elements.
<br> is an empty element without a closing tag. It defines a line break.
Adding a slash to the end of start tag, like <br/>, is the proper way of closing empty elements, accepted by HTML and XML.
- HTML element starts with a start tag/opening tag.
- HTML element ends with an end tag/closing tag.
- The Element content is everything between the start and the end tag.
- Some HTML elements have empty content.
- Empty elements are closed in the start tag.
- Most HTML elements can have attributes.
Nested Elements
<html>
<body>
<p>This is my first paragraph</p>
</body>
</html>
The <p> Element
1.The <p> element defines a new paragraph in the HTML document
2.The element has a start tag <p> and an end tag</p>
3.The element content is : This is my first paragraph
The <body> Element
1.The Element has a Start tag <body> and an end tag</body>
2.The element content is another HTML element ( one or more paragraphs).
There are usally dozens of elements within the body
The <html> Element
1.The element has a start tag <html> and an end tag </html>
2.The element content is another HTML element (the body)
Don't Forget the End Tag
<p>This is a paragraph
<p>This is another paragraph
The previous example will work in most browsers, but don't rely on it.
Forgetting the end tag can produce unexpected results or errors.
Empty HTML Elements
HTML elements without content are called empty elements.
<br> is an empty element without a closing tag. It defines a line break.
Adding a slash to the end of start tag, like <br/>, is the proper way of closing empty elements, accepted by HTML and XML.
No comments:
Post a Comment