<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>CSS Selectors</title> <style> h1 { color: blue; } /* Element Selector */ .highlight { background-color: yellow; } /* Class Selector */ #main { font-size: 20px; } /* ID Selector */ a:hover { color: red; } /* Pseudo-class */ </style> </head> <body> <h1>Welcome to CSS</h1> <p id="main">This is an introduction to CSS.</p> <p class="highlight">This text has a yellow background.</p> <a href="#">Hover over me</a> </body> </html>
2. Box Model Theory:
Every element in CSS is a rectangular box consisting of:
Content: The actual text or image
Padding: Space around the content Border: The outline of the box Margin: Space between elements Example Web Page: <!DOCTYPE html> <html> <head> <title>CSS Box Model</title> <style> .box { width: 300px; padding: 20px; border: 5px solid black; margin: 10px; background-color: lightblue; } </style> </head> <body> <div class="box">This is a box with padding, border, and margin.</div> </body> </html>
3. Flexbox Theory:
Flexbox makes it easy to align items in one-dimensional layouts. Important properties:
display: flex; (Enables flex container)
justify-content: (flex-start, center, space-between) align-items: (stretch, center, flex-start)
(Ebook) Responsive Web Design with HTML5 and CSS3 Second Edition by Ben Frain ISBN 9781784398934, 1784398934 - Quickly download the ebook to explore the full content