- This topic is empty.
-
Topic
-
CSS properties are used to define the styles and layout of HTML elements. Here’s a comprehensive list of some of the most common CSS properties, categorized by their functionality:
1. Text Properties
color
: Sets the color of the text.csscolor: #333; /* Dark gray text color */
font-family
: Specifies the font to be used.cssfont-family: Arial, sans-serif; /* Font stack */
font-size
: Sets the size of the text.cssfont-size: 16px; /* Font size in pixels */
font-weight
: Defines the thickness of the text.cssfont-weight: bold; /* Bold text */
text-align
: Aligns the text within its container.csstext-align: center; /* Center-aligns text */
text-decoration
: Adds decorations to text (e.g., underline, overline).csstext-decoration: underline; /* Underlined text */
line-height
: Sets the height of a line box, affecting spacing between lines of text.cssline-height: 1.5; /* 1.5 times the font size */
letter-spacing
: Adjusts the spacing between characters.cssletter-spacing: 0.1em; /* Adds space between characters */
text-transform
: Controls capitalization of text.csstext-transform: uppercase; /* Transforms text to uppercase */
2. Box Model Properties
width
: Sets the width of an element.csswidth: 100px; /* Fixed width */
height
: Sets the height of an element.cssheight: 50px; /* Fixed height */
margin
: Defines the space outside the element’s border.cssmargin: 10px; /* Space outside the border */
padding
: Defines the space inside the element’s border.csspadding: 10px; /* Space inside the border */
border
: Sets the border around an element.cssborder: 1px solid #ccc; /* 1px solid border with light gray color */
box-sizing
: Controls how the width and height of an element are calculated.cssbox-sizing: border-box; /* Includes padding and border in the element’s total width and height */
3. Layout Properties
display
: Specifies how an element is displayed on the page.cssdisplay: block; /* Element is displayed as a block */
display: inline; /* Element is displayed as inline */
display: flex; /* Element is a flex container */
display: grid; /* Element is a grid container */
position
: Specifies the type of positioning method used for an element.cssposition: static; /* Default position */
position: relative; /*Position relative to its normal position */
position: absolute; /*Position relative to the nearest positioned ancestor */
position: fixed; /* Position relative to the viewport */
position: sticky; /* Sticky positioning */
top
,right
,bottom
,left
: Used withposition
to set the position of an element.cssposition: absolute;
top: 10px; /*Distance from the top of the positioned ancestor */
left: 20px; /* Distance from the left of the positioned ancestor */
float
: Allows elements to float to the left or right.cssfloat: left; /* Floats the element to the left */
clear
: Controls the behavior of floating elements.cssclear: both; /* Clears both left and right floats */
overflow
: Specifies what happens if content overflows an element’s box.cssoverflow: auto; /* Adds scrollbars if necessary */
overflow: hidden; /* Hides overflowing content */
4. Background Properties
background-color
: Sets the background color of an element.cssbackground-color: #f0f0f0; /* Light gray background */
background-image
: Sets an image as the background of an element.cssbackground-image: url('image.jpg'); /* Background image */
background-repeat
: Defines how a background image is repeated.cssbackground-repeat: no-repeat; /* No repetition of the background image */
background-size
: Defines the size of the background image.cssbackground-size: cover; /* Scales the background image to cover the entire element */
background-position
: Sets the initial position of a background image.cssbackground-position: center center; /* Centers the background image */
5. Flexbox and Grid Properties
- Flexbox
flex
: Defines the ability of a flex item to grow or shrink.cssflex: 1; /* Flex item grows to fill the available space */
justify-content
: Aligns flex items along the main axis.cssjustify-content: center; /* Center-aligns flex items */
align-items
: Aligns flex items along the cross axis.cssalign-items: center; /* Center-aligns flex items vertically */
- Grid
grid-template-columns
: Defines the number and size of columns in a grid.cssgrid-template-columns: repeat(3, 1fr); /* Three equal columns */
grid-template-rows
: Defines the number and size of rows in a grid.cssgrid-template-rows: 100px auto; /*
Two rows: 100px high and auto-sized */
grid-area
: Defines a grid item’s location within a grid.cssgrid-area: header; /* Places the item in the "header" area */
6. Transitions and Animations
transition
: Defines the transition effects between property changes.csstransition: all 0.3s ease; /* Smooth transition for all properties */
animation
: Defines animations using@keyframes
.css@keyframes slideIn {
from { transform: translateX(-100%); }
to{ transform: translateX(0); }
}
.animated {
animation: slideIn 0.5s ease-out;
}
7. Miscellaneous Properties
opacity
: Sets the transparency level of an element.cssopacity: 0.5; /* 50% opaque */
z-index
: Controls the stacking order of positioned elements.cssz-index: 10; /* Higher numbers are closer to the front */
cursor
: Specifies the type of cursor to be displayed.csscursor: pointer; /* Pointer cursor for clickable elements */
visibility
: Controls the visibility of an element without affecting layout.cssvisibility: hidden; /* Hides the element but still occupies space
- You must be logged in to reply to this topic.