HTML Cheatsheet


Introduction

Hyper Text Markup Language also Know as HTML is used to create Web Pages or Websites. It is developed by Tim Berners-Lee in 1993. It is a service which runs Web Pages.

- Text Editiors: NotePad, Notepad++, Sublime Text, VS Code etc.

- Output: On any web browser.

- Extension: Save into .html or .htm

HTML Tags:

There are two types of tags in HTML

1. Paired Tags: Which starts and close. Like <html> </html>, <a> </a>

2. Unpaired Tags: Which starts but don't close. Like <br> <hr>, <img>

Boiler Plate Code:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CodeX</title>
</head>
<body>
    <h1>CodeX</h1>
</body>
</html>
Comment Tag
 <!-- This is comment. Code or Text in comment won't appear in brower. -->
Anchor Tag
<a href="About.html">About Us</a>
                    
<a href="https://www.facebook.com/" target="_blank">Go to facebook</a>
                    
<a href="https://www.facebook.com/" title="Click here to open facebook">Open facebook</a>
        
<a href="#">Go to Top</a>
        
<a href="images/photo.jpg" download="photo" hreflang="en">Download Here</a>
        
<p> <a href="#computer">Computer</a> </p>
<p> <a href="#laptop">Laptop</a> </p>
        
<h1> <a name="computer">Computer</a> </h1>
<h1> <a name="laptop">Laptop</a> </h1>
Abbr Tag (Abbreviation Tag)
<abbr title="Pen Drive">PD</abbr>
Acronym Tag (Abbreviation Tag)
<acronym title="United Kingdom">UK</acronym>
Address Tag
<address>
    Author: Sher Khan Baloch.
    <a href="mailto: admin@codex.com">Email: admin@codex.com</a>
    Visit us at: <a href="https://www.sherkhanbaloch.com">www.sherkhanbaloch.com</a>
</address>
Article Tag
<article style="width: 300px; border: 2px solid gray; padding: 10px; border-radius: 10px; margin: 20px;">
    <img src="img/img.jpeg" alt="article-image">
    <h1>This is article heading.</h1>
    <p>this is article paragraph.</p>
    <time> 11/07/2021 02:31 PM</time>
    <address>Author: Sher Khan Baloch.</address>
</article>
Area Tag
<img src="img/image.jpeg" usemap="#universe" alt="">
<map name="universe">
    <area shape="ract" coords="left, top, right, bottom" href="saturn.html" title="Click Me To See Saturn Info:" alt="">
</map>
Aside Tag
<aside style="width: 25px; float: left; background-color: gray; color: white; padding: 10px;">
    <h1>This is aside heading.</h1>
    <p>This is aside paragraph.</p>
</aside>
Audio Tag
<audio controls autoplay>
    <source src="Song.mp3" type="audio/mp3">
</audio>
                
<audio controls loop>
    <source src="Song.mp3" type="audio/mp3">
</audio>
                
<audio controls muted>
    <source src="Song.mp3" type="audio/mp3">
</audio>
                
<audio controls preload="auto">
    <source src="Song.mp3" type="audio/mp3">
</audio>
Bold Tag
<b> This Is Bold Line.</b>
Base Tag
<!-- Use This Code In Head Tag -->
<base href="Media\Images\">
        
<!-- Use This Code In Body Tag -->
<img src="img.jpeg" alt="">
Bdo Tag
<bdo dir="auto">This is Auto Direction BDO Tag.</bdo>

<bdo dir="ltr">This is Left To Right Direction BDO Tag.</bdo>

<bdo dir="rtl">This is Right To Left Direction BDO Tag.</bdo>
Blockquote Tag
<!-- To Know From Article Is Taken. -->
<blockquote cite="articleLocation">
    <h2>Heading.</h1>
    <p>Paragraph.</p>
</blockquote>
Body Tag
<body bgcolor="gray">;  </body> <!-- Background Color of Complete Webpage. -->
                        
<body background="img/image.jpeg"> </body> <!-- Background Image of Complete Webpage. -->
                        
<body text="red">  </body> <!-- Text Color of Complete Webpage. -->
                        
<body link="green">  </body> <!-- Link Color of Complete Webpage. -->
                        
<body vlink="yellow">  </body> <!-- Visited Link Color of Complete Webpage. -->
                        
<body alink="blue">  </body>; <!-- Active Link Color of Complete Webpage. -->
Button Tag
<button type="button" name="button" onclick="alert('Thanks For Joining Us.')"> Click Me </button>
                    
<button type="submit" name="submit"> This is Submit Button </button>
                    
<button type="reset" name="reset"> This Is Reset Button </button>

<button type="button" disabled> This is disabled Button </button>

<button type="button" accesskey="r"> ALT + R is shortcut for this button  </button>
Caption Tag
<table>
    <caption> This is table caption. </caption>
</table>
Cite Tag
<p> <cite>CodeX</cite> By Sher Khan Baloch.</p>
Code Tag
<p>This is JavaScript Code.
    <code>
        var a = 5;
            function myFunc(){
                Console.log(a);
            }
    </code>
</p>
Col Tag (For More Columns)
<table>
    <caption>This is caption.</caption>
    <colgroup>
        <col span="1" style="background-color: red;">
    </colgroup>
</table>
Colgroup Tag (For Few Columns)
<table>
    <caption>This is caption.</caption>
    <colgroup span="1" style="background-color: red;"> </colgroup>
</table>
Data Tag
<!-- Show Different Value To Front Page and Server. -->
<ul>
    <li>
        <data value="101">Hair Oil</data>
    </li>
</ul>
Datalist Tag
<input list="cities">
<datalist id="cities">
    <option value="Larkana"></option>
    <option value="Karachi"></option>
    <option value="Lahore"></option>
    <option value="Islamabad"></option>
</datalist>
<input type="submit" value="Submit">
DD Tag (Definition)
<dl>
    <dt>Computer</dt>
    <dd>Computer is an electronic machine which receive input, process it, give output and store it.</dd>
</dl>
Del Tag (Delete)
<p>We will go to the <del cite="Karachi is so far from here." datetime="01-08-2024 10:52:00">Karachi</del>
    <ins>Larkana</ins>
</p>
Details, Summary Tag
<details open>
    <summary>Computer</summary>
    <p>Computer is an electronic machine which receive input, process it, give output and store it.</p>
</details>
DFN Tag (Definition)
<!-- Preview In Italic -->
<p>I am <dfn title="Sher Khan Baloch">SKB</dfn></p>
Dialog Tag (Pop Box)
<dialog open>Welcome</dialog>
<p>This is Paragraph</p>
Div Tag (Division)
<!-- Most Important, Valuable, and Main Tag For Building Websites. -->
<div>
    <p>Welcome To CodeX</p>
</div>
I and EM Tag
<em>HTML</em>
<i>Markup Language</i>
Embed Tag (Multi-Media)
<embed src="Video.mp4" type="video/mp4" width="500px">
Fieldset, Legend Tag
<fieldset>
    <legend>Personal Information:</legend>
</fieldset>
Figure, Figcaption Tag
<figure>
    <img src="Moen-Jo-Daro.jpeg" alt="Moen-Jo-Daro-Image" width="100%">
    <figcaption>Moen Jo Daro, Larkana, Sindh, Pakistan</figcaption>
</figure>
Form Tag
<form action="Thank.html" name="login-form" method="post" autocomplete="on" novalidate>
    First Name: <input type="text">
    Last Name: <input type="text">
    <input type="submit" value="Submit">
</form>
HR Tag
<p>First Paragraph</p>
<hr>
<p>Second Paragraph</p>
<hr>
<p>Third Paragraph</p>
iFrame Tag With Sandbox
<!-- Sandbox: Used For The Restrictions -->
<iframe src="Gallery.html" width="400px" name="myFrame" sandbox="allow-same-origin"></iframe>

<iframe src="Gallery.html" width="400px" name="myFrame" sandbox="allow-scripts"></iframe>

<iframe src="Gallery.html" width="400px" name="myFrame" sandbox="allow-top-navigation"></iframe>

<iframe src="Gallery.html" width="400px" name="myFrame" sandbox="allow-popups"></iframe>

<iframe src="Gallery.html" width="400px" name="myFrame" sandbox="allow-forms"></iframe>
Img Tag With Srcset
<img src="Image.jpeg" width="300px" alt="Alternative-Text">

<img src="Image.jpeg" width="300px" alt="Alternative-Text" longdesc="Long Description">
                        
<img src="Image.jpeg" width="300px" alt="Alternative-Text" width="300px" longdesc="Long Description" ismap>
                        
<img src="Image.jpeg" width="300px" alt="Alternative-Text" width="300px" longdesc="Long Description" ismap sizes="">
                        
<img src="Image.jpeg" width="300px" alt="Alternative-Text" width="300px" longdesc="Long Description" ismap sizes="" crossorigin="anonymous">
                        
<img src="Image.jpeg" width="300px" alt="Alternative-Text" width="300px" longdesc="Long Description" ismap sizes="" crossorigin="anonymous" usemap="">
                        
<img src="Image.jpeg" style="width: 100%;" alt="" srcset="image.jpeg 500w, image2.jpeg 1000w, image3.jpeg 1500w">
Input Tag
<!-- For Simple Text -->
<input type="text" name="" id="" autofocus required size="5">
                            
<!-- For Insert Email -->
<input type="email" name="" id="" placeholder="Enter Your Email" required>
                            
<!-- For Insert Password -->
<input type="password" name="" id="" maxlength="20" required>
                            
<!-- For Insert Telephone No: -->
<input type="tel" name="" id="">
                            
<!-- For Date and Time -->
<input type="date" name="" id="">
                            
<!-- For MCSQs, Gender or Else -->
<input type="radio" name="" id="">
                            
<!-- For Check Box -->
<input type="checkbox" name="" id="" checked>
                            
<!-- For Submit Button -->
<input type="submit" name="" id="">
                            
<!-- For Insert Time -->
<input type="time" name="" id="">
                            
<!-- For Inserting Date and Time Both -->
<input type="datetime-local" name="" id="">
                            
<!-- For Choosing Color -->
<input type="color" name="" id="">
                            
<!-- For Choosing File -->
<input type="file" name="" id="" multiple>
                            
<!-- For Only Selecting Images -->
<input type="file" name="" id="" accept="image/*">
                            
<!-- For Inserting Number With Validation -->
<input type="number" name="" id="" min="1" max="100" step="5">
                            
<!-- For Inserting Number But With Bar -->
<input type="range" name="" id="" min="1" max="100">
                            
<!-- For Searching -->
<input type="search" name="" id="">
                            
<!-- For Inserting URL -->
<input type="url" name="" id="">
                            
<!-- For Reset Button -->
<input type="reset" name="" id="">
                            
<!-- For Send Image On Submit -->
<input type="image" name="" id="" src="Image.jpeg">
                            
<!-- For Long Description or Message -->
<textarea name="" id="" cols="40" rows="20"></textarea>
Label Tag
<form action="">
    Gender:
    <label for="male">Male</label>
    <input type="radio" name="gender" id="male">
                    
    <label for="female">Female</label>
    <input type="radio" name="gender" id="female">
</form>
Ul, Ol, Li Tag
<!-- Unordered List -->
<ul>
    <li>HTML</li>
    <li>CSS</li>
    <li>JavaScript</li>
    <li>PHP</li>
</ul>
                        
<!-- Ordered List -->
<ol type="1" start="10" reversed>
    <li>C++</li>
    <li>Java</li>
    <li>SQL</li>
    <li>C#</li>
</ol>
Main Tag
<main>
    <h2>Heading</h2>
    <section>This is Section.</section>
    <p>This is Paragraph Inside Main.</p>
</main>
Mark Tag
<p>I am Sher Khan Baloch <mark>Founder of CodeX</mark> </p>
Meter and Progress Tag
Temperature: <meter low="20" high="80" min="0" max="100" value="75" optimum="50">75 C</meter>

Downloading: <progress value="30" max="100"></progress>
Noscript Tag
<script type="text/javascript">
    document.write("CodeX");
</script>
                    
<noscript>Sorry Your Browser Does Not Support JavaScript</noscript>
Object Tag
<object data="Intro.mp4" type="video/mp4" width="400px" height="400px" name="CodeX Intro"></object>
Select, Optgroup, Option Tag
<select name="" id="" multiple disabled>
    <optgroup label="Laptops">
        <option value="">Dell</option>
        <option value="" selected>HP</option>
        <option value="">Lenovo</option>
        <option value="">Asus</option>
    </optgroup>
</select>
Meta Tag (Used For SEO)
<head>
    <meta charset="UTF-8">
    <meta name="description" content="CodeX provide Free Code, Snippets, Cheatsheets, Projects, Notes">
    <meta name="keywords" content="Web Desgin, Computer Programming, Coding, Web Development">
    <meta name="author" content="Sher Khan Baloch">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="refresh" content="5">
    <meta name="robots" content="Index, Follow">
    <title>CodeX</title>
</head>
Picture and Source Tag
<picture>
    <source media="(min-width: 650px)" srcset="Image1.jpeg">
    <source media="(min-width: 465px)" srcset="Image2.jpeg">
    <img src="Image.jpeg" alt="">
</picture>
Pre Tag
<!-- Custom Writing Style. This Tag Accepts Spaces Unlike <P> Tag. -->
<pre>
To
            The Head of Campus
            SZABIST University Larkana Campus
Subject:    Request For Adding Pre Tag In HTML Cheatsheet.
Respected Concern,
            We would like to add this tag in our HTML Cheatsheet in CodeX.    
</pre>
Ruby, Rt, Rb Tag
Hello! I am
<ruby>
    <rb>SKB</rb>
    <rt>Sher Khan Baloch</rt>
</ruby>
Section Tag (Best For SEO)
<section>
    <h2>Heading</h2>
    <p>Paragraph</p>
</section>
Script Tag
<head>
    <script type="text/javascript">
        document.write("This CodeX is written using JavaScript.");
    </script>
                        
    <script src="script.js" async="true"></script>
    
    <script src="script.js" defer="true"></script>
