Menu Close

What are the 3 way to use CSS?

Cascading Style Sheets (CSS) provide designers and developers with powerful tools to enhance the visual presentation of web pages. There are three primary ways to use CSS: inline styling, internal styling, and external styling.

Inline styling involves adding CSS directly within an HTML element using the style attribute, allowing for quick customization of individual elements. Internal styling involves embedding CSS code within the head section of an HTML document, enabling consistent styling across multiple elements within the same document. External styling involves linking an external CSS file to an HTML document, which offers the advantage of centralizing styles and easily applying them to multiple web pages.

If you are a web developer or designer, you are probably familiar with CSS, which stands for Cascading Style Sheets. CSS is a powerful tool that allows you to control the presentation and layout of web pages. It plays a crucial role in making websites visually appealing and user-friendly. In this article, we will explore the three main ways to use CSS and how they contribute to creating stunning websites.

Table of Contents

Inline CSS

Inline CSS is one of the most basic ways to apply styles to HTML elements. With inline CSS, you can define styles directly within the HTML tags using the style attribute. For example:

<p style="color: blue; font-size: 16px;">This is a paragraph with inline CSS</p>

As you can see, the style attribute contains CSS properties and their corresponding values. This allows you to set specific styles for individual elements. However, inline CSS can quickly become cumbersome and hard to manage, especially when you have a large number of elements to style. It’s generally not recommended for extensive styling purposes.

Internal CSS

Internal CSS is another way to utilize CSS in your web pages. With internal CSS, you define your styles within the <style> tags, which are placed within the <head> section of your HTML document. Here’s an example:

        p {
            color: blue;
            font-size: 16px;
    <p>This is a paragraph with internal CSS</p>

When using internal CSS, you can target specific elements using selectors, just like with inline CSS. However, internal CSS offers the advantage of keeping your styles separate from your HTML content, allowing for better organization and maintainability. It’s an excellent choice for small to medium-sized websites.

External CSS

The third and most widely used method of using CSS is through external CSS. External CSS involves creating a separate CSS file that contains all your styles and linking it to your HTML document using the <link> tag. This is how it’s done:

    <link rel="stylesheet" type="text/css" href="styles.css">
    <p>This is a paragraph with external CSS</p>

In this example, the styles for the paragraph are stored in a file called styles.css. This separation of concerns allows for greater flexibility and scalability since you can apply the same styles to multiple HTML documents. External CSS promotes code reusability and makes it easier to update and maintain your styles across an entire website.

CSS offers three main ways to style your web pages: inline, internal, and external CSS. While inline CSS is suitable for simple modifications, internal and external CSS are recommended for more extensive styling needs. Internal CSS keeps your styles within the HTML file, while external CSS allows for separation of concerns and better code organization. By understanding the different ways to use CSS, you can create visually stunning websites that are both functional and aesthetically pleasing.

CSS can be used inline, internally within the HTML document, or externally as a separate stylesheet. Each method offers a different level of flexibility and organization, allowing developers to style web pages efficiently and effectively.

Leave a Reply

Your email address will not be published. Required fields are marked *