Lesson 9: CSS Inline
Normal HTML
<h4> I Love using CSS</h4>
How to change the colour of the text to red?
- Use the style attribute to perform inline CSS
<h4 style= "color: red;"> I Love using CSS </h4>
Style attribute are declared by using the ‘style’ keyword after the element tag. Each CSS declaration has a property and value.
- The property is also declared first, and after the colon, the value is declared.
For the example above:
<h4 style= "color: red;"> I Love using CSS </h4>
- Property: Value
- Color is the property.
- Red is the value.
Properties
- Is a style feature that you want to change.
- There is a large list of CSS properties, for example, color, background-position, and border.
Values
- For inline CSS to work, each property must have a value.
- In the example above, the value assigned to the color property is red.
Multiple CSS Declarations
- Style attributes can be defined as many times as you want.
- Separate each style attribute with a semicolon at the end of the declaration.
- Each style attribute must have a comma after the semi colon so the compiler can distinguish between each of the style attributes.
Example: