Introduction to CSS: A Comprehensive Guide to Cascading Style Sheet
What is Cascading Style Sheets (CSS), and why is it necessary?

CSS stands for Cascading Style Sheets. The coding language used to create a website is what dictates its design and layout. CSS, like HTML, is critical to web design. Without it, web pages would be made up entirely of text on white backgrounds.
Prior to the World Wide Web Consortium’s (W3C) creation of CSS (Cascading Style Sheet) in 1996, Web sites were severely constrained in terms of both design and function. The first browsers displayed pages as hypertext (plain text, graphics, and connections to other hypertext sites). There was no layout at all; the page was just a single column of text.
Significant advancements in website layout, including the ability to:
- Other than the browser’s default typeface, it provides other fonts.
- Customize the colour and size of the text and links.
- Colorize backgrounds.
- Build boxes to hold site items and move them to different places on the page.
They put “style” in style sheets, which made it possible to make Web pages for the first time.
In 1998, Microsoft’s Internet Explorer 3 was the first commercial browser to read and use CSS. To this day, browser support for certain CSS features varies. The W3C, which continues to supervise and develop Web standards, has published a new CSS standard dubbed CSS3. The CSS3 creators think that all major browsers will read and show all of the CSS functions the same way, no matter what.
What is the Purpose of CSS?
As previously stated, CSS (Cascading Style Sheet) is a language used to determine how documents are displayed to users—how they are formatted, laid out, and so on.
There are many types of markup languages, but the most common is HTML. You may also see SVG or XML, but these aren’t the only ones.
Presenting a document to a user entails transforming it into a format that your audience can understand. It can be used to show documents in a way that looks like a computer screen, projector, or printer. Browsers like Firefox or Chrome are used to do this.
For example, CSS (Cascading Style Sheet) may be used to style the text in extremely simple documents—for example, to change the colour and size of headers and links. It may be used to generate layouts — for example, it can be used to convert a single column of text into a layout with a primary content section and a sidebar for relevant information. Additionally, it may be used to create effects such as animation. Consider the links included in this paragraph for particular instances.
Also Read: What is HTML?: Introduction to Basic HTML and How it Works
How CSS (Cascading Style Sheet) Works:
CSS (Cascading Style Sheet) is a basic English-based syntax that is governed by a set of rules. As previously stated, HTML was never designed to employ style components, just the page’s syntax. It was made only for the purpose of describing the material. For instance, <p> This is the beginning of a paragraph.</p>
However, how do you format the paragraph? CSS syntax is rather easy. There is a selector and a declaration block included. You choose an element and then specify the operation you want to perform on it. Isn’t that straightforward?
However, some requirements must be followed. Do not be concerned about the structural rules.
The selector identifies the HTML element to be styled. The declaration block is made up of one or more declarations that are separated by semicolons.
Each declaration contains a colon-separated list of CSS properties and their associated values. They always end with a semicolon, and declaration blocks are inside curly braces.
Consider the following example:
All <p> components will be highlighted in blue and bold.
<style> p { color: blue; text-weight: bold; } <style>
In another example, all <p> components will be centred, 16px wide, and pink in colour.
<style> p { text-align: center; font-size: 16px; color: pink; } </style>
Now, let’s discuss the various CSS styles. There are three of them: inline, external, and internal.
The Distinction Between Internal, External, and Inline CSS Styles

CSS may be included in your HTML in three ways: internal, external, or inline styles. Let us dissect them.
Internal CSS
Internal or embedded CSS needs you to include <style> tag in your HTML document’s <head> section.
This CSS style is a simple but efficient way to design a single page. Using this style for several pages, on the other hand, is time-consuming since you must include CSS rules on each page of your website.
How to utilise internal CSS:
- Locate the <head> opening tag on your HTML page.
- Add the following code immediately below the <head> tag.
<style type="text/css">
- On a new line, add CSS rules. Here is an illustration:
body { background-color: blue; } h1 { color: red; padding: 60px; }
Type the closing tag as follows:
</style>
Your HTML file will appear as follows:
<!DOCTYPE html> <html> <head> <style> body { background-color: blue; } h1 { color: red; padding: 60px; } </style> </head> <body> <h1>Hostinger Tutorials</h1> <p>This is our paragraph.</p> </body> </html>
Advantages of Internal CSS (Cascading Style Sheet):
- This style sheet supports class and ID selectors. Here is an illustration:
.class { property1 : value1; property2 : value2; property3 : value3; } #id { property1 : value1; property2 : value2; property3 : value3; }
- Because the code will be included within the same HTML page, there is no need to submit several files.
Disadvantages of Internal CSS (Cascading Style Sheet):
- By including the code in the HTML text, you may increase the size and load time of the page.
External CSS
External CSS lets you connect your web pages to an external.css file that you can write in any text editor on your computer, like Notepad++.
This CSS method is more efficient, which is very beneficial when designing a large website. By altering a single.css file, you may update the whole site simultaneously.
To use external CSS, follow these steps:
- With the text editor, create a new.css file and add the style rules. For instance:
.xleftcol { float: left; width: 33%; background:#809900; } .xmiddlecol { float: left; width: 34%; background:#eff2df; }
- Add a reference to your external.css file just after the <title> element in the <head> section of your HTML sheet:
<link rel="stylesheet" type="text/css" href="style.css" />
Please note that you must replace style.css with the name of your.css file.
External CSS (Cascading Style Sheet) has the following Advantages:
- Because the CSS code is contained in a separate page, your HTML files will be more organised and lower in size.
- You may use the same .CSS for multiple pages.
External CSS (Cascading Style Sheet) has the following Drawbacks:
- There is a chance that your websites won’t look right until the external CSS is added.
- Uploading or linking to a lot of CSS files could make your site take a long time to download.
Inline CSS
CSS is used inside an HTML element to style it. The only thing you’ll need to do is add the style property to each HTML element that needs this CSS style.
This CSS type is not recommended since each HTML element must be treated separately. Managing your website may become prohibitively difficult if you exclusively use inline CSS.
However, inline CSS in HTML might be advantageous in some circumstances. For instance, if you lack access to CSS files or simply need to design a single element.
Consider the following example: We’re going to add an inline CSS rule to the <p> and <h1> tags here:
<!DOCTYPE html> <html> <body style="background-color:black;"> <h1 style="color:white;padding:30px;">Hostinger Tutorials</h1> <p style="color:white;">Something usefull here.</p> </body> </html>
The Advantages of Inline CSS (Cascading Style Sheet) are as follows:
- CSS rules can be added to an HTML page quickly and easily. That’s why this strategy is good for testing or previewing changes to your website, as well as making quick changes.
- As with the external style, you don’t need to make and send a separate document.
The Disadvantages of Inline CSS (Cascading Style Sheet) are as follows:
- Adding CSS rules to each HTML element takes time and complicates your HTML structure.
- Styling several items might have an effect on the size and download time of your website.
CSS (Cascading Style Sheet) Syntax

CSS is a rule-based language, which means that you construct rules defining sets of styles to be applied to certain components or groups of elements on your web page. For instance, “I want the main heading of my website to be shown in brilliant red letters.”
The following code shows a very simple CSS rule that would make the style you want:
h1 { color: red; font-size: 5em; }
A selection is used to begin the rule. This picks the HTML element for styling. We are styling level one headers (h1>) in this example.
Then we have a pair of curly braces. There will be one or more declarations included inside those, which will take the form of property and value pairs. Each pair describes a property of the elements that are being selected, and then the value that should be given to that property, in that order.
We have the property before the colon and the value after the colon. CSS attributes have a range of permissible values that vary according on the property being supplied. We have the colour property in our example, which accepts multiple colour values. Additionally, we have the font-size attribute. This property accepts values in a variety of different size units.
A CSS stylesheet will have several such rules, sequentially written.
h1 { color: red; font-size: 5em; } p { color: black; }
You will discover that certain values come naturally, while others need research. Individual property pages on MDN provide a fast reference for properties and their values in case you forget or want to know what else may be used as a value.
Note: The MDN CSS reference has links to all of the CSS property pages (along with additional CSS features). Alternatively, you should get used to using the search term “mdn css-feature-name” in your preferred search engine anytime you want further information on a CSS feature. Consider searching for “mdn colour” and “mdn font-size” as examples!
CSS (Cascading Style Sheet) Modules
Due to the breadth of what may be styled using CSS (Cascading Style Sheet), the language is divided into modules. As you navigate MDN, you’ll see references to various modules, and many of the documentation pages are arranged around a single module. For instance, you may consult the MDN documentation for the Backgrounds and Borders module to learn more about the module’s purpose and the many attributes and other features it provides. Also, you will find links to the CSS Specification, which explains the technology (see below).
At this point, you don’t need to worry too much about the structure of CSS; however, it can make it easier to find information if, for example, you’re aware that a particular property is likely to be found in conjunction with other similar properties and is thus likely contained within the same specification.
Consider the Backgrounds and Borders module as an example; you may believe that it makes logical sense to declare the background-color and border-color attributes in this module. And you would be correct.
You can also learn CSS from W3Schools Website .
CSS (Cascading Style Sheet) Specifications
All web standards technologies, like HTML, CSS, and JavaScript, are explained in huge papers called specifications (or “specs”), which are written by standards groups like the W3C, WHATWG, ECMA, or Khronos. These groups make sure that these technologies work exactly how they should.
CSS (Cascading Style Sheet) is no exception; it is developed by a working group inside the World Wide Web Consortium called the CSS Working Group. This group is comprised of representatives from browser vendors and other organisations with a stake in CSS. Additionally, there are those designated as invited experts who serve as independent voices and are not affiliated with a member organisation.
The CSS (Cascading Style Sheet) Working Group develops or specifies new CSS features. Occasionally, because a specific browser expresses an interest in acquiring a capacity, occasionally, because web designers and developers request a feature, and occasionally, because the Working Group has recognised a necessity, CSS is a living document that is always evolving, with new features becoming accessible. However, a critical aspect of CSS is that everyone works really hard to ensure that no changes are made that harm existing websites. If you made a website in 2000 with the little CSS that was available at the time, it should still work with today’s browsers.
As a novice to CSS (Cascading Style Sheet), you’re likely to find the CSS specifications intimidating-they’re meant for engineers to use to build feature support in user agents, not for web developers to study in order to understand CSS. Numerous seasoned developers would prefer to consult the MDN manual or other tutorials. However, it’s important to know about them and understand how the CSS you’re using, browser support, and the specifications work together so that you can make sure your site looks good.
Also Read: How to Install WordPress Effectively: A Step by Step Guide
Information About the Browser’s Support
Once CSS (Cascading Style Sheet) is described, it is only helpful for designing web pages if it is implemented by one or more browsers. This indicates that code has been built to convert the instructions contained in our CSS file to something that can be shown on the screen. We’ll examine this procedure in more detail in the lesson “How CSS Works.” Because it is uncommon for all browsers to implement a feature concurrently, there is sometimes a gap where you can use certain CSS features in some browsers but not in others. As a result, the ability to monitor implementation progress is advantageous.
On each MDN property page, a feature titled “Browser compatibility” displays the state of browser support (use this to check if the property can be used on your website). For instance, the CSS (Cascading Style Sheet) font-family compatibility clause is replicated below.