DEV Community

S Sarumathi
S Sarumathi

Posted on

CSS Styles

- Text and Font Styles:
Used to control how text looks.
Example:

p {
  color: darkblue;             /* Text color */
  font-size: 16px;             /* Text size */
  font-family: Arial, sans-serif; /* Font type */
  font-weight: bold;           /* Bold text */
  text-align: center;          /* Align: left | right | center | justify */
  text-decoration: underline;  /* none | underline | line-through */
  text-transform: uppercase;   /* capitalize | lowercase | uppercase */
  line-height: 1.5;            /* Space between lines */
  letter-spacing: 2px;         /* Space between letters */
}

Enter fullscreen mode Exit fullscreen mode

- Box Model (Spacing and Borders)
Controls how elements are sized and spaced.
Example:

div {
  width: 200px;
  height: 100px;
  margin: 20px;          /* Space outside element */
  padding: 10px;         /* Space inside element */
  border: 2px solid black; /* Border thickness, style, color */
  border-radius: 10px;   /* Rounded corners */
}

Enter fullscreen mode Exit fullscreen mode

- Background Styles
Controls the element’s background.
Example:

body {
  background-color: lightgray;
  background-image: url('background.jpg');
  background-size: cover;       /* cover | contain */
  background-repeat: no-repeat;
  background-position: center;
}
Enter fullscreen mode Exit fullscreen mode

-Layout and Positioning
Defines where elements appear on the page.
Example:

.container {
  display: flex;           /* flex | grid | block | inline-block */
  justify-content: center; /* left-right alignment */
  align-items: center;     /* top-bottom alignment */
  position: relative;      /* static | relative | absolute | fixed | sticky */
  top: 10px;               /* moves element if positioned */
  left: 20px;
}

Enter fullscreen mode Exit fullscreen mode

-Image and Media Styles
Example:

img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  object-fit: cover;
}

Enter fullscreen mode Exit fullscreen mode

-Button Styles
Example:

button {
  background-color: #007bff;
  color: white;
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}
button:hover {
  background-color: #0056b3;
}

Enter fullscreen mode Exit fullscreen mode

-Effects and Animation
Example:

.box {
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
  transition: transform 0.3s;
}
.box:hover {
  transform: scale(1.1);
}

Enter fullscreen mode Exit fullscreen mode

Top comments (0)