The Ultimate Cheat Sheet for HTML and CSS

Are you tired of constantly searching for the right HTML and CSS syntax? Do you want to improve your coding skills and make your website look more professional? Look no further! We have created the ultimate cheat sheet for HTML and CSS that will make your coding experience a breeze.

What is HTML and CSS?

HTML (Hypertext Markup Language) is the standard markup language used to create web pages. It provides the structure and content of a webpage. CSS (Cascading Style Sheets) is a style sheet language used to describe the presentation of a document written in HTML. It provides the visual layout and design of a webpage.

Why use a cheat sheet?

A cheat sheet is a quick reference guide that provides a summary of important information. It saves time and helps you remember important syntax and rules. With our cheat sheet, you can easily find the syntax you need and improve your coding skills.

HTML Cheat Sheet

Basic Structure

<!DOCTYPE html>
    <title>Page Title</title>
    <h1>Heading 1</h1>

This is the basic structure of an HTML document. The <!DOCTYPE html> declaration defines the document type and the <html> element is the root element of an HTML page. The <head> element contains meta information about the document and the <title> element specifies a title for the document. The <body> element contains the visible content of the document.


<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>

Headings are used to define the hierarchy of a document. The <h1> element is the most important heading and the <h6> element is the least important heading.



The <p> element defines a paragraph.


<a href="">Link</a>

The <a> element defines a hyperlink. The href attribute specifies the URL of the page the link goes to.


<img src="image.jpg" alt="Image">

The <img> element defines an image. The src attribute specifies the URL of the image and the alt attribute provides alternative text for the image.


  <li>Item 1</li>
  <li>Item 2</li>

  <li>Item 1</li>
  <li>Item 2</li>

The <ul> element defines an unordered list and the <ol> element defines an ordered list. The <li> element defines a list item.


    <th>Header 1</th>
    <th>Header 2</th>
    <td>Row 1, Column 1</td>
    <td>Row 1, Column 2</td>
    <td>Row 2, Column 1</td>
    <td>Row 2, Column 2</td>

The <table> element defines a table. The <tr> element defines a table row. The <th> element defines a table header cell and the <td> element defines a table data cell.


  <label for="name">Name:</label>
  <input type="text" id="name" name="name">
  <label for="email">Email:</label>
  <input type="email" id="email" name="email">
  <input type="submit" value="Submit">

The <form> element defines a form. The <label> element defines a label for an input element. The <input> element defines an input field. The type attribute specifies the type of input field and the name attribute specifies the name of the input field. The <input type="submit"> element defines a submit button.

CSS Cheat Sheet

Basic Syntax

selector {
  property: value;

CSS rules consist of a selector and a declaration block. The selector selects the element(s) to apply the style to and the declaration block contains one or more declarations separated by semicolons. Each declaration consists of a property and a value.


element {
  property: value;

#id {
  property: value;

.class {
  property: value;

element.class {
  property: value;

element, element {
  property: value;

CSS selectors are used to select the element(s) to apply the style to. The element selector selects all elements of a specific type. The #id selector selects an element with a specific ID. The .class selector selects all elements with a specific class. The element.class selector selects elements of a specific type with a specific class. The element, element selector selects multiple elements.


color: value;
background-color: value;
font-size: value;
font-family: value;
text-align: value;
border: value;
padding: value;
margin: value;

CSS properties are used to define the style of an element. The color property sets the color of text. The background-color property sets the background color of an element. The font-size property sets the size of text. The font-family property sets the font family of text. The text-align property sets the alignment of text. The border property sets the border of an element. The padding property sets the padding of an element. The margin property sets the margin of an element.



CSS units are used to define the size of an element. The px unit specifies pixels. The em unit specifies the font size of the element. The rem unit specifies the font size of the root element. The % unit specifies a percentage of the parent element.


selector:hover {
  property: value;

selector:active {
  property: value;

selector:focus {
  property: value;

CSS pseudo-classes are used to define the style of an element in a specific state. The :hover pseudo-class selects an element when the mouse pointer is over it. The :active pseudo-class selects an element when it is being clicked. The :focus pseudo-class selects an element when it has focus.

Media Queries

@media screen and (max-width: 600px) {
  selector {
    property: value;

CSS media queries are used to define the style of an element based on the screen size. The @media rule specifies the media type and the and keyword specifies the media feature. The max-width media feature specifies the maximum width of the screen. The selector and properties inside the media query apply only when the screen size is less than or equal to 600px.


With our ultimate cheat sheet for HTML and CSS, you can easily find the syntax you need and improve your coding skills. Whether you are a beginner or an experienced developer, our cheat sheet is a valuable resource that will save you time and help you create professional-looking websites. So what are you waiting for? Download our cheat sheet and start coding today!

Editor Recommended Sites

AI and Tech News
Best Online AI Courses
Classic Writing Analysis
Tears of the Kingdom Roleplay
Tech Debt - Steps to avoiding tech debt & tech debt reduction best practice: Learn about technical debt and best practice to avoid it
Run MutliCloud: Run your business multi cloud for max durability
Prompt Engineering Jobs Board: Jobs for prompt engineers or engineers with a specialty in large language model LLMs
Decentralized Apps - crypto dapps: Decentralized apps running from webassembly powered by blockchain
JavaFX Tips: JavaFX tutorials and best practice