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

The style attribute

The style attribute

The style attribute helps — you guessed it — style HTML elements. It's also a global attribute, meaning that it can be applied to most HTML elements.

The style attribute introduces elements in a different type of language called CSS. While HTML gives content its structure, CSS's job is to describe your web pages' style, design, layout, etc. The value of a style attribute — the part that follows the equals sign and is enclosed with quotation marks — has its own structure.

For example, the attribute style="color:red;" will make the text of that paragraph red. Color here is a CSS property, while red is its value. You must use a colon to separate the two parts and a semicolon after the CSS value.

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