<?xml version="1.0" encoding="utf-8"?>

The style attribute syntax

The style attribute syntax Bad Practice
The style attribute syntax Best Practice

Writing code gives the browser commands about how to display your content. When applying an inline CSS style to an element, you need to communicate 3 things to the browser:

• The fact that you wish to change the element's style

• What style property you want to change

• What value of the property you wish to set

Technically, you can write it out in the following way. In the start tag, add an attribute style followed by an equals sign (=). Next, describe the property you want to set in the following order:

1. Open quotation marks

2. Indicate the property (for example, color)

3. Put a colon

4. State the property's value (for example, blue)

5. Put a semicolon

6. Close the quotation marks

Pro Tip: Make sure not to miss any of the punctuation signs — without them, browsers won't be able to display your page correctly!

Top contributors

The Eye of Sauron

Topics

From Lesson

Share

Improve your UX & Product skills with interactive courses that actually work