CSS Basics and Styling

Cascading Style Sheets (CSS) is used to style HTML content and make webpages more visually appealing. In this article, we'll cover the basics of CSS and how to apply styles to HTML elements.

CSS Syntax
CSS styles are applied using selectors and declarations. A selector is used to target an HTML element, and a declaration is used to define a style property and value. Multiple styles can be applied to an element by separating them with semicolons.

Here's an example of a CSS rule that targets all the headings on a webpage and sets the color to blue:

h1 {
  color: blue;

CSS Styles
CSS styles can be applied to various HTML elements, including text, backgrounds, borders, and more. Here are some common style properties and values:

  • color: sets the color of text
  • font-size: sets the size of text
  • background-color: sets the background color of an element
  • border: sets the border style of an element
  • "padding:* sets the spacing between the element content and border

CSS Classes and IDs

CSS classes and IDs are used to target specific HTML elements. A class is used to apply the same styles to multiple elements, while an ID is used to apply unique styles to a single element. To apply a class or ID, you need to add it to the HTML element's opening tag using the class or id attribute.

Here's an example of how to apply a class to a paragraph element:

<p class="my-class">This is a paragraph with a class</p>

And here's how to apply an ID to a heading element:

<h1 id="my-id">This is a heading with an ID</h1>


CSS allows you to style HTML content and make webpages more visually appealing. By understanding the syntax of CSS, the various style properties and values, and how to apply classes and IDs, you can create visually stunning webpages. In the next article, we'll cover how to create responsive layouts using CSS.

You've successfully subscribed to Leewardslope
Great! Next, complete checkout to get full access to all premium content.
Error! Could not sign up. invalid link.
Welcome back! You've successfully signed in.
Error! Could not sign in. Please try again.
Success! Your account is fully activated, you now have access to all content.
Error! Stripe checkout failed.
Success! Your billing info is updated.
Error! Billing info update failed.