Skip to content

Buzzingz

Unleashing the Power of Code

  • HTML
  • CSS
  • Toggle search form

CSS Syntax

Posted on March 12, 2023March 12, 2023 By shani No Comments on CSS Syntax

The syntax of CSS consists of three parts: selector, property, and value. Here is an example:

selector {
  property: value;
}
  • Selector: Selects the HTML element that you want to style. It could be a tag name, class, ID, or other selectors.
  • Property: Specifies the property of the selected element that you want to change, such as color, font-size, padding, margin, etc.
  • Value: Sets the value of the property that you want to apply to the selected element.

For example, the following CSS code sets the text color of all <p> elements to red:

p {
  color: red;
}

Here, p is the selector, color is the property, and red is the value.

CSS also supports multiple selectors and properties in a single rule. For example:

h1, h2, h3 {
  font-family: Arial, sans-serif;
  color: #333;
}

Here, the rule sets the font family and color for all <h1>, <h2>, and <h3> elements.

CSS also allows you to group multiple rules together. For example:

h1 {
  font-family: Arial, sans-serif;
  color: #333;
}

p {
  font-family: Georgia, serif;
  font-size: 16px;
  line-height: 1.5;
}

Here, two rules are grouped together to set the font family and color for all <h1> elements, and the font family, size, and line height for all <p> elements.

In addition, CSS allows you to add comments to your code using /* */ notation. For example:

/* This is a comment */
h1 {
  font-family: Arial, sans-serif;
  color: #333; /* This is also a comment */
}

Comments are ignored by the browser and are used to provide notes or explanations to your code.

CSS

Post navigation

Previous Post: HTML Tutorial
Next Post: CSS Selectors

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

CSS Tutorial

  • Basic CSS Tutorial For Beginners
  • CSS Introduction
  • CSS Syntax
  • CSS Selectors
  • How To Add CSS
  • CSS Comments
  • CSS Colors
  • CSS Backgrounds
  • CSS Borders
  • CSS Margins
  • CSS Margin Collapse
  • CSS Padding
  • CSS Height, Width and Max-width
  • CSS Box Model
  • CSS Outline
  • CSS Text
  • CSS Fonts
  • CSS Web Safe Fonts
  • CSS Font Fallbacks
  • CSS Font Style
  • CSS Font Size
  • CSS Google Fonts
  • CSS Great Font Pairings
  • CSS Icons
  • CSS Links
  • CSS Lists
  • CSS Tables
  • CSS Layout – display: inline-block
  • CSS Layout – float and clear
  • CSS Layout – Horizontal & Vertical Align
  • CSS Layout – Overflow
  • CSS Layout – The display Property
  • CSS Layout – The z-index Property
  • CSS Layout – width and max-width
  • CSS Layout – The position Property
  • CSS Attribute Selectors
  • CSS Image Sprites
  • CSS Image Gallery
  • CSS Dropdowns
  • CSS Horizontal Navigation Bar
  • CSS Vertical Navigation Bar
  • CSS Navigation Bar
  • CSS Opacity / Transparency
  • CSS Pseudo-elements
  • CSS Pseudo-classes
  • CSS Combinators
  • CSS Math Functions
  • CSS The !important Rule
  • CSS Specificity
  • CSS Units
  • CSS Website Layout
  • CSS Counters
  • CSS Forms
  • About Us
  • Contact Us
  • Privacy Policy
  • Terms & Conditions

Copyright © 2023 Buzzingz.

Powered by PressBook WordPress theme