When building a website, content is not enough – the visual design plays an important role in attracting users. HTML Styles help to live your pages to bring your pages to the colorability and formatting colours, fonts and formatting.
In this guide, we will explore what HTML phrases and how they work and use them effectively.
What Are HTML Styles?
HTML styles are rules or attributes used to change the visible presentation of components in a webpage. With styles, you can change colors, font sizes, alignments and backgrounds. It makes your page more attractive and user friendly.
The HTML style Attribute
The style attribute is used directly to apply inline CSS (cascading style sheets) directly inline css (cascading style sheets) to HTML elements. This allows you to revise the elements without writing external or internal stylesheets.
Syntax:
<tagname style="property:value;">
Example:
<p style="color:blue;">This is a blue text paragraph.</p>
Exercise it:
Inline styles are quick and easy for minor changes, but the large projects maintenance of CSS should be avoided.
Background Color in HTML
Using the background color property, you can change the background color of any HTML element.
Example:
<body style="background-color: lightblue;">
💡 Tip: Use the hexadecimal (#ffffff), RGB (rgb(255,255,255)), or color names (blue, red, etc.).
Text Color Styling
To set the color of the text, use the color property.
Example:
<h1 style="color: green;">Green Heading</h1>
Exercise it:
Choosing the right contrast between the background and the text improves readability and accessibility.
Changing Fonts in HTML
Fonts add personality to your content. And use the font-family property to change the typeface.
Example:
<p style="font-family: Arial, sans-serif;">This is the Arial font.</p>
✅ Best Practice: Always include a fallback font (eg. sans-serif) if the browser doesn’t support your primary font.
Adjusting Text Size
The font-size property controls the size of your text.
Example:
<p style="font-size: 18px;">This text is 18 pixels in size.</p>
Exercise it:
📌 You can also use like em, %, or rem for more responsive sizing.
Text Alignment
Align the text with the text-align property. General values ​​are left, center, right and justify.
Example:
<p style="text-align: center;">This text is centred.</p>
Exercise it:
Proper alignment can improve content flow and aesthetic layout.
Margin and Padding
The Margin and padding control spacing outside and inside HTML elements.
Example:
<div style="margin: 20px; padding: 10px;">Box with spacing</div>
Exercise it:
- Margin: Give space outside the border
- Padding: Give space inside the element, between content and border
Borders and Box Styling
Borders help to visually separate the sections or emphasize content.
Example:
<p style="border: 1px solid black;">Paragraph with border</p>
Exercise it:
You can customize:
- Border width
- Style (solid, dashed, dotted)
- Color
Using Multiple Style Properties
Now you can use or apply multiple CSS properties inside a single style attribute.
Example:
<h2 style="color: red; font-size: 24px; text-align: center;">Styled Heading</h2>
Exercise it:
This may allow full control over how each element looks with just one line of code.
Bonus Tips for Better HTML Styling

Conclusion
Learning HTML styles is ideal in developing clean, professionally, and user-friendly web pages. Styling is like the hand between content and design and ranges between font change and font, and alignment to background color change. Once you learn this fundamental then you will be ready to create more visually appealing sites.