Sunday, February 5, 2023

Basic class of CSS (Cascading Style Sheets)

 


CSS (Cascading Style Sheets) is a stylesheet language used for describing the look and formatting of a document written in HTML or XML. Here are some basic concepts and examples to get you started with CSS:


Selectors: CSS selectors are used to select the elements on a web page that you want to style. Selectors can be tag names, class names, or ID values.

Example:


css

Copy code

h1 {

  color: blue;

  text-align: center;

}


.highlight {

  background-color: yellow;

}


#header {

  background-color: gray;

  height: 50px;

}

Properties: CSS properties define the styles for the selected elements. Some common properties include color, background-color, font-size, text-align, and display.

Example:


css

Copy code

p {

  font-size: 16px;

  color: green;

  text-align: justify;

}


button {

  background-color: red;

  color: white;

  padding: 10px 20px;

  border: none;

}

Box model: Every HTML element is a rectangular box with content, padding, borders, and margins. Understanding the box model is essential for creating well-designed web pages.

Example:


css

Copy code

div {

  width: 300px;

  padding: 20px;

  border: 2px solid black;

  margin: 20px;

}

Cascade and inheritance: CSS uses the "cascade" to determine which styles apply to an element, and "inheritance" to pass styles down to child elements.

Example:


css

Copy code

body {

  font-family: Arial;

}


p {

  font-size: 16px;

  color: blue;

}


.highlight {

  color: yellow;

  font-weight: bold;

}


<body>

  <p>This is a paragraph.</p>

  <p class="highlight">This is a highlighted paragraph.</p>

</body>

These are just a few of the basics of CSS. To learn more, I recommend reading the official CSS documentation and practicing on your own web pages.

#CSS (Cascading Style Sheets) #Cascading Style Sheets #Web Pages #Computing



No comments:

Post a Comment

Benefits of Fasting

Fasting is the practice of abstaining from food or drink for a period of time. While it has traditionally been associated with spiritual or ...