HTML AS IT
HTML AS IT
<html lang="en">
Note that you should use the html element rather than the body
element, since the body element doesn't cover the text inside the
document's head element.
The <title> element
The <style> element
• The <style> tag is used to define style information (CSS) for a
document.
• Inside the <style> element you specify how HTML elements should
render in a browser.
The <link> element
The <link> element
The <link> element
The <meta> element
• The metadata means information about data. The <meta> tag in
HTML provides information about HTML Document or in simple
words, it provides important information about a document. Adding
the meta tag while making the webpage or website, is a good practice
because search engines like Google search for this meta tag in order
to understand the information provided by the website. It is also
helpful if the user search for a specific website then the search engine
result page will display snippets in search results that will provide
information related to that website.
The <meta> element
• These tags are basically used to add name/value pairs to describe
properties of HTML documents, such as expiry date, author name, list
of keywords, document author, etc ie., it is used to specify a character
set, page description, keywords, author of the document, and viewport
settings. This tag is an empty element because it only has an opening
tag and no closing tag, but it carries information within its attributes. A
web document can include one or more meta tags depending on
information, but in general, it doesn’t affect the physical appearance of
the document.
• Syntax:
• <meta attribute-name="value">
The <meta> element
• Attributes: This tag accepts four attributes which are mentioned and
described below.
• name: This attribute is used to define the name of the property.
• http-equiv: This attribute is used to get the HTTP response message
header.
• content: This attribute is used to specify properties value.
• charset: This attribute is used to specify a character encoding for an
HTML file.
The <meta> element
• Key Points:
• The <meta> tag contents are not visible on your browser, but they can
be parsed by the machine.
• They are just used to give additional information about the HTML
document.
• The <meta> tags are added to our HTML document for the purpose
of Search Engine Optimisation.
• They are added inside the <head> tag & are used by browsers, search
engines & other web services.
• Through <meta> tag, designer can control the viewport.
The <script> element
• The <script> tag in HTML is used to define the client-side script. The
<script> tag contains the scripting statements, or it points to an
external script file. The JavaScript is mainly used in form validation,
dynamic changes of content, image manipulation, etc.
• Syntax:
Syntax:
<ul> list of items </ul>
Attribute: This tag contains two attributes which are listed below:
Syntax:
<ol>
<li>Item1</li>
<li>Item2</li>
<li>Item3</li>
</ol>
The HTML Ordered List
Attributes:
Syntax:
It passes SEO authority from other site to It passes SEO authority pages on your site,
your site, increasing your “domain increasing the “page authority” of specific
authority”. pages.
Syntax:
Syntax:
Here Pagename.html or URL is the name of the webpage or address where link will
navigate on click.
block-level and in-line elements
• Block Level Elements: A block-level element always starts on a new line and
stretches out to the left and right as far as it can ie, it occupies the whole
horizontal space of its parent element & the height is equal to the content’s
height.
• div element: The <div> element is used as a container for other HTML
elements. It has no required attributes. Style, class, and id are the commonly
used attributes.
• Syntax:
• <div>GFG</div>
block-level
• Example: Below code illustrates the implementation of <div> tag.
block-level and in-line elements
• Inline Elements: An inline element is the opposite of the block-level
element. It does not start on a new line and takes up only the necessary
width ie., it only occupies the space bounded by the tags defining the
HTML element, instead of breaking the flow of the content.
• span element: The <span> tag is used as a container for text. It has no
required attributes. Style, class, and id are the commonly used attributes.
• Syntax:
• <span>GFG</span>
In-line
• Example: Below code illustrates the implementation of <span> tag.
Images
• There are 2 ways to insert the images into a webpage:
• By providing a full path or address (URL) to access an internet file.
• By providing the file path relative to the location of the current web
page file.
Images
• The <img> tag is used to add or embed the images to a
webpage/website. The “img” tag is an empty tag, which means it can
contain only a list of attributes and it has no closing tag. The addition
of the images improves the quality along with enhancing the design
structure, appearance of the webpage. Nowadays, a website does not
directly add images to a web page, as the images are linked to web
pages by using the <img> tag which holds space for the image.
• Syntax:
• <img src="url" alt="some_text" width="" height="">
Images
• Attribute: The <img> tag has following attributes:
• src: It is used to specify the path to the image.
• alt: It is used to specify an alternate text for the image. It is useful as it informs the user about what the image means and
also due to any network issue if the image cannot be displayed then this alternate text will be displayed.
• crossorigin: It is used to import images from third-party sites that allow cross-origin access to be used with canvas.
• height: It is used to specify the height of the image.
• width: It is used to specify the width of the image.
• ismap: It is used to specify an image as a server-side image map.
• loading: It is used to specify whether a browser should defer the loading of images until some conditions are met or load
an image immediately.
• longdesc: It is used to specify a URL to a detailed description of an image.
• referrerpolicy: It is used to specify which referrer information to use when fetching an image i.e. no-referrer, no-referrer-
when-downgrade, origin, origin-when-cross-origin, unsafe-url.
• sizes: It is used to specify image sizes for different page layouts.
• srcset: It is used to specify a list of image files to use in different situations.
• usemap: It is used to specify an image as a client-side image map.
Images
• src: The src stands for source. Every image has an src attribute which
tells the browser where to find the image you want to display. The
URL of the image provided points to the location where the image is
stored. When the webpage loads for the first time, then the browser
gets the image from a web server and inserts it into the page. If the
image is not spotted by the browser then users will get a broken link
icon. It might be possible if the file path is wrong or the image got
deleted from that location.
Images
• Example 1: This simple example illustrates the use of the <img> tag in
HTML that is used to embed the image into the webpage.
.png’’
Images
• Example 1: This simple example illustrates the use of the <img> tag in
HTML that is used to embed the image into the webpage.
.png’’
Tables
• Defining Tables in HTML: An HTML table is defined with the “table”
tag. Each table row is defined with the “tr” tag. A table header is
defined with the “th” tag. By default, table headings are bold and
centered. A table data/cell is defined with the “td” tag.
Tables
• Example 1: In this example, we are creating a simple table in HTML using a table
tag.
Tables
• Example 3: This example explains the addition of the
border to the HTML Table.
Tables
Tables
• Creating Nested Tables: Nesting tables simply means making a Table inside another Table. Nesting tables can lead
to complex tables layouts, which are visually interesting and have the potential of introducing errors.
• Example 12: This example describes the Nested of HTML Table.
Forms
• <form> is a HTML element to collect input data with containing interactive controls. It provides facilities to
input text, number, values, email, password, and control fields such as checkboxes, radio buttons, submits
buttons, etc. or in other words, form is a container that contains input elements, like text, email, number,
radio buttons, checkboxes, submit buttons, etc. Forms are generally used when you want to collect data
from the user. For example, a user wants to buy a bag online, so he/she has to first enter their shipping
address in the address form and then add their payment detail in the payment form to place an order.
• Syntax:
• <form>
• elements of form...
• </form>
Forms
• Elements of HTML <form>
• These are the following HTML <form> elements:
• <label>: It defines label for <form> elements.
• <input>: It is used to get input data from the form in various type such as text, password, email, etc by
changing it’s type.
• <button>: It defines a clickable button to control other elements or execute a functionality.
• <select>: It is used to create a drop-down list.
• <textarea>: It is used to get input long text content.
• <fieldset>: It is used to draws a box around other form elements and group the related data.
• <legend>: It defines caption for fieldset elements.
• <datalist>: It is used to specify pre-defined list options for input controls.
• <output>: It display the output of performed calculations.
• <option>: It is used to define option in drop-down list.
• <optgroup>: It used to defines group related options in a drop down list.
Forms
• Elements of HTML <form>
• These are the following HTML <form> elements:
• <label>: It defines label for <form> elements.
• <input>: It is used to get input data from the form in various type such as text, password, email, etc by
changing it’s type.
• <button>: It defines a clickable button to control other elements or execute a functionality.
• <select>: It is used to create a drop-down list.
• <textarea>: It is used to get input long text content.
• <fieldset>: It is used to draws a box around other form elements and group the related data.
• <legend>: It defines caption for fieldset elements.
• <datalist>: It is used to specify pre-defined list options for input controls.
• <output>: It display the output of performed calculations.
• <option>: It is used to define option in drop-down list.
• <optgroup>: It used to defines group related options in a drop down list.
Forms
Textbox in HTML Form
• In an HTML form, we use <input> tag by assigning type attribute value
to text to input single line input. It is the most commonly used tag. To
define type attribute see the below syntax.
• Syntax:
• <input type="text">
Forms
Forms
Radio Button in an HTML Form
To create a radio button, we use the <input> tag following by radio type
to provide users to choose a limited number of choices.
Syntax:
• Syntax:
• <input type="checkbox">
Forms
Forms
Combobox in an HTML Form
Combobox is used to create a drop-down menu in your form which contains multiple options.
So, to create an Combobox in an HTML form, we use the <select> tag with <option> tag. It is
also known as a drop-down menu.
Syntax:
<select>
<option>option1</option>
<option>option2</option>
<option>option3</option>
</select>
Forms
Forms
Submit button in an HTML Form
In the HTML form, submit button is used to submit the details of the
form to the form handler. A form handler is a file on the server with a
script that is used to process input data.
Syntax:
Syntax:
• Syntax
• <video>
• <source src="file_name" type="video_file_type">
• </video>
Video
Attribute Value Description
When the page is loaded. It specifies to play video
autoplay autoplay
as soon as possible.
auto
It specifies how the author thinks the video will be
preload metadata
loaded when the page is ready.
none
OR
Audio
• To embed audio in HTML, we use the <audio> tag. Before HTML5, audio can
not be added to web pages in the Internet Explorer era. To play audio, we
used web plugins like Flash. After the release of HTML5, it is possible. This tag
supports Chrome, Firefox, Safari, Opera, and Edge in three audio formats –
MP3, WAV, OGG. Only Safari browser doesn’t support OGG audio format.
• Syntax:
• <audio>
• <source src="file_name" type="audio_file_type">
• </audio>
Audio
Attribute Value Description
When the page is loaded. It specifies to
autoplay autoplay play audio as soon as possible.
• Syntax: