HTML Cheat Sheet
HTML Cheat Sheet
Introduction to HTML
HTML stands for HyperText Markup language.
It's not a programming language but a markup language for creating web pages.
HTML creates the structure of a web page and uses “tags” to mark up a web page.
HTML Tags:
Tags are keywords surrounded by angle brackets like <tag> .
They come in pairs: opening <tag> and closing </tag> .
Example:
<h1>This is a heading</h1>
<p>This is a paragraph</p>
Editing HTML:
Use a plain text editor like Notepad.
Save files with either .htm or .html extension.
<!DOCTYPE html>
<html>
<head>
<title>My HTML Cheat Sheet</title>
</head>
<body>
<!-- Content goes here -->
</body>
</html>
2. HTML Paragraphs:
<p>This is a paragraph.</p>
3.HTML Links:
Created with <a> tag and href attribute for the link address.
Example:
4. HTML Images:
Defined with <img> tag, using src for image source, height for the height of the image, width for
the width of the image, alt defines an alternate text that displays if the image cannot be rendered.
Use % for the value of width for responsive webpage.
Example:
5. HTML Comments:
Use tags like <b> for bold, <i> for italic, <u> for underline, etc.
Example:
<b>Bold Text</b>
<i>Italic Text</i>
<u>Underline text</u>
H<sub>2</sub>0
2<sup>2</sup>
Or, we can use <Style> tag inside the <head> tag to use CSS elements.
Example:
<head>
<title>New Tab</title>
<head>
<title>Document</title>
<style>
body{
background-color: orange;
}
h1{
color: royalblue;
text-align: center;
font-family: Ink Free;
font-size: 100px;
font-style: italic;
border: 5px solid red;
}
</style>
</head>
Use <tag class="class_name"> for different styles for the same type of tags.
Use <span class="class_name"> for individual words.
For the <style> tag use .class_name{} .
Example:
<!DOCTYPE html>
<html>
<head>
<title>India</title>
<style>
body{
background-color: black;
color: white;
}
.heading_1{
font-family: cooper;
font-size: 500%;
text-align: center;
}
.a{color: orange;}
.b{color: white;}
.c{color: green;}
.heading_2{
color: blue;
}
</style>
</head>
<body>
<h1 class="heading_1">
<span class="a">I</span> <span class="b">LOVE</span> <span class="c">INDIA</span>
</h1>
<h1 class="heading_2">This is something</h1>
</body>
</html>
9. HTML Lists:
Use <ul> for unordered lists and <ol> for ordered lists.
List items are defined with <li> tag.
Use start attribute to to start from a certain number.
use type attribute to change the type of ordered or unordered lists.
Type for <ul> are: "circle" , "square" , "none"
Type for <ol> are: "a" , "A" , "i" , "I"
Example:
<table>
<tr>
<th> Course </th>
<th> Progress </th>
</tr>
<tr>
<td> HTML </td>
<td> 90% </td>
</tr>
<tr>
<td> CSS </td>
<td> 80% </td>
</tr>
<tr>
<td> JavaScript </td>
<td> 95% </td>
</tr>
</table>
Use CSS Style tag to give border to the table
Example:
<style>
table,th,td{
border: 1px solid lime;
}
</style>
<table border="1">
<tr>
<td colspan="2">Header Cell Spanning Two Columns</td>
</tr>
<tr>
<td rowspan="2">Cell Spanning Two Rows</td>
<td>Cell 1</td>
</tr>
<tr>
<td>Cell 2</td>
</tr>
</table>
In this example, the first cell spans two columns horizontally, and the second cell spans two rows
vertically.
<form>
<label>Student Name</label>
<input type="text"><hr>
<input type="text"><hr>
<label>Date of Birth</label>
<input type="date"><hr>
<label>Time of Birth</label>
<input type="time"><hr>
<label>Gender</label>
<label>Male</label>
<input type="radio" name="gender">
<label>Female</label>
<input type="radio" name="gender"><hr>
<label>Apoinment type</label><br>
<input type="checkbox">
<input type="file">
<marquee direction="right">
<img src="1.jpg" width="400px" />
<img src="2.jpg" width="400px" />
<img src="3.jpg" width="400px" />
</marquee>
Attributes like behavior , direction , scrollamount , and loop can be used to customize the
scrolling behavior.