In modern web development, knowing how to efficiently build and deploy web applications is crucial. HTML and CSS form the backbone of website structure and design, while Docker streamlines deployment by containerizing applications. This cheat sheet offers essential commands, syntax, and tools to help you master HTML, CSS, and Docker for a seamless development experience.
1. HTML Cheat Sheet
HTML cheat sheet: Quick reference for tags, attributes, and structure. Includes headings, paragraphs, links, images, forms, lists, and more. It uses a system of elements enclosed in tags to organize and present content.
Common HTML Tags
Tag | Description | Example |
<html> | Root of an HTML document | <html lang=”en”> |
<head> | Contains meta-information | <head><title>Page</title></head> |
<body> | Contains the content of the webpage | <body>Content here</body> |
<h1> to <h6> | Heading tags, from largest to smallest | <h1>Main Title</h1> |
<p> | Paragraph text | <p>This is a paragraph.</p> |
<a> | Hyperlink | <a href=”url”>Link</a> |
<img> | Image | <img src=”image.jpg” alt=”Image”> |
<ul>, <ol> | Unordered/Ordered lists | <ul><li>Item</li></ul> |
<div> | Division or section | <div>Content</div> |
<form> | Form for user input | <form>…</form> |
Attributes
- href: Specifies the URL for links.
- src: Specifies the source for images and media.
- alt: Provides alternative text for images.
- class: Assigns CSS classes for styling.
- id: Unique identifier for an element.
2. CSS Cheat Sheet
CSS cheat sheet: A quick guide for styling HTML with selectors, properties, and values. Covers colors, fonts, margins, paddings, borders, layouts, flexbox, grid, positioning, and responsive design techniques.
Basic Syntax
selector {
property: value;
}
Common Selectors and Properties
Selector | Example | Description |
* | * { margin: 0; } | Targets all elements |
.class | .btn { color: blue; } | Targets elements by class |
#id | #header { font-size: 20px; } | Targets elements by ID |
element | p { line-height: 1.5; } | Targets specific tags |
Common CSS Properties
Property | Usage | Example |
color | Text color | color: red; |
background | Background color or image | background: #fff; |
margin | Space outside an element | margin: 10px; |
padding | Space inside an element | padding: 15px; |
font-family | Font type | font-family: Arial, sans-serif; |
display | Layout type | display: flex; |
position | Element positioning | position: absolute; |
z-index | Layering elements | z-index: 10; |
Box Model
- Content: The actual content inside an element.
- Padding: Space between content and border.
- Border: Surrounds padding and content.
- Margin: Space outside the border.
3. Docker Cheat Sheet
Using the Docker cheat sheet, developers can package applications and their dependencies into containers that can be run on different machines. These containers ensure consistency across different environments.
Common Docker Commands
Command | Description |
docker pull <image> | Download an image from Docker Hub. |
docker build -t <name> . | Build an image from a Dockerfile. |
docker run <image> | Run a container from an image. |
docker ps | List running containers. |
docker stop <container> | Stop a running container. |
docker rm <container> | Remove a stopped container. |
docker exec -it <container> | Run a command inside a running container. |
docker-compose up | Start services defined in a Docker Compose file. |
docker-compose down | Stop and remove containers and networks. |
Dockerfile Basics
A Dockerfile defines how to build a Docker image:
- FROM: Base image.
- COPY: Copies files into the container.
- RUN: Executes commands.
- CMD: Sets the default command to run the container.
Example Dockerfile (for a simple HTML project):
FROM nginx:alpine
COPY . /usr/share/nginx/html
Using Docker for HTML and CSS Development
Docker can help you create isolated environments for your web projects. For example:
- Set Up: Use Docker to pull a lightweight web server like Nginx.
- Develop: Place your HTML and CSS files in the appropriate directory.
- Run: Use docker-compose to run your project locally.
Conclusion
This cheat sheet provides a quick reference to essential HTML tags, CSS properties, and Docker commands. Mastering these tools allows you to efficiently design, style, and deploy web applications in a consistent environment. For hands-on practice, try building a simple HTML/CSS project and running it in a Docker container using the commands outlined here.