Professional Documents
Culture Documents
Css Syntax
Css Syntax
Css Syntax
SYNTAX:
/* This is a CSS comment */
/* Selectors and Declarations */
selector {
property: value;
}
/* Example: Styling an ID */
#my-id {
border: 1px solid #ccc;
margin: 20px;
}
/* Grouping Selectors */
h2, h3 {
font-weight: bold;
}
/* This is a CSS comment */: Comments in CSS are enclosed in /* */ and are used
for adding notes or explanations within the stylesheet.
selector: Selects HTML elements to apply styles to.
{ }: The curly braces enclose a block of CSS declarations.
property: value;: Each declaration consists of a property and its corresponding value.
Examples:
Selectors:
a:hover: Selects an <a> (link) element when the user hovers over it.
Media Queries:
@media (max-width: 768px): Applies styles only when the viewport width is 768 pixels
or less.
This is a basic overview of CSS syntax. CSS is a powerful styling language, and its syntax
allows for a wide range of styling options to create visually appealing and responsive
designs.