HTML_Notes
HTML_Notes
#HTML:-
1) HTML stands for Hyper Text Markup Language.
#Markup Language:-
A markup language is used to format and structure text in a document.
It makes text interactive and dynamic by turning it into images, tables, links, etc.
#Web Page :-
A web page is a document written in HTML and displayed by a web browser.
#Features of HTML:-
1. Easy to Learn: HTML is a simple and easy-to-understand language.
3. Flexible Design: Being a markup language, it allows flexible web page design with text.
4. Hyperlinks: HTML lets programmers add links using the <a> tag, improving user browsing experience.
5. Platform Independent: HTML works on all platforms like Windows, Linux, and macOS.
6. Multimedia Support: It allows adding graphics, videos, and sounds to make web pages interactive.
<html>: This tag indicates the document is HTML and contains all other HTML elements expect <!DOCTYPE>.
<head>: It should be the first element inside the <html> element, which Contains metadata about the document
and comes before the <body>.
1. <!DOCTYPE>
2. <html>
3. <head>
4. <title>Web page title</title>
5. </head>
6. <body>
7. <h1>Write Your First Heading</h1>
8. <p>Write Your First Paragraph.</p>
9. </body>
10. </html>
<title>: Specifies the title of the HTML page, shown at the top of the browser window or tab. Must be inside the
<head> tag and closed immediately. (Optional)
Example: <title>My Webpage</title>.
<body>: Contains the visible content of the webpage, such as text, images, and links. It is placed inside the
<html> tag.
Example:<body>
Welcome to my webpage!
</body>
<h1>: Text between <h1> tag describes the first level heading of the webpage.
Example: <h1>Welcome!</h1>
<p>: Text between <p> tag describes the paragraph of the webpage.
Example: <p>This is a paragraph of text.</p>.
*An HTML document consist of its basic building blocks which are:
Tags: An HTML tag surrounds the content and apply meaning to it. It is written between < and >
brackets. Example: <h1> or <p>
Attributes: Provide additional information about an element. Written in the opening tag and consist of a
name and value.
Example: <img src="image.jpg" alt="A picture">
Elements: The complete structure, including the tags and the content inside them.
Example: <p>This is a paragraph.</p>.
#HTML Tags :-
HTML tags are keywords that tell the browser how to format and display content.
Tags help the browser distinguish HTML content from plain text.
Most tags have three parts: opening tag, content, and closing tag (e.g., <p>Content</p>). Some tags are
self-closing (e.g., <img>).
Browsers read HTML documents from top to bottom, left to right.
Tags are used to build HTML documents and define their properties.
Each tag has unique properties and functions.
An HTML file must include essential tags to help the browser recognize it as HTML.
All tags are written inside < > brackets.
Each tag serves a specific purpose.
Most tags need an opening <tag> and a closing </tag>, except for self-closing tags.
HTML tags are always written in lowercase.
#Unclosed HTML Tags:-
•Some HTML tags are not closed, for example br and hr.
•<br> Tag: br stands for break line, it breaks the line of the code.
•<hr> Tag: hr stands for Horizontal Rule. This tag is used to put a line across the webpage.
#HTML Attribute:-
HTML attributes are special words which provide additional information about the elements or attributes
are the modifier of the HTML element.
Each element or tag can have attributes, which defines the behavior of that element.
Attributes should always be applied with start tag.
The Attribute should always be applied with its name and value pair.
The Attributes name and values are case sensitive, and it should be written in Lowercase only.
You can add multiple attributes in one HTML element, but need to give space between two attributes.
Or
In the example, a style attribute is used with the <p> tag to apply CSS properties.
Example:
Or
Example:
#Absolute Path:
Starts from the root directory of the system and gives the exact location of a file or directory.
It always points to the same place, no matter where you are in the system.
An absolute path is the full URL or path to a file.
#Relative Path:
Starts from the current directory and describes the file's location in relation to it.
It's more convenient when working within a specific directory or subdirectory.
Example:
Example:<head>
<meta charset="UTF-8">
</head>
Example:
#HTML Lists:-HTML lists allow web developers to group a set of related items in lists.
Unordered HTML List: An unordered list starts with the<ul>tag. Each list item starts with the<li>tag.
The list items will be marked with bullets (small black circles) by default.
Ordered HTML List: An ordered list starts with the<ol>tag. Each list item starts with the<li>tag.
The list items will be marked with numbers by default.
OR
HTML Lists group related items together.
Unordered List:
Example:
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
Ordered List:
Example:
<ol>
<li>First item</li>
<li>Second item</li>
</ol>
<html>
<body>
<h2>Ordered List</h2>
<ol type="1">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
<ol type="A">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
<ol type="a">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
<ol type="I">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
<ol type="i">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
<ol start="50">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
<ol>
<li>Coffee</li>
<li>Tea
<ol>
<li>Black tea</li>
<li>Green tea</li>
</ol>
</li>
<li>Milk</li>
</ol>
</body>
</html>
HTML tables are used to arrange data into rows and columns.
A table consists of table cells inside rows and columns.
Each table cell is defined by the <td> tag (for data).
The content of the table cell is placed between the <td> and </td> tags.
Each table row starts with the <tr> tag and ends with the </tr> tag.
You can add as many rows as needed, but each row must have the same number of cells.
Ex:
<table>
<tr>
</tr>
<tr>
</tr>
</table>
--------------------------------------------
<!DOCTYPE html>
<html><body>
</tr>
<tr >
<td style="border:solid">Emil</td>
<td style="border:solid">Tobias</td>
<td style="border:solid">Linus</td>
</tr>
<tr>
<td style="border:solid">16</td>
<td style="border:solid">14</td>
<td style="border:solid">10</td>
</tr>
</table></body></html>
<html>
<body>
<tr>
<th colspan="2">Name</th>
<th>Age</th>
</tr>
<tr>
<td height="100px">Jill</td>
<td>Smith</td>
<td>43</td>
</tr>
<tr>
<td style="height:50px">Eve</td>
<td>Jackson</td>
<td>57</td>
</tr>
</table>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<th>Name</th>
<td>Jill</td>
</tr>
<tr>
<th rowspan="2">Phone</th>
<td>555-1234</td>
</tr>
<tr>
<td>555-8745</td>
</tr>
</table>
</body>
</html>
#HTML Forms:-
HTML forms are used to collect user input, usually sent to a server for processing.
The <form> element acts as a container for different types of input elements, such as text fields, checkboxes, radio buttons,
and submit buttons.
Example:
<form>
<label for="name">Name:</label>
<label for="subscribe">Subscribe:</label>
Type Description
<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)
@Text Fields:-
The <input type="text"> creates a single-line input field for text.
The form itself is not visible, only the input fields are.
Example:
<!DOCTYPE html>
<html>
<body>
<form>
<label for="fname">First Name:</label><br>
</form>
</body>
</html>
#The <label> Element:-
The <label> tag defines a label for form elements.
It is useful for screen-reader users because it reads out the label when the user focuses on the input element.
It helps users click on small form elements like radio buttons or checkboxes by allowing them to click the label text to toggle
the element.
The for attribute of the <label> tag should match the id of the associated <input> element to link them together.
Example:
<form>
<label for="subscribe">Subscribe:</label>
<input type="checkbox" id="subscribe" name="subscribe">
</form>
Radio Buttons: Radio buttons let a user select ONE of a limited number of choices.
<!DOCTYPE html>
<html>
<body>
<h2>Radio Buttons</h2>
<p>Choose your favorite Web language:</p>
<form>
<input type="radio" id="html" name="fav_language" value="HTML">
<label for="html">HTML</label><br>
<input type="radio" id="css" name="fav_language" value="CSS">
<label for="css">CSS</label><br>
<input type="radio" id="javascript" name="fav_language" value="JavaScript">
<label for="javascript">JavaScript</label>
</form>
</body>
</html>
The form data is sent to a form-handler, which is usually a file on the server with a script to process the data.
The form-handler's location is specified in the action attribute of the <form> tag.
Example:
<form action="submit_form.php">
#Checkboxes:-
Checkboxes allow the user to select zero or more options from a limited set of choices.
Example:
<!DOCTYPE html>
<html>
<body>
<h2>Checkboxes</h2>
</form>
</body>
</html>
OR from pdf
<!DOCTYPE html>
<html>
<body>
<h2>Checkboxes</h2>
<form action="/action_page.php">
<input type="checkbox" id="vehicle1" name="vehicle1" value="Bike">
</form>
</body>
</html>
#HTML Form Attributes:
The Action Attribute:
The action attribute specifies what happens when the form is submitted.
Typically, the form data is sent to a file on the server, where it is processed.
In the example, form data is sent to a file called action_page.php, which contains a script to handle the data.
If the action attribute is not included, the data is sent to the current page.
Example:
<form action="action_page.php">
<input type="text" name="username">
<input type="submit" value="Submit">
</form>
Value Description
Example:
<form action="submit_form.php" target="_blank">
Example:
<form action="submit_form.php" method="post">
<input type="text" name="username">
GET Method:
Example:
POST Method:
POST sends form data in the body of the HTTP request (not visible in the URL).
Example:
------
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>hello</title>
</head>
<body style="background-color:powderblue;">
<h1> HTML </h1>
<br>
<br>
<br>
</form></body></html>
1. <input>
2. <label>
3. <select>
4. <textarea>
5. <button>
6. <fieldset>
7. <legend>
8. <datalist>
9. <output>
10. <option>
Example:
<input type="text" name="username">
The <option> element defines the items that can be selected from the list.
<select name="fruits">
<option value="apple">Apple</option>
<option value="orange">Orange</option>
</select>
Pdf pg n0:60
#The <textarea> Element:
The <textarea> element defines a multi-line text input field.
The rows attribute specifies how many visible lines of text are shown.
The cols attribute specifies the visible width of the text area.
Example:
Pg no:64
#The <fieldset> and <legend> Elements
The <legend> element defines a caption or title for the grouped data inside the <fieldset>.
Example:
<fieldset>
<legend>Personal Information</legend>
<label for="name">Name:</label>
<input type="text" id="name" name="name">
</fieldset>
Pg no:64
The <datalist> Element:
The <datalist> element provides a list of predefined options for an <input> element.
The list attribute of the <input> element must reference the id of the <datalist>.
Example:
<datalist id="fruits">
<option value="Apple">
<option value="Banana">
<option value="Orange">
</datalist>
Pg : 66