Open In App

Which inline attribute is used to specify the styling of specific elements in HTML ?

In this article, we will discuss the inline attribute used to specify the styling of specific elements in HTML. Styles in HTML are basically rules that describe how a document will be presented in a browser. Style information can be either attached as a separate document or embedded in the HTML document.  

Inline Style: In Inline styling, the CSS rules are directly written inside the starting tag using the style attribute. The style attribute includes a series of CSS property and value pairs. Each ‘ property: value ‘ pair is separated by a semicolon ( ; ). 



Let’s understand the style attribute using examples:

Example 1: In this example, we will use style attribute for styling the HTML






<!DOCTYPE html>
<html>
 
<body>
    <h1 style="color:Blue;font-size:25px;">
        Java - Inline style
    </h1>
    <p style="color:red;">Java - paragraph</p>
    <p style="color:green;font-size:40px;">
        python - paragraph
    </p>
    <hr style="border-color:orange;">
</body>
</html>

Output:

Example 2: In this example, we will style the content by using inline CSS styling.




<!DOCTYPE html>
<html>
   
<body>
    <h1 style="color:Blue;font-size:25px;">
        Java - Inline style
    </h1>
    <h2 style="color:green;font-size:15px;">
        Python - Inline style
    </h2>
</body>
</html>

Output:


Article Tags :