</head>
Span Tag
<p>Welcome To My Website <span style="background-color: maroon; color: white;">CodeX</span> </p>
Style Tag
<head>
    <style type="text/css">
    h2 {
        color: red;
            font-size: 45px;
        }     
        p {
            color: green;
            font-size: 30px;
        }
    </style>
    
    <style type="text/css" media="print">
        h2 {
            color: white;
            background-color: gray;
            font-size: 45px;
        }
        p {
            color: black;
            font-size: 30px;
        }
    </style>
        
    <style type="text/css" media="screen and (max-width: 500px)">
        h2 {
            color: red;
            background-color: white;
            font-size: 50px;
        }        
        p {
            color: red;
            font-size: 40px;
        }
    </style>
</head>
Sub and Sup Tag
<!-- Super Script -->
<p>I am in Class 2<sup>nd</sup></p>
                        
<!-- Sub Script -->
<p>Water Formula Is: H<sub>2</sub>O</p>
SVG Tag
<svg width="100" height="100" style="border: 1px solid green;">
    <circle cx="50" cy="50" r="40" fill="yellow" stroke="red" stroke-width="5"></circle>
</svg>
                    
<svg width="100" height="100" style="border: 1px solid green;">
    <rect rx="10" x="10" y="10" width="80" height="80" fill="yellow" stroke="red" stroke-width="5"></rect>
</svg>
Table Tag
<head>
    <style type="text/css">
        table,
        th,
        td {
            border: 1px solid black;
            border-spacing: 1px;
        }
    </style>
</head>
                    
<body>
    <!-- 
        th = Table Heading
        tr = Table Row
        td = Table Data / Column
        Rowspan = Row Merge
        Colspan = Column Merge
    -->

    <table>
        <thead>
            <tr>
                <th>ID</th>
                <th>Item</th>
                <th>Rate</th>
                <th>Remarks</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>01</td>
                <td>Computer</td>
                <td>100</td>
                <td rowspan="3">Rows Merged</td>
            </tr>
            <tr>
                <td>02</td>
                <td>Laptop</td>
                <td>200</td>
            </tr>
            <tr>
                <td>03</td>
                <td>Tablet</td>
                <td>300</td>
            </tr>
        </tbody>
        <tfoot>
            <tr>
                <td colspan="2">Grand Total</td>
                <td>600</td>
            </tr>
        </tfoot>
    </table>
</body>
Video Tag
<video width="500px" poster="Image.jpeg" controls autoplay loop muted preload="auto">
    <source src="Footage.mp4" type="video/mp4">
</video>
                    
<video width="500px" src="Footage.mp4" poster="Image.jpeg" controls autoplay loop muted preload="auto"></video>
Shortcut Icon
<head>
    <title>CodeX</title>
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
</head>
Marquee Tag
<marquee behavior="scroll">
    <h2>This is Behavior attribute with Scroll </h2>
</marquee>
                    
<marquee behavior="alternate">
    <h2>This is Behavior attribute with Alternate </h2>
</marquee>
                    
<marquee behavior="slide">
    <h2>This is Behavior attribute with Slide </h2>
</marquee>
                    
<marquee direction="right">
    <h2>This is Direction attribute with Right </h2>
</marquee>
                    
<marquee direction="left">
    <h2>This is Direction attribute with left </h2>
</marquee>
                    
<marquee direction="up">
    <h2>This is Direction attribute with Up </h2>
</marquee>
                    
<marquee direction="down">
    <h2>This is Direction attribute with down </h2>
</marquee>
                    
<marquee scrollamount="50">
    <h2>This is Scrollamount (Speed Control) attribute with 50</h2>
</marquee>
                    
<marquee bgcolor="aqua">
    <h2>This is Bgcolor attribute with Aqua</h2>
</marquee>
                    
<marquee bgcolor="aqua" height="150">
    <h2>This is Height attribute with 150</h2>
</marquee>
                    
<marquee bgcolor="aqua" width="250">
    <h2>This is width attribute with 250</h2>
</marquee>
                    
<marquee loop="3">
    <h2>This is Loop attribute with 3</h2>
</marquee>
                    
<marquee scrolldelay="3">
    <h2>This is ScrollDelay attribute with 3</h2>
</marquee>
                    
<marquee bgcolor="aqua" hspace="50">
    <h2>This is HSpace attribute with 50</h2>
</marquee>
                    
<marquee bgcolor="aqua" vspace="50">
    <h2>This is VSpace attribute with 50</h2>
</marquee>
                    
<marquee bgcolor="aqua" onmouseover="this.stop()">
    <h2>This is OnMouseOver attribute with this.stop() (JavScript)</h2>
</marquee>
                    
<marquee bgcolor="aqua" onmouseover="this.stop()" onmouseout="this.start()">
    <h2>This is OnMouseOut attribute with this.start() (JavScript)</h2>
</marquee>