Shreya
Shreya
HTML is an acronym which stands for Hyper Text Markup Language which
is used for creating web pages and web applications. Let's see what is meant
by Hypertext Markup Language, and Web page.
Hyper Text: HyperText simply means "Text within Text." A text has a link
within it, is a hypertext. Whenever you click on a link which brings you to a
new webpage, you have clicked on a hypertext. HyperText is a way to link two
or more web pages (HTML documents) with each other.
History Of Html-
HTML 1.0 (1991): The first version of HTML, known as HTML 1.0, was
introduced by Tim Berners-Lee in 1991. It included basic elements for
structuring a document, such as headings, paragraphs, and links.
HTML 2.0 (1995): The Internet Engineering Task Force (IETF) took over the
development of HTML, and HTML 2.0 was released in 1995. This version
introduced new features like tables and text alignment.
HTML 3.0 (1997): The World Wide Web Consortium (W3C) took over the
HTML standardization process. HTML 3.0 included more features like applets,
scripting, and support for style sheets.
HTML 4.0 (1997-1999): HTML 4.0, released in 1997, brought further
improvements, including support for scripting languages (like JavaScript) and
the introduction of the Document Object Model (DOM). HTML 4.01, a minor
revision, was released in 1999.
XHTML (2000): Extensible Hypertext Markup Language (XHTML) was
introduced as a reformulation of HTML using XML syntax. XHTML 1.0 was
published in 2000, emphasizing a stricter and cleaner coding style.
HTML5 (2014): HTML5, the latest major version of HTML, was officially
standardized by the W3C in 2014. It brought significant enhancements,
including new semantic elements (header, nav, article, etc.), multimedia
support without plugins (audio and video), and improved APIs for JavaScript.
Features of html-
5)Platform Independent-It means HTML can be run on any device which has
a basic web browser.Even on our mobile devices, we have chrome, firefox,
opera mini, etc. browsers so we can run HTML easily on any device.
Html Tags-All HTML tags must enclosed within < > these brackets.Every tag in
HTML perform different tasks.If you have used an open tag <tag>, then you
must use a close tag </tag> (except some tags)
2. Ordered List (<ol>)-An ordered list is used for listing items in a specific
order. The items in an ordered list are usually displayed with numbers or
letters.
<ol>
<li>First step</li>
<li>Second step</li>
<li>Third step</li>
</ol>
cellpadding: Defines the space between the cell content and its borders. (e.g.,
cellpadding="5")
width and height: Specify the width and height of the table.
align: Determines the alignment of the table on the page (e.g., left, center,
right).
colspan: Used within <td> or <th> to specify how many columns a cell should
span.
rowspan: Used within <td> or <th> to specify how many rows a cell should
span.
<!DOCTYPE html>
<html>
<head>
<title>Simple HTML Table</title>
</head>
<body>
<h2>My Favorite Fruits</h2>
<table border="1">
<tr>
<th>Name</th>
<th>Color</th>
</tr>
<tr>
<td>Apple</td>
<td>Red</td>
</tr>
<tr>
<td>Banana</td>
<td>Yellow</td>
</tr>
<tr>
<td>Grape</td>
<td>Purple</td>
</tr>
</table>
</body>
</html>
The HTML anchor tag defines a hyperlink that links one page to another page.
It can create hyperlink to other web page as well as files, location, or any URL.
The "href" attribute is the most important attribute of the HTML a tag. and
which links to destination page or URL.
The href attribute is used to define the address of the file to be linked. In other
words, it points out the destination page.
Syntax
1. <element attribute_name="value">content</element>
Example:
<body>
<form>
Enter your name <br>
<input type="text" name="username">
</form>
</body>
Output:
1. <form>
2. First Name: <input type="text" name="firstname"/> <br/>
3. Last Name: <input type="text" name="lastname"/> <br/>
4. </form>
Output:
The <textarea> tag in HTML is used to insert multiple-line text in a form. The
size of <textarea> can be specify either using "rows" or "cols" attribute or by
CSS.
Example:
1. <!DOCTYPE html>
2. <html>
3. <head>
4. <title>Form in HTML</title>
5. </head>
6. <body>
7. <form>
8. Enter your address:<br>
9. <textarea rows="2" cols="20"></textarea>
10. </form>
11. </body>
12. </html>
Output:
If you click on the label tag, it will focus on the text control. To do so, you need
to have for attribute in label tag that must be same as id attribute of input tag.
1. <form>
2. <label for="firstname">First Name: </label> <br/>
3. <input type="text" id="firstname" name="firstname"/> <br/>
4. <label for="lastname">Last Name: </label>
5. <input type="text" id="lastname" name="lastname"/> <br/>
6. </form>
Output:
HTML Password Field Control
1. <form>
2. <label for="password">Password: </label>
3. <input type="password" id="password" name="password"/> <br/>
4. </form>
Output:
The email field in new in HTML 5. It validates the text for correct email
address. You must use @ and . in this field.
1. <form>
2. <label for="email">Email: </label>
3. <input type="email" id="email" name="email"/> <br/>
4. </form>
It will display in browser like below:
Note: If we will not enter the correct email, it will display error like:
The radio button is used to select one option from multiple options. It is used
for selection of gender, quiz questions etc.If you use one name for all the radio
buttons, only one radio button can be selected at a time.Using radio buttons
for multiple options, you can only choose a single option at a time.
1. <form>
2. <label for="gender">Gender: </label>
3. <input type="radio" id="gender" name="gender" value="male"/>Male
4. <input type="radio" id="gender" name="gender" value="female"/>Female
<br/>
5. </form>
Checkbox Control
The checkbox control is used to check multiple options from given checkboxes.
1. <form>
2. Hobby:<br>
3. <input type="checkbox" id="cricket" name="cricket" value="cricket"/>
4. <label for="cricket">Cricket</label> <br>
5. <input type="checkbox" id="football" name="football" value="football"/>
6. <label for="football">Football</label> <br>
7. <input type="checkbox" id="hockey" name="hockey" value="hockey"/>
8. <label for="hockey">Hockey</label>
9. </form>
Note: These are similar to radio button except it can choose multiple
options at a time and radio button can select one button at a time, and its
display.
Output:
HTML <input type="submit"> are used to add a submit button on web page.
When user clicks on submit button, then form get submit to the server.
Syntax:
Example:
1. <form>
2. <label for="name">Enter name</label><br>
3. <input type="text" id="name" name="name"><br>
4. <label for="pass">Enter Password</label><br>
5. <input type="Password" id="pass" name="pass"><br>
6. <input type="submit" value="submit">
7. </form>
Output:
Example:
1. <form>
2. <fieldset>
3. <legend>User Information:</legend>
4. <label for="name">Enter name</label><br>
5. <input type="text" id="name" name="name"><br>
6. <label for="pass">Enter Password</label><br>
7. <input type="Password" id="pass" name="pass"><br>
8. <input type="submit" value="submit">
9. </fieldset>
10. lt;/form>
Output:
1. <!DOCTYPE html>
2. <html>
3. <head>
4. <title>Form in HTML</title>
5. </head>
6. <body>
7. <h2>Registration form</h2>
8. <form>
9. <fieldset>
10. <legend>User personal information</legend>
11. <label>Enter your full name</label><br>
12. <input type="text" name="name"><br>
13. <label>Enter your email</label><br>
14. <input type="email" name="email"><br>
15. <label>Enter your password</label><br>
16. <input type="password" name="pass"><br>
17. <label>confirm your password</label><br>
18. <input type="password" name="pass"><br>
19. <br><label>Enter your gender</label><br>
<input type="radio" id="gender" name="gender" value="male"/>Male <br/
<input type="radio" id="gender" name="gender" value="female"/>Female
<br/>
<input type="radio" id="gender" name="gender" value="others"/>others
<br/>
20. <br>Enter your Address:<br>
21. <textarea></textarea><br>
22. <input type="submit" value="sign-up">
23. </fieldset>
24. </form>
25. </body>
26. </html> Output:
Html Frameset-
The <frameset> tag in HTML is used to define the frameset. The <frameset>
element contains one or more frame elements. It is used to specify the number
of rows and columns in frameset with their pixel of spaces. Each element can
hold a separate document.
Syntax:
<frameset cols = "pixels|%|*">
cols: The cols attribute is used to create vertical frames in a web browser.
This attribute is basically used to define the no. of columns and their size
inside the frameset tag.
rows: The rows attribute is used to create horizontal frames in the web
browser. This attribute is used to define the no. of rows and their size
inside the frameset tag.
border: This attribute of frameset tag defines the width of the border of
each frame in pixels. Zero value is used for no border.
frameborder: This attribute of frameset tag is used to specify whether a
three-dimensional border should be displayed between the frames or not
for this use two values 0 and 1, where 0 defines no border and value 1
signifies for yes there will be a border.
framespacing: This attribute of frameset tag is used to specify the amount
of spacing between the frames in a frameset. This can take any integer
value as a parameter which basically denotes the value in pixel
Eg-
1]
<!DOCTYPE html>
<html>
<head>
<title>frameset attribute</title>
</head>
<frameset rows = "20%, 60%, 20%">
<frame name = "top" src = "attr1.png" />
<frame name = "main" src = "gradient3.png" />
<frame name = "bottom" src = "col_last.png" />
</frameset>
</html>
2] <!DOCTYPE html>
<html>
<head>
<title>frameset attribute</title>
</head>
What is CSS?
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-color: lightblue;
h1 {
color: white;
text-align: center;
p{
font-family: verdana;
font-size: 20px;
</style>
</head>
<body>
<p>This is a paragraph.</p>
</body>
</html>
CSS Syntax
Types Of CSS-
<!DOCTYPE html>
<html>
<head>
</head>
<body>
This is a paragraph of text with inline CSS styles. The font size is set to 16
pixels,
and the line height is set to 1.5 times the font size.
</p>
</body>
</html>
Internal or Embedded CSS: This can be used when a single HTML document
must be styled uniquely. The CSS rule set should be within the HTML file in the
head section i.e. the CSS is embedded within the <style> tag inside the head
section of the HTML file.
Example: This example shows the application of internal-css.
<!DOCTYPE html>
<html>
<head>
<title>Internal CSS</title>
<style>
.main {
text-align: center;
.GFG {
color: #009900;
font-size: 50px;
font-weight: bold;
.geeks {
font-style: bold;
font-size: 20px;
</style>
</head>
<body>
<div class="main">
<div class="geeks">
A computer science portal for geeks
</div>
</div>
</body>
</html>
External CSS: External CSS contains separate CSS files that contain only style
properties with the help of tag attributes (For example class, id, heading, …
etc). CSS property is written in a separate file with a .css extension and should
be linked to the HTML document using a link tag. It means that, for each
element, style can be set only once and will be applied across web pages.
Example: The file given below contains CSS property. This file saves with .css
extension. For Ex: geeks.css
body {
background-color:powderblue;
}
.main {
text-align:center;
}
.GFG {
color:#009900;
font-size:50px;
font-weight:bold;
}
#geeks {
font-style:bold;
font-size:20px;
}
Below is the HTML file that is making use of the created external style sheet.
link tag is used to link the external style sheet with the html webpage.
href attribute is used to specify the location of the external style sheet file.
html
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div class="main">
<div class="GFG">GeeksForGeeks</div>
<div id="geeks">
</div>
</div>
</body>
</html>
Output:
Importance Of CSS-
1. Visual Styling: CSS allows web developers to control the presentation and
appearance of web pages. It provides a wide range of styling options such
as colors, fonts, layouts, backgrounds, borders, and more. With CSS, you
can make your website visually attractive, consistent, and aligned with
your branding.
6. Print Styling: CSS also plays a role in print styling, allowing developers to
define specific styles for when web pages are printed. This is particularly
useful for generating printer-friendly versions of web content, ensuring
that printed documents maintain a consistent and professional
appearance.
CSS Selectors-A CSS selector selects the HTML element(s) you want to
style.
The CSS id Selector
To select an element with a specific id, write a hash (#) character, followed by
the id of the element.
<!DOCTYPE html>
<html>
<head>
<style>
#p1 {
text-align: center;
color: red;
</style>
</head>
<body>
</body>
</html>
Output-
Hello World!
The class selector selects HTML elements with a specific class attribute.
To select elements with a specific class, write a period (.) character, followed
by the class name.
Example
In this example all HTML elements with class="center" will be red and
center-aligned:
<!DOCTYPE html>
<html>
<head>
<style>
.center {
text-align: center;
color: red;
</style>
</head>
<body>
</body>
</html>
Output-
In this example only <p> elements with class="center" will be red and center-
aligned:
<!DOCTYPE html>
<html>
<head>
<style>
p.center {
text-align: center;
color: red;
</style>
</head>
<body>
</html>
Output-
In this example the <p> element will be styled according to class="center" and
to class="large":
<!DOCTYPE html>
<html>
<head>
<style>
p.center {
text-align: center;
color: red;
p.large {
font-size: 300%;
}
</style>
</head>
<body>
</body>
</html>
Output-
The grouping selector selects all the HTML elements with the same style
definitions.
<html>
<head>
<style>
h1, h2, p {
text-align: center;
color: red;
</style>
</head>
<body>
<h1>Hello World!</h1>
<h2>Smaller heading!</h2>
<p>This is a paragraph.</p>
</body>
</html>
Output-
Hello World!
Smaller heading!
This is a paragraph.
Eg-2]
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h1>Heading One</h1>
<h2>Heading Two</h2>
<p>Paragraph One</p>
<p>Paragraph Two</p>
<div>Div content</div>
</body>
</html>
CSS(style.css)-
h1, h2, p {
color: green;
color: blue;
CSS Properties-
body {
Eg.
h1 {
font-size: 24px;
font-weight: bold;
Eg.
div {
margin: 10px;
padding: 20px;
width: 300px;
height: 150px;
Eg-
div {
border: 2px solid #ccc; /* 2px solid border with light gray color */
CSS plays an important role, by using CSS you simply got to specify a repeated
style for element once & use it multiple times as because CSS will
automatically apply the required styles.
The main advantage of CSS is that style is applied consistently across variety of
sites. One instruction can control several areas which is advantageous.
Web designers needs to use few lines of programming for every page
improving site speed.
Cascading sheet not only simplifies website development, but also simplifies
the maintenance as a change of one line of code affects the whole web site and
maintenance time.
It is less complex therefore the effort are significantly reduced.
It has the power for re-positioning. It helps us to determine the changes
within the position of web elements who are there on the page.
Easy for the user to customize the online page
It reduces the file transfer size.
Limitations-
With CSS, what works with one browser might not always work with
another. The web developers need to test for compatibility, running the
program across multiple browsers.
After making the changes we need to confirm the compatibility if they
appear. The similar change affects on all the browsers.
The programming language world is complicated for non-developers
and beginners. Different levels of CSS i.e. CSS, CSS 2, CSS 3 are often
quite confusing.
Browser compatibility (some styles sheet are supported and some are
not).
CSS works differently on different browsers. IE and Opera supports CSS
as different logic.