Click on a topic to expand and learn in detail.
CSS (Cascading Style Sheets) is used to style HTML elements and make websites visually appealing.
/* Example */
body {
background-color: lightblue;
font-family: Arial, sans-serif;
}
Selectors target HTML elements to apply styles.
/* Tag selector */
p {
color: red;
}
/* Class selector */
.my-class {
font-size: 18px;
}
/* ID selector */
#my-id {
background: yellow;
}
body {
color: #333;
font-family: 'Poppins', sans-serif;
font-size: 16px;
}
h1 {
color: darkblue;
font-weight: 600;
}
/* Box model consists of: margin, border, padding, content */
div {
width: 200px;
padding: 10px;
border: 2px solid black;
margin: 15px;
}
div {
background-color: lightyellow;
border: 2px dashed green;
border-radius: 10px;
}
/* Display types: block, inline, inline-block, none */
div {
display: block;
}
/* Visibility */
p {
visibility: hidden;
}
/* Static, Relative, Absolute, Fixed, Sticky */
div {
position: relative;
top: 10px;
left: 20px;
}
.container {
display: flex;
justify-content: space-between;
align-items: center;
}
.item {
flex: 1;
}
.container {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 10px;
}
.item {
background: lightblue;
}
/* Mobile first responsive */
@media (max-width: 768px) {
.container {
grid-template-columns: 1fr;
}
}
/* Transition */
div {
transition: background 0.5s;
}
/* Animation */
@keyframes example {
from {background-color: red;}
to {background-color: yellow;}
}
div {
animation: example 3s infinite;
}