Module 2
Module 2
HTML stands for HyperText Markup Language. It was developed by Tim Berners-Lee in
1991. HTML is the standard markup language used for creating web pages. It describes the
structure of a web page and consists of a series of elements.
HTML is not a programming language; it is a mark-up language that tells web browsers
how to display content.
It organizes content into parts like headings, paragraphs, images, links, and more.
HTML Elements
An HTML Element consists of a start tag, content, and an end tag, which
together define the element’s structure and functionality.
HTML Elements are the basic building blocks of a webpage and can represent
different types of content, such as text, links, images, or headings.
Syntax
<tagname>Content goes here...</tagname>
Examples of some HTML elements:
Paragraph Tag
The <p> tag offers a way to structure your text into different paragraphs. Each paragraph of text
should go in between an opening <p> and a closing </p> tag.
Center Tag
The <center> tag aligns text, images, or other HTML elements in the middle of a web page.
<center> <p>This text is in the center.</p> </center>
<p>This is paragraph one and should be on top</p> <hr /> <p>This is paragraph two and should
be at bottom</p>
HTML Text Formatting tags
HTML text formatting refers to the use of specific HTML tags to modify the appearance
and structure of text on a webpage. It allows you to style text in different ways.
<img src="img_flower.jpg">
The <img> tag should also contain the width and height attributes, which specify the width and
height of the image (in pixels):
The required alt attribute for the <img> tag specifies an alternate text for an image, if the image
for some reason cannot be displayed. This can be due to a slow connection, or an error in
the src attribute, or if the user uses a screen reader.
The style attribute is used to add styles to an element, such as color, font, size, and more.
<!DOCTYPE html>
<html lang="en">
<body>
...
</body>
</html>
Creating hyperlinks
HTML Links
A hyperlink is a specific type of link that allows users to navigate from one web page or resource
to another by clicking on it. You can create hyperlinks using text or images available on a
webpage. A hyperlink is created using the HTML Anchor Tag (</a>).
An anchor tag, or <a> tag, is a basic element that creates hyperlinks between two pages.
The HTML <a> tag defines a hyperlink. It has the following syntax:
<a href="url">link text</a>
The most important attribute of the <a> element is the href attribute, which indicates the link's
destination.
The link text is the part that will be visible to the reader.
Clicking on the link text, will send the reader to the specified URL address.
<a href="https://www.youtube.com/">Visit youtube.com!</a>
HTML - Images
HTML images provide visual content for web pages, enhancing user experiences and conveying
information. They can be photographs, graphics, icons, or illustrations.
Note: The <img> tag is an empty tag, which means that it can contain only a list of attributes and
has no closing tag.
<img src="image_path" alt="Alternate text for the image" width="200px" height="150px" />
src: The src attribute defines the path of the image (image URL).
alt: The alt attribute defines the alternate text; if there is a broken link to the image path, the
alternate text displays on the webpage.
width and height: The width and height attribute define the height and width for the image.
Make sure you specify the correct image file name in the src attribute. The image name is always
case-sensitive.
The alt attribute is an optional attribute but recommended as it specifies an alternate text for an
image if the image cannot be displayed.
HTML Lists
An HTML List allows you to organize data on web pages into an ordered or unordered
format to make the information easier to read and visually appealing. HTML Lists are very
helpful for creating structured, accessible content in web development.
type: It defines which type(1, A, a, I, and i) of the order you want in your list of numeric,
alphabetic, or roman numbers.
Item 1
Description of Item 1
Item 2
Description of Item 2
To make a cell span over multiple columns, use the colspan attribute:
<th colspan=”2” >subject </th> // span over 2 columns
To make a cell span over multiple rows, use the rowspan attribute:
<th rowspan=”3” >name</th> // span over 3 rows