List of Complete CSS Properties
Below is a list of commonly used CSS properties in HTML along with their explanations and examples.
1. Background Properties
These properties control the background of elements.
Example:
body {
background-color: lightblue;
background-image: url('background.jpg');
background-repeat: no-repeat;
background-size: cover;
}
2. Text Properties
These properties control text appearance.
Example:
h1 {
color: red;
font-size: 24px;
text-align: center;
text-transform: uppercase;
}
3. Font Properties
These properties define font style and appearance.
Example:
p {
font-family: 'Arial', sans-serif;
font-size: 18px;
font-weight: bold;
}
4. Margin and Padding
These properties control spacing around elements.
Example:
div {
margin: 20px;
padding: 10px;
border: 1px solid black;
}
5. Border Properties
These properties define element borders.
Example:
div {
border: 2px solid red;
border-radius: 10px;
}
6. Box Model Properties
These define the size and layout of elements.
Example:
div {
width: 200px;
height: 100px;
padding: 10px;
margin: 20px;
}
7. Flexbox Properties
These properties help in creating flexible layouts.
Example:
.container {
display: flex;
justify-content: center;
align-items: center;
}
8. Grid Properties
These properties help in designing grid-based layouts.
Example:
.container {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 10px;
}
9. Positioning Properties
These define how elements are positioned.
Example:
div {
position: absolute;
top: 50px;
left: 100px;
}
10. Animation and Transition Properties
These add effects and animations to elements.
Example:
.button {
background-color: blue;
color: white;
padding: 10px;
transition: background-color 0.5s ease;
}
.button:hover {
background-color: red;
}
Frequently Asked Questions
What are CSS properties in HTML?
CSS properties are rules that define the appearance of HTML elements. They control aspects like colors, fonts, layouts, spacing, and animations.
Why are CSS properties important?
CSS properties enhance user experience by making web pages visually appealing, organized, and responsive across different devices.
How can I apply CSS properties in HTML?
CSS properties can be applied using inline styles, internal styles within a <style> tag, or external stylesheets linked using the <link> tag.
Conclusion
In this article, we learned CSS properties in HTML, their role in styling web pages, and how they enhance the visual presentation of elements. We discussed different types of CSS properties, including layout, typography, colors, and positioning. Understanding these properties helps developers create responsive and visually appealing websites with better user experience and design consistency.