Skip to content

Latest commit

 

History

History
117 lines (79 loc) · 1.45 KB

File metadata and controls

117 lines (79 loc) · 1.45 KB

CSS Notes

What is CSS?

CSS (Cascading Style Sheets) is used to style and layout web pages.
It controls colors, spacing, borders, and the visual structure of HTML elements.


Text Align

The text-align property is used to align text.

Values:

  • left
  • right
  • center
  • justify

Example:

p {
  text-align: center;
}

Display

The display property defines how an element is displayed.

Common values:

  • block

  • inline

  • inline-block

Example:

span {
  display: inline-block;
}

Border

The border property adds a border around an element.

It includes:

  • border-width

  • border-style

  • border-color

Example:

div {
  border: 2px solid black;
}

Margin and Padding

Margin: space outside the element

Padding: space inside the element

Example:

div {
  margin: 10px;
  padding: 5px;
}

Box Sizing

The box-sizing property controls how width and height are calculated.

Values:

  • content-box

content-box box model

Width and height apply only to the content.
Padding and border increase the total size.

  • border-box

border-box box model

Width and height include content, padding, and border.
The final size remains fixed

Example:

* {
  box-sizing: border-box;
}

Colors

Used to change text and background colors.

Example:

p {
  color: blue;
  background-color: lightgray;
}