An HTML file is made of elements. These elements are responsible for creating web pages and define content in that webpage.
An element in HTML usually consist of a start tag <tag name>
, close tag </tag name>
and content inserted between them.
Technically, an element is a collection of start tag, attributes, end tag, content between them.
To put it more simply, HTML element is everything from the start tag to the end tag:
Example<tag name>
Content goes here...</tag name>
Start tag | Element content | End tag |
---|---|---|
<h1> | My First Heading | </h1> |
<p> | My first paragraph. | </p> |
<br> | none | none |
<!DOCTYPE html>
<html>
<head>
<title>
this is my title </title>
</head>
<body>
<h1>
This is heading 1 </h1>
<h2>
This is heading 2 </h2>
<h3>
This is heading 3 </h3>
<h4>
This is heading 4 </h4>
<h5>
This is heading 5 </h5>
<h6>
This is heading 6 </h6>
<p>
This is paragraph 1 </p>
<p>
This is paragraph 2 </p>
<a href="https://www.softechsupply.com">
This is a link </a>
</body>
</html>
<element attribute_name="value">
content</element>
<a>
tag defines a hyperlink. The href
attribute specifies the URL of the page the link goes to:<a href="https://www.softechsupply.com">
This is a link </a>
The <img>
tag is used to embed an image in an HTML page. The src
attribute specifies the path to the image to be displayed:
<img src="img_girl.jpg">
There are two ways to specify the URL in the src
attribute:
1. Absolute URL - Links to an external image that is hosted on another website. Example: src="https://www.w3schools.com/images/img_girl.jpg".
Notes. External images might be under copyright. If you do not get permission to use it, you may be in violation of copyright laws. In addition, you cannot control external images; it can suddenly be removed or changed.
2. Relative URL - Links to an image that is hosted within the website. Here, the URL does not include the domain name. If the URL begins without a slash, it will be relative to the current page. Example: src="img_girl.jpg". If the URL begins with a slash, it will be relative to the domain. Example: src="/images/img_girl.jpg".
Tip: It is almost always best to use relative URLs. They will not break if you change domain.
The required alt
attribute for the <img>
tag display an alternate text for an image, if the image for some reason cannot be displayed. This can be due to slow connection, or an error in the img
attribute, or if the user uses a screen reader.
<img src="img_girl.jpg" alt="Girl with a jacket">
Now is the time to learn CSS, as you've already studied the fundamentals of HTML, which we'll need in the future.
NextTotal: $0.00