Get 25% off for the next 48:23:55 hours

Adding cascading style sheets—CSS

Cascading style sheets are the way we define the presentation of the HTML pages, from font and colors to the layout of your page. HTML documents may contain style sheet rules directly in them or they may import style sheets.

There are THREE ways of setting style sheets to your webpage:

  • External style sheet
  • Internal style sheet
  • Inline style

External style

An external style sheet is a separate file where you can define all the styles that you want to use on your website. This is ideal when you want the same style on multiple pages. An external style sheet makes it is easier to to change the look of the entire website and reuse your CSS. You can make drastic changes to your web pages with just a few changes in a single CSS file.

For example code in HTML to link to CSS file
<head>
<link rel="stylesheet" type="text/css" href="css/eg-css-file.css">
</head>

In the example below you can see the file paths, the CSS and HTML files open and what the output is. CSS,HTML and a file explorer showing how they are connected

Internal style sheet

An internal style sheet is a section on a HTML page that contains style definitions. this type of style sheet should be used when a single document has a unique style. They are defined by using the <style></style> tags between the <head> area of the document.

For example
<style>
body{
  background-color: steelBlue;
  border:1px dashed gray;
  color:white;
}
h1 {
  background-color: lightSteelBlue;
  margin-left: 25px;
}
</style>

<h1>h1 tag</h1>

12345678

Inline style

Inline Style refers to the style sheet information being written inside an element. This is useful when you want to apply a simple style only once. This should be used sparingly.

It does override CSS written externally and internally.

For example
<h3 style=''>This text has no CSS added</h3>

<h3 style='color:steelBlue;'>This text has CSS added</h3>

<h3 style=''>This text has no CSS added</h3>

What happens when you add an internal style sheet as well to change h3 elements?

<style>
  h3{
    color:mediumSeaGreen;
  }
</style>
<h3>This text has 'internal CSS' added</h3>

<h3 style='color:steelBlue;'>This text has 'inline CSS' added</h3>

<h3>This text has 'internal CSS' added</h3>
  • download
  • new file
  • upload media
  • rename

  • delete
Next task Ctrl+Space
Run Ctrl+Enter
Check Ctrl+Shift+Enter
Reset Ctrl+Backspace
Undo Ctrl+Z
Redo Ctrl+Y
Cut Ctrl+X
Copy Ctrl+C
Paste Ctrl+V
Find Ctrl+F
Find & replace Ctrl+F+F

Keyboard Shortcuts

Code Avengers Tasks

Check/Next CTRL+ENTER
Run CTRL+SHIFT+ENTER
Reset CTRL+BACKSPACE

Editting Code

Undo CTRL+Z
Redo CTRL+Y
Cut CTRL+X
Copy CTRL+C
Paste CTRL+V
Find CTRL+F
Find & replace CTRL+F+F

Toolbox

My Notes

Loading Notes...

Code Avengers Code Avengers
  • {{ $t('HeaderMenu', 'Navigation1') }}
  • {{ item.text }}
  • {{ $t('HeaderMenu', 'Navigation2') }}
  • {{ item.text }}
  • {{ $t('HeaderMenu', 'Navigation4') }}
  • {{ link.text }}
  • {{ $t('Shared', 'Support') }}
  • {{ item.text }}
{{ link.text }}