HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials
  • Insights
  • Verify Certificate
HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials
HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials

HTML5andCSS3.org helps developers learn modern frontend skills with practical tutorials, production-ready snippets, and fast web tools built for everyday coding.

Quick Links

  • About Us
  • Contact Us
  • Privacy Policy
  • Copyright
  • Disclaimer

Top Tools

  • Try It Editor
  • JSON Formatter
  • CSS Minifier
  • HTML Minifier
  • Base64 Encoder / Decoder

Contact

  • business@html5andcss3.org
Newsletter

Learn at your own pace, practice with useful tools, and build websites you're proud of.

© 2011-2026 html5andcss3.org. All rights reserved.

How to Use

HTML Tutorial

HTML Basics

Introduction to HTMLHTML EditorsHTML StructureHTML Elements & AttributesHTML HeadingsHTML ParagraphsHTML FormattingHTML CommentsHTML Styles

HTML Text and Links

HTML Text FormattingHTML Quotations & CitationsHTML LinksHTML Email Links

HTML Lists and Tables

HTML ListsHTML TablesTable Styling & Borders

HTML Images and Media

HTML ImagesHTML Picture ElementHTML AudioHTML VideoHTML Embed & Object

HTML Forms

HTML Forms OverviewHTML Form ElementsHTML Input TypesHTML Input AttributesHTML Form AttributesHTML Form Validation

HTML Layout

HTML Block vs Inline ElementsHTML Div & SpanHTML Semantic Layout TagsHTML Iframes

Advanced HTML

HTML Entities & SymbolsHTML EmojisHTML Head Element TagsHTML Meta Tags for SEOHTML Responsive Design

HTML References

HTML5 New TagsDeprecated TagsHTML Global AttributesEvent AttributesComplete HTML Tag ListComplete HTML5 ElementsHTML Tutorial PDF
  1. Home
  2. /
  3. Tutorials
  4. /
  5. HTML Tutorial
  6. /
  7. HTML Styles

HTML Basics

HTML Styles

HTML allows you to style your web page content to make it visually appealing.
Styles define colors, fonts, spacing, and layout of elements. You can apply styles inline, internally, or externally using CSS.

What Are HTML Styles?

Styles control the visual presentation of HTML elements.
While HTML defines structure, styles define appearance.

HTML Style Example

html

<p style="color: blue; font-size: 18px;">This is a styled paragraph.</p>
  • style → Attribute to apply inline CSS
  • color → Sets text color
  • font-size → Sets size of text

Types of Styling in HTML

a) Inline Styles

Applied directly to an element using the style attribute.

Inline Style Example

html

<h1 style="color: #29AB87; text-align: center;">Welcome!</h1>

b) Internal Styles

Defined within <style> tags inside the <head> section.

Internal Style Example

html

<head>
  <style>
    p {
      color: red;
      font-size: 16px;
    }
  </style>
</head>
<body>
  <p>This paragraph is styled using internal CSS.</p>
</body>

c) External Styles

Stored in a separate .css file and linked to HTML using <link> in <head>.

External Style Example

html

<head>
  <link rel="stylesheet" href="styles.css">
</head>

styles.css:

Style Example

css

body {
  background-color: #f0f0f0;
}
h1 {
  color: #29AB87;
}

Common Style Properties

PropertyDescriptionExample
colorText colorcolor: blue;
background-colorBackground colorbackground-color: yellow;
font-sizeText sizefont-size: 18px;
font-familyFont stylefont-family: Arial, sans-serif;
text-alignText alignmenttext-align: center;
marginSpace outside elementmargin: 10px;
paddingSpace inside elementpadding: 5px;

Example: Combining Styles

Combined Style Example

html

<p style="color: white; background-color: #29AB87; font-size: 18px; padding: 10px; text-align: center;">
Styled paragraph with multiple properties.
</p>

This paragraph has text color, background color, font size, padding, and centered alignment.

Tips for Using Styles

Use CSS classes instead of repeating inline styles.

Example HTML

html

<p class="highlight">This is highlighted text.</p>

Define classes in <style> or external CSS.

Example CSS

css

.highlight {
  color: #29AB87;
  font-weight: bold;
}

Avoid overusing inline styles for cleaner code and better maintainability.

Browser Support

Chrome
Edge
Firefox
Safari
Opera
IE9+
YesYesYesYesYesYes

Conclusion

HTML styles enhance the appearance and readability of your web page.
Learning to use inline, internal, and external styles effectively is essential for creating visually appealing and professional-looking websites.

PreviousHTML CommentsNextHTML Text Formatting