Loading
Lesson 13
Courses / Software School Cuts
Introduction to CSS - Styling Paragraphs

Get started with Cascading Styling Sheets (CSS), using the JSFiddle platform.

In a previous session, HyperText Markup Language (HTML) was introduced to define the structure of a website document. This lecture goes over changing the styling and visuals of a page.

The lesson shows you how to style paragraph elements. You learn the syntax to select elements for styling. You learn to use an element name selector to change the text color CSS property.

Summary

# Summary of CSS Introduction

In this session, the focus is on **Cascading Style Sheets (CSS)**, which are used to modify the styles of a document, complementing the **HTML** framework discussed previously. 

## Key Points Covered:

- **Website Building Blocks**: Websites are built using HTML for structure, CSS for styles, and JavaScript for interactivity.
- **Practice Platform**: The examples will be practiced on [jsphoto.net](http://jsphoto.net), which has separate panels for HTML, CSS, and JavaScript.
- **Basic HTML Structure**:
  - An HTML paragraph is created using `<p>` tags, with a corresponding closing tag `</p>`.
  
- **Styling with CSS**:
  - To style a paragraph, navigate to the CSS panel.
  - Use a **selector** (e.g., `P`) to target elements.
  - Define styles within curly braces `{}`.
  
### CSS Syntax:

1. **Selector**: Defines which HTML element(s) to style (e.g., `P` for paragraphs).
2. **Properties & Values**: Pairs of property and value are written as `property: value;`.
   - Example: To change text color:
     - Property: `color`
     - Value: `red`
     
3. **Example**:
   - To change paragraph color to red:
     ```css
     P {
         color: red;
     }
     ```
   - Use a semicolon to end each style declaration.

- **Testing Changes**: Click "Run" to see the effects of the styles applied. For example, changing the paragraph's color from black to red.

Feel free to experiment with different colors!

Video Transcript

As I said, we'll be practicing the examples in this website, jsphoto.net. And we'll talk about CSS today, Cascading Style Sheets. Last session I talked about HTML, hypertext markup language. That's how we build websites, the document structure and everything. Today is more about the styles, the visuals. So Cascading Style Sheets is what we use to modify the styles of a document. Any website you see today in the browser, be it in your phone or computer, is going to be written in HTML, CSS, some JavaScript. We're going to talk about JavaScript. So let's start off with a paragraph in the HTML. If you don't know about jsphoto, we have the HTML panel where you can write the code in HTML. You have the CSS panel here on the right-hand side where you can type CSS, you can type JavaScript. And then to see the result, you click Run on the top left, and you can see in the bottom right the result. You can change this layout clicking Settings if you want to like, choose a different layout for you. I'm going to keep classic. Okay, so we got a paragraph here. You remember French HTML, we could create elements with tags. We have an opening tag, a closing tag, and in between the tags we want to show for the paragraph. Always the opening tag has the name of the element within the angle brackets, and then the closing tag, the same thing except we have the slash before the element name. In this case, the element name is P, which stands for paragraph. Now let's say I want to style this paragraph and change its color. So what I would do is first I need to go to the CSS tab here, start writing some code, but I need to say, okay, what do you want to style? So I have to use a selector. So if I say P like this, that means I want to target all of the P elements in this document. Now you have to specify the styles within the curly braces. So you're going to write some curly braces there and we're going to type some code between the opening and the closing. Now I added some space after the P that's just for style. You don't need that. And I added a new line also don't need that, but usually we like to make it more readable. That's why I do that. So the proper CSS always works the same way. We have the selector, what we want to target, and then we have the styles, which are pairs of property, colon, value, semicolon, and you can separate, you can add multiple ones. So the property for the text color is just called color. And the syntax you have to have a colon there and then the value, for example, red. And then you finish it off with a semicolon. Now the property is color, the value is red. The colon and the semicolon are because of syntax. You always have to have them. I usually like to place a space after the colon just for to better visualize it, but it's not necessary. So when I click run in the top left, I can see if you can see colors that the paragraph change color from black to red. So you can play around a change menu color like make the green. Like that.
No comments yet (loading...)
No comments yet (loading...)
Did you like the lesson? 😆👍
Consider a donation to support our work: