2 HTML Elements and Tags
2 HTML Elements and Tags
ELEMENTS
AND TAGS
Requirement in creating Webpage with HTML:
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
HTML IMAGES
HTML Images
• HTML images are defined with the <img> tag.
• The source file (src), alternative text (alt), width, and height are
provided as attributes:
Start tag
Value Content End tag
Attribute
HTML ELEMENT
• is defined by a start tag, some content and end tag:
<tagname>Content goes here…</tagname>
• The HTML element is everything from the start tag to the end tag:
• <h1>My First Heading</h1>
• <p>My First Paragraph</p>
Start tag Element content End tag
Note: Some HTML elements have no content (like the <br> element). This
elements are called empty elements. Empty elements do not have an end
tag.
Nested HTML Elements
• HTML elements can be nested (this means that
elements can contain other elements).
• All HTML documents consist of nested HTML
elements.
• The following example contains four HTML
elements
• (<html>, <body>, <h1> and <p>):
Example
<!DOCTYPE html>
<html>
<body>
</body>
</html>
Example Explained
•• The <html> element is the root element and it defines the
whole HTML document.
•• It has a start tag <html> and an end tag </html>.
•• Then, inside the <html> element there is a <body> element:
<body>
</body>
• The <body> element defines the document's body.
• It has a start tag <body> and an end tag </body>.
• Then, inside the <body> element there is two other elements: <h1>
and <p>:
<html>
<body>
<p>This is a paragraph
<p>This is a paragraph
</body>
</html>
Empty HTML Elements
• HTML elements with no content are called empty elements.
• The <br> tag defines a line break, and is an empty element without
a closing tag:
Example
<p>This is a <br> paragraph with a line break.</p>
HTML is Not Case Sensitive
https://www.youtube.com/watch?v=hM0VQKLNgkQ
OUTPUT
ACTIVITY
• For those who have laptop or Desktop:
1.Choose your favorite song.
2.Encode the lyrics in your notepad.
3.Add image of the artist or the album
4.Use the different tags and attributes that were discussed.
5.Submit the screenshot of your syntax and web output in our MS Teams.