Introduction to HTML
Introduction to HTML
What is HTML?
• HTML stands for Hyper Text Markup Language
• HTML is the standard markup language for
creating Web pages
• HTML describes the structure of a Web page
• HTML consists of a series of elements
• HTML elements tell the browser how to
display content
Purpose of HTML Elements
• Example Code:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
Key HTML Components
• <!DOCTYPE html>: Defines the document as
HTML5
• <html>: Root element of the HTML page
• <head>: Contains meta information about the
page
• <title>: Specifies the page title (shown in the
browser's tab)
• <body>: Container for visible content (headings,
paragraphs, etc.)
Common HTML Elements
• <h1>: Defines a large heading
• <p>: Defines a paragraph
• Example:
<h1>My First Heading</h1>
<p>My first paragraph.</p>
What is an HTML Element?
• Defined by:
- Start tag
- Content
- End tag
• Structure:
<tagname> Content goes here... </tagname>
• Example:
<h1>My First Heading</h1>
<p>My first paragraph.</p>
Code Output
Code Output
Code Output
Code Output
Code Output
Code Output
HTML Headings
• HTML headings are titles or subtitles that you want to
display on a webpage.
• HTML headings are defined with the <h1> to <h6> tags.
• <h1> defines the most important heading. <h6> defines
the least important heading.
• Each HTML heading has a default size. However, you
can specify the size for any heading with the style
attribute, using the CSS font-size property:
• <h1 style="font-size:60px;">Heading 1</h1>
HTML Paragraphs
– Marking abbreviations can give useful information to browsers, translation systems and search-
engines.
<address>
– The HTML <address> tag defines the contact information for the author/owner of a document or
an article.
– The contact information can be an email address, URL, physical address, phone number, social
media handle, etc.
– The text in the <address> element usually renders in italic, and browsers will always add a line
break before and after the <address> element.
HTML Comments
• HTML comments are not displayed in the browser, but they can
help document your HTML source code.
• <!-- Write your comments here -->
• Comments can be used to hide content.
• You can also hide more than one line. Everything between the
<!-- and the --> will be hidden from the display.
• Comments are also great for debugging HTML, because you can
comment out HTML lines of code, one at a time, to search for
errors.
HTML Links
• 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.
• By default, links will appear as follows in all browsers:
• Images are not technically inserted into a web page; images are linked to web pages. The <img> tag creates a holding
space for the referenced image.
• The <img> tag is empty, it contains attributes only, and does not have a closing tag.
• To point to an image on another server, you must specify an absolute (full) URL in the src attribute
HTML Images
• The float property in CSS is used to position
an element to the left or right of its
container, allowing text or inline elements to
wrap around it. It's commonly used for
layouts, images, or floating elements
alongside text.
• float: none | left | right;
HTML ImageMap
• By defining various shapes (rectangles, circles, and polygons) within an image,
each with its own associated link, developers can create dynamic and
interactive visual HTML image maps are defined by the <map> tag.
• An image map enables specific areas of an image to be clickable, acting as
links to different destinations.
• This technique is useful for creating complex navigation systems or interactive
graphics on a webpage.
<map name="world map">
<!-- Define your clickable areas here --> </map>
• When used in conjunction with the <img> tag, the <map> tag
establishes a connection between the image and its associated map.
• The <area> tag is used within the <map> tag to define clickable
regions on an image. It specifies the shape, coordinates, and
associated actions for each clickable area.
• Following is the syntax of the <area> tag −
• <area shape="shape_values" coords="coordinates" href="url"
alt="Description">
Creating Image Map in HTML
– Hex codes − A six-digit code representing the amount of red, green, and blue
that makes up the color.
– Color decimal or percentage values − This value is specified using the rgb()
property.
HTML Colors
• Colors can also be specified using the web-safe colors, which are formed
by the combination of red, green, and blue (RGB) hex values.
• Here is a list of 216 colors that are considered the safest and most
consistent across different computers. These colors range from the
hexadecimal code #000000 (black) to #FFFFFF (white) and are supported
by all computers using a 256-color palette.
•
Set Text Color
• Set Background Color style="background-color: Fuchsia;"
• Set Border Color style="border: 2.5px solid Fuchsia;
HTML Tables
• HTML tables allow web developers to arrange data into rows and columns.
• <table>
<tr>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
</tr>
<tr>
<td>Alfreds Futterkiste</td>
<td>Maria Anders</td>
<td>Germany</td>
</tr>
<tr>
<td>Centro comercial Moctezuma</td>
<td>Francisco Chang</td>
<td>Mexico</td>
</tr>
</table>
HTML Tables
• HTML tables can have borders of different
styles and shapes.
• To add a border, use the CSS border property
on table, th, and td elements:
HTML Lists
• HTML lists allow web developers to group a
set of related items in lists.
• The <script> element either contains script statements, or it points to an external script file
through the src attribute.
• Common uses for JavaScript are image manipulation, form validation, and dynamic changes
of content.
• This JavaScript example writes "Hello JavaScript!" into an HTML element with id="demo":
• <script>
document.getElementById("demo").innerHTML = "Hello JavaScript!";
</script>
document.getElementById("demo").innerHTML = "Hello JavaScript!";
HTML HEAD Element
• The HTML <head> element is a container for the following elements: <title>, <style>,
<meta>, <link>, <script>, and <base>.
• The <title> element defines the title of the document. The title must be text-only, and
it is shown in the browser's title bar or in the page's tab.
• The <style> element is used to define style information for a single HTML page:
• The <link> element defines the relationship between the current document and an
external resource.
• The <link> tag is most often used to link to external style sheets
• The <meta> element is typically used to specify the character set, page description,
keywords, author of the document, and viewport settings.
• The metadata will not be displayed on the page, but is used by browsers (how to
display content or reload page), by search engines (keywords), and other web
services.
Setting the Viewport
• The viewport is the user's visible area of a web page. It varies with the
device - it will be smaller on a mobile phone than on a computer screen.
• You should include the following <meta> element in all your web pages:
• <meta name="viewport" content="width=device-width, initial-scale=1.0">
• This gives the browser instructions on how to control the page's
dimensions and scaling.
• The width=device-width part sets the width of the page to follow the
screen-width of the device (which will vary depending on the device).
• The initial-scale=1.0 part sets the initial zoom level when the page is first
loaded by the browser.
HTML Forms
• An HTML form is used to collect user input. The
user input is most often sent to a server for
processing.
• The HTML <form> element is used to create an
HTML form for user input:
• The action attribute defines the action to be performed when the form is submitted.
Usually, the form data is sent to a file on the server when the user clicks on the submit
button.
• In the example below, the form data is sent to a file called "action_page.php". This file
contains a server-side script that handles the form data
The Method Attribute
• The method attribute specifies the HTTP method to be used when submitting the form
data.
• The form-data can be sent as URL variables (with method="get") or as HTTP post
transaction (with method="post").
• <input type="button">
• <input type="checkbox">
• <input type="color">
• <input type="date">
• <input type="datetime-local">
• <input type="email">
• <input type="file">
• <input type="hidden">
• <input type="image">
• <input type="month">
• <input type="number">
• <input type="password">
• <input type="radio">
• <input type="range">
• <input type="reset">
• <input type="search">
• <input type="submit">
• <input type="tel">
• <input type="text">
• <input type="time">
• <input type="url">
• <input type="week">
HTML Styles
<element style="property: value; property: value;">
Background Styling
• background-color: Sets background color.
• Example: style="background-color: yellow;"
• background-image: Adds a background image.
• Example: style="background-image: url('image.jpg');
HTML Styles
Summary
• HTML is the backbone of web pages
• Elements define the structure and
presentation of content
• Basic syntax includes tags, attributes, and
content
• Practice with simple examples to build
understanding