article header

What is CSS and why should I learn it?

So, we’ve been through HTML, and without it, the internet would be a pretty scarce place. However, the role that CSS plays is nearly as important. Sure, HTML is probably the most important thing on the internet, however, without CSS, I think we’d all be very bored from looking at the lack of style and an abundance of plain black text on white. 

What is CSS? 

CSS, or Cascading Style Sheets, is what adds the style and colour to every webpage. When we talk about style, we’re talking about some of the basic, yet extremely important things like fonts, font sizes, background and text colours. When we spoke about HTML, we compared it to the human form. HTML is the head and the body. CSS would be the style of that. For example, the colour of our eyes, the size of our ears, the pigment of our skin, and even the clothes that we wear. In other words – it’s our look and style. To offer some perspective, Javascript would be the equivalent of how we interact with people. How we talk, shake hands, wink, nod our heads, etc. 

CSS – External, Internal & Inline

As mentioned before, CSS can determine things like colours, fonts, borders, etc, that feature on a page. It can be used in three ways – Inline, Internal and External. Here’s the difference between the three. 

External

External style sheets are very handy, especially when you want to maintain one style through an entire site. The style rules need to be created just once and they are applied to all required pages within a site. If you need to change the style slightly on all pages that use this external sheet, then it just needs to be changed once and it automatically applies to all pages – which is handy! In general, this is the standard way of using CSS.

Internal

This applies to just the page that you are working on. This can be used if a unique style is required for one page of your web app.

Inline

Inline CSS, which I will be using in the example below, relates to a specific page element. In the example below, we use CSS to turn a heading to the colour red on a page. You’ll notice that the order is embedded within HTML text – which is how it is written. (To highlight the CSS in the example below, I have put it in italics – this is to highlight its function for you). However, Inline CSS is only used where you want to apply a unique style to one element.

<!DOCTYPE html>
<html>
<body>
<h2 style=”color:red;”>This is a Red Heading</h2>
</body>
</html>

The front-end of the code above will eventually look like this:

This is a Red Heading

Business without CSS – pretty grim!

Cascading Style Sheets are hugely important to business today. Imagine a website without it. We’d be looking at just text with no style. Just like HTML, CSS is a hugely important and sought-after skill in today’s world. Look at any job site and you will see how in-demand it is.  As a result, wise new coders are learning it.

Learn some basic CSS for free

So, if you want to learn some of the basics of CSS, as well as HTML and JavaScript, Code Institute offers a free 5 Day Coding Challenge. After just one hour a day for five days, you will have built your first-ever web page. Register today through the form below and take your first steps in becoming a coder.