selector { property: value; }
body { font-family: Arial, sans-serif; background-color: #f4f4f4; }
p { color: blue; }
.class-name { color: red; }
#id-name { color: green; }
a[href] { color: purple; }
a:hover { color: orange; }
div { width: 100px; padding: 20px; border: 10px solid black; margin: 30px; }
div { display: block; }
span { display: inline; }
img { display: inline-block; }
div { position: static; }
div { position: relative; top: 10px; }
div { position: absolute; top: 20px; }
div { position: fixed; top: 30px; }
.container { display: flex; flex-direction: row; justify-content: space-between; }
.item { flex: 1; margin: 10px; }
.container { display: grid; grid-template-columns: repeat(3, 1fr); grid-gap: 10px; }
.item { background-color: lightblue; padding: 20px; }
@media (max-width: 600px) { body { background-color: lightgreen; } }
p::before { content: "Note: "; font-weight: bold; }
button { transition: background-color 0.3s; } button:hover { background-color: blue; }
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Responsive Layout</title> <link rel="stylesheet" href="style.css"> </head> <body> <header class="container"> <div class="item">Logo</div> <nav class="item">Navigation</nav> </header> <main class="container"> <section class="item">Content</section> <aside class="item">Sidebar</aside> </main> <footer class="container"> <div class="item">Footer</div> </footer> </body> </html>
body { font-family: Arial, sans-serif; } .container { display: flex; flex-wrap: wrap; justify-content: space-between; margin: 20px; } .item { flex: 1; margin: 10px; padding: 20px; border: 1px solid #ccc; } header, footer { background-color: #f4f4f4; padding: 20px; text-align: center; }
nav { background-color: #007BFF; color: white; padding: 10px; } nav a { color: white; text-decoration: none; margin: 0 10px; } nav a:hover { text-decoration: underline; }
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Styled Form</title> <link rel="stylesheet" href="style.css"> </head> <body> <form> <label for="name">Name:</label> <input type="text" id="name" name="name" required> <label for="email">Email:</label> <input type="email" id="email" name="email" required> <label for="password">Password:</label> <input type="password" id="password" name="password" minlength="8" required> <input type="submit" value="Submit"> </form> </body> </html>
form { max-width: 600px; margin: 0 auto; padding: 20px; border: 1px solid #ccc; border-radius: 5px; } label { display: block; margin-bottom: 8px; }
input[type="text"], input[type="email"], input[type="password"] { width: 100%; padding: 8px; margin-bottom: 10px; border: 1px solid #ccc; border-radius: 4px; } input[type="submit"] { padding: 10px 15px; background-color: #007BFF; color: white; border: none; border-radius: 4px; cursor: pointer; } input[type="submit"]:hover { background-color: #0056b3; }
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Advanced CSS</title> <link rel="stylesheet" href="style.css"> </head> <body> <p>This is a paragraph with a pseudo-element.</p> <button>Hover over me!</button> </body> </html>
p::before { content: "Note: "; font-weight: bold; color: red; } button { transition: background-color 0.3s; } button:hover { background-color: blue; color: white; }
Feel free to ask any questions you have about the content covered today.
By Traversy Media.
A comprehensive overview of CSS, covering styles, selectors, and declarations. It includes a CSS cheat sheet for reference and a basic website layout tutorial using CSS3 basics.
A beginner friendly crash course on CSS animation using keyframes as well as CSS transitions. We will do a little experimenting and we will build a small animated landing page project.
Create a beautiful, custom landing page for a Travel website using HTML, CSS and a little JavaScript
Use HTML & CSS to build a mobile first layout. We will build a clone of the CVS app landing page and learn about the grid, flex, media queries and more.
Flexbox is used for space distribution, positioning and alignment in CSS.
This crash course will teach you all of the fundamentals of CSS Grid