HTML NOTES
HTML NOTES
</html>
IMPORTANT NOTES
• <head> & <body> tags are children of HTML tag.
• HTML is the parent of <head> & <body> tags.
• Most of the HTML elements have opening & closing tag with content in
between opening & closing tags.
1
2
•Some HTML tags have no content. These are called Empty elements e.g.
<br>
• We can either use .html or .html extension.
• You can use “inspect element” or “view page source” option from
Chrome to look into a website’s HTML Code.
COMMENTS IN HTML
Comments in HTML are used to mark text which should not be parsed. They can help
document the source code.
CASE SENSITIVITY
HTML is a case insensitive language. <H1> and <h1> tags are the same.
HTML ELEMENT
An HTML element consists of everything from the starting tag to the ending tag.
Example:
BR TAG
The <br> tag is used to create line breaks in an HTML document.
<br>
3
2
<big>Hello world</big>
<small>Hello world</small>
HR TAG
<hr> tag in HTML is used to create a horizontal ruler often used to separate the content.
<hr>
PRE TAG
HTML always ignores extra spaces and newlines. In order to display a piece of text as is, we
use pre tag.
<pre>
This is written.
by pre tag.
</pre>
When we use the right tag in right place, it results in a better page layout,
better indexing by search engines and better user experience.
We use the following tags to get the job done.
Inside the main tag we insert the following tags:
LINK ATTRIBUTES
<!-- Contact page opens in the same tab -->
<a href="/contact">Contact</a>
<!-- Contact page opens in a new tab -->
<a href="/contact" target="_blank">Contact us</a>
We can put any content inside an anchor tag (images, headings etc are all allowed).
If the page is inside a directory, we need to make sure that we link to the correct page
(Same applies to img tag as well.)
<div>
<h1>This is a heading inside a div.</h1>
<p>This is a paragraph inside a div.</p>
</div>
5
2
UNORDERED LIST: An unordered list is used to list items that do not have a specific order.
<ul>
<li>Home</li>
<li>About</li>
</ul>
Ordered list: An ordered list is used to list items in a specific order, typically numbered.
<ol>
<li>Phone</li>
<li>PC</li>
<li>Laptop</li> </ol>
Table: The <table> tag in HTML is used to define tables, which are used to format and
display tabular data.
We can define as many table rows as we want. To add a caption to the table, we use
<caption> tag inside table.
• <thead> tag: Used to wrap table head (caption & <tr> with <th>)
• <tbody> tag: Used to wrap the table body.
Example:
<table>
<caption>Students Report</caption>
<thead>
<tr>
<th>Name</th>
<th>Grade</th>
</tr>
</thead>
<tbody>
<tr>
<td>Rohan</td>
<td>A+</td>
</tr>
<tr>
<td>Harry</td>
<td>D</td>
</tr>
</tbody> </table>
Colspan attribute: This attribute is used to create cells spanning multiple columns.
<!-- Spans 3 Columns -->
<th colspan = "3" > Harry </th>
HTML FORM
An HTML <form> tag is used to create a form that collects input from users.
<form>
<!-- Elements of form -->
</form>
There are different form elements for different kinds of user input.
• <input> element: Can be of type text, checkbox, radio, button and submit. We
also have a ‘file’ type.
• <textarea> element: Defines a multiline text input ‘cols’ and ‘rows’ attributes
can be used to size the text area.
• <select> element: Defines a drop-down list.
7
2
EMBEDDING VIDEOS:
To embed videos in HTML, you can use the <video> tag along with various attributes to
control its behavior.
• Src: Specifies the URL of the video file (harry.mp4 in this case).
• Width: Adjusts the width of the video player. Height adjusts
automatically to maintain aspect ratio.
• Controls: Displays video controls such as play, pause, volume, etc.
• Autoplay: Automatically starts playing the video when the page loads.
• Loop: Causes the video to automatically start over from the beginning
when it reaches the end.
• Preload: Specifies whether the video should be loaded when the page
loads (auto, metadata, none).
HTML SEO
HTML developers can implement SEO using the following techniques:
1. Title Tag: Set a clear and descriptive <title> tag that accurately reflects the content
of the page.
2. Meta Description: Provide a concise summary of the page content using the <meta>
tag.
3. URL Slug: Use a clean and readable URL structure that includes relevant keywords.
4. Meta Author Tag: Optionally include the author information in a <meta> tag 5.
Favicon: Use a favicon to enhance brand recognition and usability.
6. Image Optimization: Compress images to improve page load times and include
descriptive alt attributes.
7. Optimize Resources: Remove unused HTML, CSS, and JavaScript files, and
minify/compress them to reduce page load times.
8. Semantic HTML: Use appropriate HTML tags (<header>, <nav>, <article>, <footer>,
etc.) to structure the content logically, which can improve SEO indirectly by making
the content more accessible and understandable to search engines.
<head>
<title>Example Page - SEO Best Practices</title>
<meta name="description" content="This is an example page
demonstrating SEO best practices in HTML.">
<meta name="author" content="Harry">
<link rel="icon" href="favicon.ico" type="image/x-icon">
</head>