CSS Basics
ยท One min read
CSS is what makes websites colorful, big, small, pretty, and fun.
HTML builds the house ๐ โ CSS paints and decorates it ๐จ.
Exampleโ
body {
font-family: Arial, sans-serif;
background-color: #f5f5f5;
}
h1 {
color: #2c3e50;
}
๐งช Exerciseโ
-
Create
style.css -
Change:
- Background color
- Font size
- Text color
-
Link CSS to HTML
<link rel="stylesheet" href="style.css" />
โ Goal: Learn separation of structure and style
If you want to learn other concepts in CSS, below is the link from MDN.
MDN CSS Tutorials โ structured from beginner basics to advanced topics, with examples and explanations. CSS Tutorials (MDN) https://developer.mozilla.org/en-US/docs/Web/CSS/Tutorials
Box Example
Live Editor
<> <div style={{ backgroundColor: "orange", padding: "20px", border: "2px solid black", width: "200px", textAlign: "center" }} > I am a box </div> </>
Result
Loading...
Button Hover Example
Live Editor
<> <button style={{ backgroundColor: "green", color: "white", padding: "10px 20px", border: "none", cursor: "pointer" }} onMouseOver={e => e.target.style.backgroundColor = "orange"} onMouseOut={e => e.target.style.backgroundColor = "green"} > Hover Me </button> </>
Result
Loading...