What is Inline CSS?
Inline CSS is used to apply styles directly to a single HTML element, using the style attribute within the HTML tag. This allows you to style individual elements without affecting other elements on the page.
Advantages of Using Inline CSS
Inline CSS can be useful for making quick style changes to specific elements without having to create separate style sheets. It also allows for more specific targeting of elements and overrides other style rules, such as those defined in external style sheets.
Disadvantages of Using Inline CSS
While inline CSS can be convenient for small-scale styling, it can lead to redundancy and reduced maintainability when used extensively across a website. It also makes it more challenging to implement consistent styles across multiple pages.
How to Write Inline CSS
To apply inline CSS to an HTML element, use the style attribute within the opening tag of the element. The style attribute should contain CSS property-value pairs. For example, <p style="color: blue; font-size: 18px;">This is a paragraph with inline CSS</p>
Example Code
<p style="color: blue; font-size: 18px;">This is a paragraph with inline CSS</p>