HTML is a simple (Hyper-Text) Markup Language used to describe the structure of user interfaces on the web.
An HTML page is made up of elements, defined with a start tag and an end tag:
<tag>content goes here</tag>
HTML elements can also contain additional information in the form of attributes, defined inside the start tag:
<tag type="a"> content goes here </tag>
<tag type="b"> content goes here </tag>
class
and id
are common attributes used to distinguish between similar elements.
The browser reads these HTML elements and renders them accordingly. Lets explore a few widely used elements:
These tags are used to show a heading on the page. For example:
<h4>Heading Size 4</h4>
<h5>Heading Size 5</h5>
<h1>
has the biggest font-size, <h6>
the smallest.
This is essentially a block element used for structuring content. Lets say we want to display a blog post which has four sections - date, title, content, author. We will create a structure like this:
<div class="blog-post">
<div class="blog-date">19th Jan, 2017</div>
<div class="blog-title">How to build a web app</div>
<div class="blog-content">...</div>
<div class="blog-author">....</div>
</div>
Structure is fine, but how does one navigate from one web page to another? With the use of anchor tags:
<a href="/register">Register your own app today</a>
href
is the attribute used to define the exact url of the page you wish to send the user to.
<a href="http://www.heroku.com" target="_blank">Host your own app on Heroku</a>
The target="_blank"
attribute allows us to tell the browser to open the link in a new tab.
What would the web without visual content, and its most important component - images. You can add images to your web page like this:
<img src="http://wallpapers.com/amazon-rainforest.jgp" height="400" width="300" />
yes you can end a tag like that ;)
src
attribute defines the url of the image that needs to be loaded.
width
and height
defines the space to be occupied by the image in pixels.
The video tag is more or less like the image tag, except with the option to add multiple sources of content, and other dynamic attributes like autoplay
and controls
.
<video width="320" height="240" controls autoplay>
<source src="movie.mp4" type="video/mp4">
<source src="movie.ogg" type="video/ogg">
</video>