Styles
Give your HTML personality by changing colors, sizes, backgrounds, and more.
style=“color:#20e778;”>
Hello!
</h1>
>_ What Are Styles?
So far, HTML has given our webpages structure and content. Styles let us control how that content looks — including its colors, size, background, spacing, and much more.
The language used to style webpages is called CSS, which stands for Cascading Style Sheets.
One simple way to introduce CSS is with HTML’s style attribute.
Text Color
Change the color of headings, paragraphs, links, and other text.
Font Size
Make text larger or smaller using the font-size property.
Backgrounds
Give an element a background color using background-color.
>_ The style Attribute
The style attribute is placed inside an HTML element’s opening tag.
Hello, World!
</h1>
Here, color is the CSS property and blue is its value.
>_ Property + Value
color
The property tells CSS what you want to change.
blue
The value tells CSS how you want it changed.
:
A colon separates the CSS property from its value.
;
A semicolon separates one CSS declaration from the next.
>_ Using Multiple Styles
You can apply more than one CSS property inside the same style attribute.
style=“color: white; background-color: #071a35;”
>
Welcome to mC0de
</h1>
>_ Changing Text Size
The font-size property controls the size of text.
I’m learning how to style HTML!
</p>
>_ Aligning Text
Another useful property is text-align. It controls the horizontal alignment of text.
Centered Heading
</h2>
Inline styles are great for learning and quick experiments, but larger websites normally keep most styling in dedicated CSS rules. We’ll build toward that as the lessons continue.
Style Your Profile
Create a small profile page and use inline styles to make it your own.
-
✓
Create an
<h1>with your name or nickname. -
✓
Change the heading’s
color. -
✓
Give the heading a
background-color. -
✓
Center the heading using
text-align. -
✓
Add a paragraph and change its
font-size. - ✓ Experiment with at least one color of your own.
Styles Challenge
What You’ve Learned
style attribute.
color and
font-size.
background-color.
text-align.
Nice work!
Finished this lesson? Mark it complete to track your progress.


