Are you

HTML Elements

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>
<title>this is my title </title>

<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="">This is a link </a>


HTML Attributes

  • HTML attributes are special words that provide more information about elements or attributes are the HTML element's modifier.
  • Each element or tag can have attributes that define how that element behaves.
  • Attributes all the times are applied to the tags.
  • The Attribute should always be applied with name of the attribute and value attribute. example: name="value"
  • The name and values of the attributes are case sensitive, and W3C recommends that they be written in lowercase only.
  • Multiple attributes can be added to a single HTML element, but there must be a space between them.


<element attribute_name="value">content</element>

The href Attribute

The<a> tag defines a hyperlink. The href attribute specifies the URL of the page the link goes to:
<a href="">This is a link </a>

The src Attribute

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="".

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 alt Attribute

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.