HTML_Notes
HTML_Notes
com/learn/class-10-cbse-code-165-sumita-computer-
applications/solutions/P3j4Q/basic-html#theoretical-questions
html
HTML is the standard markup language for creating Web pages. HTML is a global
markup language for web. You can create any a webpage using HTML and any
browser can open that HTML file.
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 the content
HTML elements label pieces of content such as "this is a heading", "this is a
paragraph", "this is a link", etc.
Features of HTML
It is easy to learn and easy to use.
It is platform-independent.
Images, videos, and audio can be added to a web page.
Hypertext can be added to the text.
It is a markup language.
HTML Page Structure
The basic structure of an HTML page is shown below. It contains the essential
building-block elements (i.e. doctype declaration, HTML, head, title, and body
elements) upon which all web pages are created.
A Simple HTML Document
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
</body>
</html>
Advantages of HTML
HTML is used to build websites.
It is supported by all browsers.
It can be integrated with other languages like CSS, JavaScript, etc.
Disadvantages of HTML
HTML can only create static web pages. For dynamic web pages, other
languages have to be used.
A large amount of code has to be written to create a simple web page.
The security feature is not good.
<!-- Multi
It follows the syntax of a single-line comment by
Multi-line Line
adding multiple lines in the comment.
Comment -->
HTML Lists :
An HTML list is a structured record of related information used to display data or
information on web pages in an ordered or unordered form. Lists are fundamental
for organizing content in a clear and readable way.
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.
Syntax
<img src="url" alt="alternatetext">
Image Size - Width and Height
<img src="D:\Flower3.JPG" alt="Flower" style="width:500px;height:600px;">
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:
<form>
.
form elements
.
</form>
The <form> element is a container for different types of input elements, such as:
text fields, checkboxes, radio buttons, submit buttons, etc.
The <input> Element
Type Description
<input type="text"> Displays a single-line text input field
<input type="radio"> Displays a radio button (for selecting
one of many choices)
<input type="checkbox"> Displays a checkbox (for selecting zero or
more of many choices)
<input type="submit"> Displays a submit button
(for submitting the form)
<input type="button"> Displays a clickable button
Code
<!DOCTYPE html>
<html>
<body>
<h2>HTML Forms</h2>
<form action="/action_page.php">
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname" value="Shubhanshu"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname" value="Shukla"><br><br>
<input type="submit" value="Submit">
</form>
<p>If you click the "Submit" button, the form-data will be sent to a page called
"</p>
</body>
</html> OUTPUT
The <label> Element
Notice the use of the <label> element in the example above.
The <label> element is useful for screen-reader users, because the screen-
reader will read out loud the label when the user focuses on the input
element.
The <label> element also helps users who have difficulty clicking on very
small regions (such as radio buttons or checkboxes) - because when the user
clicks the text within the <label> element, it toggles the radio
button/checkbox.
The for attribute of the <label> tag should be equal to the id attribute of
the <input> element to bind them together.
Radio Buttons
The <input type="radio"> defines a radio button.
<html>
<body>
<h2>Radio Buttons</h2>
<form>
<label for="html">HTML</label><br>
<label for="css">CSS</label><br>
<label for="javascript">JavaScript</label>
</form> </body>
</html>
Checkboxes
The <input type="checkbox"> defines a checkbox.
Checkboxes let a user select ZERO or MORE options of a limited number of choices.
<!DOCTYPE html>
<html>
<body>
<h2>Checkboxes</h2>
<p>The <strong>input type="checkbox"</strong> defines a checkbox:</p>
<form action="/action_page.php">
<input type="checkbox" id="vehicle1" name="vehicle1" value="Bike">
<label for="vehicle1"> I have a bike</label><br>
<input type="checkbox" id="vehicle2" name="vehicle2" value="Car">
<label for="vehicle2"> I have a car</label><br>
<input type="checkbox" id="vehicle3" name="vehicle3" value="Jeep">
<label for="vehicle3"> I have a boat</label><br><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
The Submit Button
The <input type="submit"> defines a button for submitting the form data to a form-
handler.
The form-handler is typically a file on the server with a script for processing input data.
<!DOCTYPE html>
<html>
<body>
<form action="/action_page.php">
</form>
</body>
</html>
If the name attribute is omitted, the value of the input field will not be sent at all.
OUTPUT
Table Tag
HTML <table> Tag: This tag is used to create the table that wrap the rows and
columns within it.
HTML <tr> Tag: Stands for "table row" and is used to create a row within the
table.
HTML <td> Tag: Represents "table data" and is used to create standard cells
within a row.
HTML <th> Tag: Represents "table header" and is used to create header cells
within a row.
Example :
<!DOCTYPE html>
<html>
<body>
<table border="1">
<tr>
<th>Product</th>
<th>Category</th>
<th>Price</th>
</tr>
<tr>
<td>Laptop</td>
<td>Electronics</td>
<td>$800</td>
</tr>
<tr>
<td>Bookshelf</td>
<td>Furniture</td>
<td>$150</td>
</tr>
<tr>
<td>Coffee Maker</td>
<td>Appliances</td>
<td>$50</td>
</tr>
</table>
</body>
</html>
Output :
HTML bgcolor Attribute: We can set background color for whole table or just for one cell.
HTML background Attribute: We can set background image by using the HTML
background attribute.
You can also set border color also using bordercolor attribute.
<!DOCTYPE html>
<html>
<head>
<title>HTML Table Background Color</title>
</head>
<body>
<table border="1" bordercolor="green" bgcolor="yellow">
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
</tr>
<tr>
<td rowspan="2">Row 1 Cell 1</td>
<td>Row 1 Cell 2</td>
<td>Row 1 Cell 3</td>
</tr>
<tr>
<td>Row 2 Cell 2</td>
<td>Row 2 Cell 3</td>
</tr>
<tr>
<td colspan="3">Row 3 Cell 1</td>
</tr>
</table>
</body>
</html>
Output :