Elements

Open up your text editor and type this into a new file:

<h1>Hello!</h1>

Save your file and open it in your browser.

Ta da! You're a website developer!

The Basics

The code you wrote consisted of one HTML element. An element consists of:

  • An opening tag, in this case <h1>
  • Content, in this case Hello!
  • A closing tag, </h1>

The element is identified by its opening tag. We would say that we wrote an "h1 element".

Attributes

Elements can also contain attributes. Some elements require the presence of certain attributes in order to function. For example, let's add a link to Google:

<a href="https://www.google.com">Search</a>

Save the file and refresh your browser. You should now have a link that you can click to go to Google's home page.

The href attribute above is how the browser knew what to do when the content Search was clicked.

Attributes have a name and a value, always separated by an = sign, and the value is always enclosed in quotation marks.

In the above example,

  • The attribute name is href
  • The attribute value is https://www.google.com