Inline Styling in CSS: Applying Styles Directly in HTML


Inline styles are used to apply the unique style rules to an element, by putting the CSS rules directly into the start tag. It can be attached to an element using the style attribute. The style attribute includes a series of CSS property and value pairs

In CSS, inline styling refers to the method of applying styles directly to individual HTML elements using the style attribute. It allows you to define CSS properties and their values directly within the HTML tags, without the need for an external CSS file or internal style sheet. Inline styles are specified within the opening tag of an element using the following syntax:

<tagname style="property: value;">

Here's an example to Illustrate Inline styling:

Eg.
	<p style="color:red; text-align:center">.....</p>
Output

CSS Inline Method

In this example, the style attribute is added to the <p> tag, and the CSS properties color and text-align are defined with their respective values. As a result, the text within the paragraph will have a red color and a text align is center.

Inline styles have a higher specificity than external stylesheets or internal styles. This means that they override any conflicting styles defined elsewhere. However, inline styles can quickly become cumbersome to manage, especially when applied to multiple elements, as they require modifying the HTML markup directly.

Some key points to keep in mind regarding inline styles:

  1. Inline styles are applied directly to individual elements, allowing for specific element-level customization.
  2. Inline styles take precedence over external stylesheets and internal styles.
  3. Inline styles are specified using the style attribute within the opening tag of an HTML element.
  4. Multiple CSS properties can be defined within the style attribute by separating them with a semicolon.

While inline styles can be useful for quick, one-off styling, it is generally recommended to use them sparingly and prioritize external or internal style sheets for better organization and maintainability of CSS code.

Source Code

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Tutor Joes</title>
</head>
<body>
    <p style="color:orange;text-align: justify;">
    Lorem ipsum dolor, sit amet consectetur adipisicing elit. Voluptate voluptates rem eveniet, 
	quo tempora architecto iste eligendi dolorem reiciendis quas accusantium repellat illum 
	libero odit exercitationem.Voluptates rerum, expedita laudantium ipsa minima repellat? 
	Sequi quo inventore sapiente voluptas rerum, porro quidem commodi earum consequuntur 
	laudantium! In facere ullam voluptas deserunt.Perferendis delectus corrupti amet minima! 
	Veritatis hic obcaecati enim.
    </p>
    <hr>
    <p style="color:orange;text-align: justify;">
    Lorem ipsum dolor, sit amet consectetur adipisicing elit. Voluptate voluptates rem eveniet, 
	quo tempora architecto iste eligendi dolorem reiciendis quas accusantium repellat illum 
	libero odit exercitationem.Voluptates rerum, expedita laudantium ipsa minima repellat? 
	Sequi quo inventore sapiente voluptas rerum, porro quidem commodi earum consequuntur 
	laudantium! In facere ullam voluptas deserunt.Perferendis delectus corrupti amet minima! 
	Veritatis hic obcaecati enim.
    </p>
</body>
</html>
Live Preview

CSS Tutorial


Properties Reference


Cascading Style Sheet


Flexbox Tutorial


CSS Grid Tutorial


Transitions Properties


CSS Properties with Examples


CSS Selectors


CSS Pseudo Elements


CSS Attribute Selectors


Input Pseudo Classes


CSS Examples


CSS Animation Projects