In CSS, a declaration is a key-value pair that sets the style of an HTML element. Each declaration consists of a CSS property (the "key") and a value, separated by a colon. Declarations are terminated with a semicolon and are used to apply styles to elements or groups of elements.
/* CSS declaration format */ property-name: value; /* Example CSS declarations */ text-align: center; color: purple; width: 100px;
The font-size property in CSS controls the size of the text. Font sizes can be set using various units, such as pixels (px), ems, rems, percentages, and more.
font-size: 30px;
The background-color property sets the background color of an HTML element.
background-color: blue;
The !important rule in CSS is used to override any other styles for a property, regardless of specificity. However, it is generally considered a bad practice to use !important excessively, as it makes the CSS harder to manage.
#column-one { width: 200px !important; } .post-title { color: blue !important; }
The opacity property controls the transparency level of an element, ranging from 0 (fully transparent) to 1 (fully opaque).
opacity: 0.5;
The font-weight property sets the weight (boldness) of the text. Common values include bold, normal, lighter, or numerical values like 400, 700, etc.
font-weight: bold;
The text-align property sets the horizontal alignment of text in an element. Possible values include left, right, center, and justify.
text-align: right;
A CSS rule set contains one or more selectors and one or more declarations. The selector points to an HTML element, while the declarations apply specific styles to that element.
h1 { color: blue; text-align: center; }
The color property sets the foreground text color of an element. Values can be named colors like green or blue, or hexadecimal color codes like #22f or #2a2aff.
p { color: #2a2aff; } span { color: green; }
In CSS, the url() function is used to specify resource URLs, which can be applied to properties like background-image.
background-image: url("../resources/image.png");
The background-image property sets the background image of an element. The value should be an image URL in the format url("image-name.jpg").
background-image: url("nyan-cat.gif");
The font-family property specifies the typeface for text in an element. Fonts should be available on the user's device or linked as a web font. Multi-word font names should be enclosed in quotes.
h2 { font-family: Verdana; } #page-title { font-family: "Courier New"; }
Color name keywords, such as aqua or khaki, can be used to set color values in CSS.
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!