HTML Styles
Style a paragraph with dark text, a pale background, and a visible border.
Understand the topic
The style attribute accepts CSS declarations for one element. A declaration contains a property, a colon, and a value; separate declarations with semicolons. Inline styles can demonstrate a small idea, but stylesheets are easier to reuse and maintain across a website. HTML describes the content while CSS changes its visual presentation.
Worked example
<p style="color: #14532d; background-color: #dcfce7; padding: 1rem;">Registration is open.</p>
color changes text, background-color changes the area behind it, and padding adds space inside the paragraph. All three declarations apply to this element only.
Practice
Style a paragraph with dark text, a pale background, and a visible border.
Show a suggested answer
<p style="color: #172033; background-color: #f0f9ff; border: 1px solid #64748b; padding: 1rem;">Next class: Friday</p>Common mistake
A visual change should not hide meaning. Check readable contrast and avoid using color as the only way to communicate a result.