Inline style in HTML refers to the practice of applying styling directly to a specific HTML element, rather than using an external stylesheet or internal styles within a <style> tag. This approach allows developers to apply unique styles to individual elements, providing a fine-grained level of control over the appearance of their web pages.
To define an inline style in HTML, you can use the style attribute within the opening tag of the element you want to style. The style attribute contains CSS properties and values that determine the appearance of the element.
Check below example:
<p style="color: blue; font-size: 16px;">This is a styled paragraph.</p>
In this example, the style attribute is applied to the <p> (paragraph) element, setting the text color to blue and the font size to 16 pixels.
Adding inline styles to your HTML elements is a straightforward process.
Follow these steps:
Identify the HTML element you want to style.
Add the style attribute within the opening tag of the element.
Inside the style attribute, specify the desired CSS properties and values separated by semicolons.
Here's an example of adding an inline style to an <h1> (heading) element:
<h1 style="text-align: center; color: #e74c3c;">Centered and red heading</h1>
In this example, the text alignment is set to center, and the text color is defined as a shade of red.
© Copyright Sahad Sarang 2024