An inline attribute in HTML refers to the style attribute, which allows you to apply CSS directly to a specific element. This provides quick, element-specific styling without affecting other elements or requiring external stylesheets. It is defined directly within the HTML tag.
What is the style Attribute?
The style attribute is an inline attribute used in HTML to apply CSS styles directly to an individual element. Unlike external or internal stylesheets, which apply to multiple elements across a page or site, the style attribute allows you to define unique styling for a specific element.
Syntax
<p style="color: red; font-size: 18px;">This is a styled paragraph.</p>Examples of inline attribute to specifies the styling of elements in HTML
Example 1: Here the inline CSS to style elements directly within the tags. Each element has specific styles applied, such as color and font size
<!DOCTYPE html>
<html>
<head>
<title>Inline attribute specifies the styling of elements</title>
</head>
<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 use inline CSS styling by directly applying color and font size to headings. Each heading features unique styles for Java and Python,
<!DOCTYPE html>
<html>
<head>
<title>inline attribute specifies the styling of elements in HTML</title>
</head>
<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:
