HTML & CSS Tutorial for Beginners
1. Introduction to HTML
HTML (HyperText Markup Language) is used to structure a webpage using tags.
|
1 2 3 4 5 6 7 8 9 10 11 |
<!DOCTYPE html> <html> <head> <title>My First Webpage</title> </head> <body> <h1>Hello, World!</h1> <p>This is my first webpage.</p> </body> </html> |
2. HTML Elements & Attributes
Elements are building blocks, attributes provide extra info.
|
1 2 3 |
<a href="https://www.example.com" target="_blank">Visit Example</a> <img src="image.jpg" alt="Sample Image" width="200"> |
3. Introduction to CSS
CSS (Cascading Style Sheets) is used to style HTML elements.
|
1 2 3 4 5 |
<style> p { color: green; font-size: 16px; } h1 { text-align: center; } </style> |
4. CSS Selectors
|
1 2 3 4 5 6 7 8 9 |
/* Element */ p { color: red; } /* Class */ .highlight { background-color: yellow; } /* ID */ #main-title { font-size: 24px; } |
5. CSS Box Model
|
1 2 3 4 5 6 7 |
div { width: 200px; padding: 10px; border: 2px solid black; margin: 20px; } |
6. CSS Layouts (Flexbox & Grid)
Flexbox Example:
|
1 2 3 4 5 6 7 8 9 10 |
.container { display: flex; justify-content: space-between; } .item { width: 100px; height: 100px; background-color: lightblue; } |
Grid Example:
|
1 2 3 4 5 6 |
.grid { display: grid; grid-template-columns: 1fr 2fr 1fr; gap: 10px; } |
7. Practical Example with Live Editor
Try editing the HTML below and click Run Code to see output:
8. Responsive Design
Use media queries to make your site mobile-friendly.
|
1 2 3 4 5 |
@media (max-width: 600px) { body { font-size: 14px; } .container { flex-direction: column; } } |
9. Next Steps
- Create multiple pages for different topics (Java, Python, Tools).
- Add interactive tools like Online Java Editor, Age Calculator.
- Place AdSense ads strategically for revenue.
- Promote tutorials on social media & programming forums.