Linking a css file

April 20, 2016

by — Posted in CSS

So you need to link a css file to your html page in order to style that page, CSS stands for Cascading Style Sheet.

Navigate to the folder that holds your html file in which you would like to style, Create a file called style.css and save it.

Open your HTML file and within the <head></head> tags add the following code:

<link rel="stylesheet" type="text/css" href="/style.css" />

Now open your CSS file and enter copy & paste the following code:

html, body {
background: #22b673;
margin: 0;
padding: 0;
}

In the code above we have the background, margin & padding,

the background, pretty obviously, changes the style or color of the background which in our case is now green. The margin effects how far we move our element from the edges of the screen and the padding effect the distance in which we create a gap from the edge of the screen to the content within ( I know these sound the same but they are not, when you have a mess around yourself with this code you will see what I mean. )

Now open your HTMl page in a browser and you will see how the CSS code has effected your website.

 

Congrats! You have now used CSS in your website! 😀

 

Dave Lynch, Developer.

 

Leave a Reply

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