HTML Elements
What is an HTML element?
- An HTML element is composed of an opening tag, followed by content, and a closing tag.
- <tagname>Some content here..</tagname>
- HTML opening and closing tags are formed with the tag name enclosed with less than and greater than symbols, with an extra slash “/” before the tag name of a closing tag.
- Empty HTML elements don’t need a closing tag, as they don’t contain any content.
- <br>, <hr>
- HTML elements are not case sensitive, but make sure to use the same case in both opening and closing tags, and W3C recommends using lowercase tags
- <p>content</p>
- <P>content</P>
- Never skip a closing tag on the elements that contain content
- though browsers display their content correctly, as it may sometimes cause unexpected results and errors.
- Each element has a specific meaning
<tagname attrname=”attr-value”>Some content here</tagname>
Basic HTML Elements
Some of the basic HTML elements are included below to understand the basic syntax.
<h1>Heading</h1>
<p>Paragraph text goes here..</p>
<a href="https://randomcodez.com">link</a>
<img src="random.png" alt="brand" width="200" height="300">
<hr>
<br>
Examples
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<h1>HTML Elements</h1>
<p>Paragraph text goes here..</p>
<a href="https://randomcodez.com">link</a>
<img src="random.png" alt="brand" width="200" height="300">
</body>
</html>
Overall
HTML elements are the building blocks using which content can be added to an HTML document.