Use -CSS Display and Positioning and Use CSS Box Model
Use -CSS Display and Positioning and Use CSS Box Model
1. Fonts
CSS allows you to style text by changing the font type, size, and style.
Properties:
o font-family: Sets the type of font (e.g., Arial, Times New Roman).
o font-size: Adjusts the size of the text (e.g., 16px, 1em).
o font-style: Makes text italic or normal.
o font-weight: Controls the boldness (e.g., normal, bold).
Example:
h1 {
font-size: 24px;
font-weight: bold;
font-style: italic;
2. Text
Properties:
o text-align: Aligns text (e.g., left, center, right).
o text-transform: Changes the case (e.g., uppercase, lowercase, capitalize).
o line-height: Adjusts spacing between lines.
o letter-spacing: Changes spacing between letters.
Example:
p{
text-align: justify;
text-transform: uppercase;
letter-spacing: 2px;
}
Properties:
o color: Changes the text color.
o background-color: Changes the background color.
o Colors can be defined using names, hex codes, RGB, or HSL values.
Example:
body {
color: #333333;
background-color: #f0f0f0;
4. Opacity
Property:
o opacity: Ranges from 0 (completely invisible) to 1 (fully visible).
Example:
div {
5. Background Image
Properties:
o background-image: Sets the image (e.g., url('image.jpg')).
o background-size: Adjusts how the image fits (e.g., cover, contain).
o background-repeat: Repeats the image (e.g., no-repeat, repeat).
o background-position: Sets the position (e.g., center, top).
Example:
div {
background-image: url('background.jpg');
background-size: cover;
background-repeat: no-repeat;
background-position: center;
}
The CSS Box Model is a fundamental concept in web design. Every element on a webpage is
treated as a box with the following parts:
Content, Padding, Border, and Margin.
Example:
div {
width: 200px;
height: 100px;
background-color: lightblue;
2. Borders
Example:
div {
3. Border Radius
Example:
div {
border-radius: 10px;
4. Padding
Example:
div {
5. Margin
div {
6. Visibility
Example:
div {
7. Auto
Example:
div {
width: 50%;