CSS (Cascading Style Sheets) is used to style and layout web pages.
It controls colors, spacing, borders, and the visual structure of HTML elements.
The text-align property is used to align text.
Values:
- left
- right
- center
- justify
Example:
p {
text-align: center;
}The display property defines how an element is displayed.
Common values:
-
block
-
inline
-
inline-block
Example:
span {
display: inline-block;
}The border property adds a border around an element.
It includes:
-
border-width
-
border-style
-
border-color
Example:
div {
border: 2px solid black;
}Margin: space outside the element
Padding: space inside the element
Example:
div {
margin: 10px;
padding: 5px;
}The box-sizing property controls how width and height are calculated.
Values:
- content-box
Width and height apply only to the content.
Padding and border increase the total size.
- border-box
Width and height include content, padding, and border.
The final size remains fixed
Example:
* {
box-sizing: border-box;
}Used to change text and background colors.
Example:
p {
color: blue;
background-color: lightgray;
}
