The Front-End
CSS
Styling Properties

Styling Properties

CSS (Cascading Style Sheets) styling properties allow you to control the presentation and layout of HTML elements. Here's a brief introduction to some essential CSS styling properties, taking into consideration the principles of reusability, uniqueness, JavaScript interactions, and specificity:

  1. Color Properties
  2. Font Properties
  3. Text Properties
  4. Spacing Properties
  5. Border Properties
  6. Display Properties
  7. Positioning Properties
  8. Flexbox Properties
  9. Media Queries

Color Properties

color

Defines the text color.

body {
  color: #333; /* Hex color code */
}
 
h1 {
  color: rgb(255, 0, 0); /* RGB color */
}
 
a {
  color: teal; /* Named color */
}

background-color

Defines the background color.

body {
  background-color: #f0f0f0;
}
 
.button {
  background-color: #3498db;
  color: white;
}

Font Properties

font-family

Defines the font for the text.

body {
  font-family: 'Arial', sans-serif;
}
 
.heading {
  font-family: 'Helvetica', sans-serif;
}

font-size

Defines the size of the text.

p {
  font-size: 16px;
}
 
h2 {
  font-size: 24px;
}

font-weight

Defines the weight of the text.

h1 {
  font-weight: bold;
}
 
h2 {
  font-weight: normal;
}

Text Properties

text-align

Defines the horizontal alignment of the text.

h1 {
  text-align: center;
}
 
.footer {
  text-align: right;
}

text-decoration

Defines the decoration of the text.

a {
  text-decoration: none;
}
 
.underline {
  text-decoration: underline;
}

text-transform

Defines the capitalization of the text.

h1 {
  text-transform: uppercase;
}
 
h2 {
  text-transform: lowercase;
}

Spacing Properties

margin and padding

Controls the outer and inner spacing of an element.

.box {
  margin: 10px; /* Shorthand for setting all margins */
  padding: 20px; /* Shorthand for setting all paddings */
}
 

lineheight

Controls the height of a line of text.

p {
  line-height: 1.5;
}
 
.header {
  line-height: 2;
}

Border Properties

border

Specifies the width, style, and color of an element's border.

.box {
  border: 1px solid #ccc; /* Shorthand for setting all border properties */
}
 

border-radius

Specifies the radius of an element's border.

.card {
  border-radius: 10px;
}

Display Properties

display

Specifies the display behavior of an element.

.inline-block {
  display: inline-block;
}
 
.hidden {
  display: none;
}

Positioning Properties

position

Specifies the positioning behavior of an element.

.absolute {
  position: absolute;
  top: 0;
  left: 0;
}
 
.fixed {
  position: fixed;
  top: 0;
  left: 0;
}

float

Specifies the floating behavior of an element. Specifies whether an element should be placed to the left or right of its container, allowing other elements to wrap around it.

.image {
  float: left;
  margin-right: 10px;
}

Flexbox Properties

display: flex

Flexbox is a powerful layout model that simplifies the design of complex layouts. Enables the flexbox layout.

.container {
  display: flex;
  justify-content: space-between; /* Align items with space between them */
}

flex

Specifies the flex grow, flex shrink, and flex basis of an element.

.item {
  flex: 1; /* Flex-grow, flex-shrink, and flex-basis combined */
}

flex-direction

Specifies the direction of the flex items.

.container {
  flex-direction: row; /* Horizontal */
}
 
.container {
  flex-direction: column; /* Vertical */
}

flex-wrap

Specifies whether the flex items should wrap or not.

.container {
  flex-wrap: wrap; /* Wrap */
}
 
.container {
  flex-wrap: nowrap; /* No wrap */
}

justify-content

Specifies the alignment of the flex items.

.container {
  justify-content: flex-start; /* Left */
}
 
.container {
  justify-content: flex-end; /* Right */
}
 
.container {
  justify-content: center; /* Center */
}
 
.container {
  justify-content: space-between; /* Space between */
}
 
.container {
  justify-content: space-around; /* Space around */
}

align-items

Specifies the alignment of the flex items.

.container {
  align-items: flex-start; /* Top */
}
 
.container {
  align-items: flex-end; /* Bottom */
}
 
.container {
  align-items: center; /* Center */
}

align-content

Specifies the alignment of the flex lines.

.container {
  align-content: flex-start; /* Top */
}
 
.container {
  align-content: flex-end; /* Bottom */
}
 
.container {
  align-content: center; /* Center */
}
 
.container {
  align-content: space-between; /* Space between */
}
 
.container {
  align-content: space-around; /* Space around */
}

Media Queries

Media queries allow you to apply different styles based on the device's screen size. This is useful for creating responsive web pages that look good on all devices.

@media (max-width: 600px) {
  .container {
    flex-direction: column;
  }
}

These are just some of the fundamental CSS properties. Understanding and mastering these properties will give you a solid foundation for styling and laying out web pages. As you become more comfortable with these basics, you can explore more advanced properties and techniques to enhance your styling skills.