Write a program to apply the Inline CSS in HTML.

1
2
3
    <html>
4
    <body>
5
        <h1 style="color:blue;margin-left:30px;">This is a heading</h1>
6
        <p>This is a paragraph.</p>
7
    </body>
8
    </html>
9
    

Output

1
2
        No Output Available
3
        

Rate the Code

Reviews are published after a quick safety check (usually within 24 hours).

Reviews are public. Developers can see basic device specifications to respond. Learn more

Core Concept of Applying Inline CSS in HTML

When you apply CSS styles to an element with the style attribute, it is known as inline CSS.

In this code:

  • The style = “color:blue; margin-left:30px;” is used in <h1> tag as inline css

Why is it used?

  • When you want to apply small-scale CSS to a particular element, then inline CSS is used.
  • To apply CSS with the highest priority.

Real-life Applications

  • Dynamic Style via JavaScript: When you want to change the runtime color, visibility, position, or anything about an element.
  • HTML Email Templates: Most of the email clients (like Gmail, Outlook) don’t render external or internal CSS, so inline CSS is used.
  • Quick Testing and Debugging: When testing the live CSS code, inline CSS is used by applying it to the targeted element inside the developer tools.

Key Benefits of this Program

  • Highest Specificity: Inline CSS has the highest priority among external, internal, and inline CSS. So, if you want to apply any rule with the highest priority, the inline approach is best.
  • Quick Step-up: No need to make a dedicated external file for small changes.

Limitations of this Program

  • Code Maintenance Problem: Due to adding inline CSS to every single element, the code is very hard to maintain.
License: This program's source code is open-sourced under the MIT License, while the rest of the program's text content and overall dhimanp platform and brand content remain proprietary under dhimanp.

Submit your modified code

Your submissions are published after a quick safety check (usually within 7 days).

Submissions are public. Developers can see basic device specifications to respond. Learn more

Disclaimer

The information that you shared with us will be publicly visible, and everyone can see your information. And we (dhimanp) are not responsible if anyone misuses this information. We can remove any submitted code at any time for better transparency.

Privacy Policy

If you share your data with us by submitting your code for credit, then we may show your full name, school or college name, and city name on our website.

We are not using this data to track you and are not selling this data to anyone.

If you want to remove your name from our website, you can contact us, and we will remove your name from our website. In the removal process, full credit, including your full name, school or college, city, and code, will be removed from our website.