In CSS, a declaration sets a style for an element. It consists of a property (like color) and a value (like red). Each declaration ends with a semicolon.
/* Format: property: value; */ color: red; font-size: 16px;
The `font-size` property sets the size of the text. You can use units like pixels (px) or ems.
font-size: 20px;
The `background-color` property changes the background color of an element.
background-color: lightgreen;
The `!important` rule makes sure a style is applied no matter what. Use it sparingly as it can make your CSS harder to manage.
.button { background-color: orange !important; }
The `opacity` property controls how transparent an element is. Values range from 0 (completely transparent) to 1 (completely opaque).
opacity: 0.7;
The `font-weight` property controls how thick or thin the text appears. You can use keywords like `bold` or `normal`.
font-weight: bold;
The `text-align` property sets the alignment of text within its container. Options include `left`, `right`, or `center`.
text-align: center;
A CSS rule set includes a selector and style declarations. For example, `h1 { color: blue; }` sets the text color of all `h1` elements to blue.
h1 { color: blue; text-align: center; }
Use the `color` property to set the text color. You can use color names or hex codes.
p { color: #ff5733; } span { color: green; }
The `background-image` property sets an image as the background of an element. Provide the image URL inside `url()`.
background-image: url("example.jpg");
The `font-family` property specifies the font to use. You can include multiple fonts as fallback options.
h1 { font-family: Arial, sans-serif; }
CSS supports color names like `aqua` or `khaki` to set the color property.
h1 { color: aqua; } li { color: khaki; }
Welcome to our comprehensive collection of programming language cheatsheets! Whether you're a seasoned developer or a beginner, these quick reference guides provide essential tips and key information for all major languages. They focus on core concepts, commands, and functions—designed to enhance your efficiency and productivity.
ManageEngine Site24x7, a leading IT monitoring and observability platform, is committed to equipping developers and IT professionals with the tools and insights needed to excel in their fields.
Monitor your IT infrastructure effortlessly with Site24x7 and get comprehensive insights and ensure smooth operations with 24/7 monitoring.
Sign up now!