Creating a first website with CSS involves structuring your files, writing HTML to define content, and then applying CSS to style that content.
1. Project Setup:
2. HTML Structure (index.html):
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>My First CSS Website</title> <link rel="stylesheet" href="css/style.css"> </head> <body> <h1>Welcome to My Website!</h1> <p>This is my first website styled with CSS.</p> <div> <h2>About Me</h2> <p>I am learning web development.</p> </div> </body> </html> |
3. CSS Styling (css/style.css):
| body { font-family: Arial, sans-serif; background-color: #f0f0f0; color: #333; margin: 20px; } h1 { color: #0056b3; text-align: center; } div { background-color: #fff; padding: 15px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); margin-top: 20px; } p { line-height: 1.6; } |
4. Viewing Your Website: