💡 Tip: Login now to track your course progress and unlock your downloadable certificates instantly!

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
<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
<h1 style="color: #29AB87; text-align: center;">Welcome!</h1>

b) Internal Styles

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

Internal Style Example
<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
<head>
  <link rel="stylesheet" href="styles.css">
</head>

styles.css:

Style Example
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
<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
<p class="highlight">This is highlighted text.</p>

Define classes in <style> or external CSS.

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

Avoid overusing inline styles for cleaner code and better maintainability.

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.

Sign In Form

User your email and password to singn in

Don’t have an account, signup here : 

HTML5 & CSS3

Tools and Tutorials

Want a Website

Want a website for your business ?

Please fill out the details below, so we can reach out to you.

Registration Form

Signup to track your record and much more.

We have sent you an email with a registration link. Please click the link to verify your email address, or enter the 6-digit OTP provided in the email.

Didn't receive the OTP. Regenerate OTP Resend