CSS lets us make our HTML pages look great. In the example below, you have two files. One is called index.html and one is called style.css
We need to link together these files. To do this, copy and paste the following code so that it is on the line underneath the <title> tags on the index.html page.
<link rel="stylesheet" href="style.css">If you have done this correctly, you will see that the whole page changes colour, so does the text.
Now click on the style.css file. Your challenge is to change the colour of the background and the text.
To practice your CSS skills, you are now going to make a wanted poster look better.
Click on the “style.css” tab. You’ll notice that there are already CSS properties for the div containing the different parts of the poster.
div { text-align: center; overflow: hidden; border: 2px solid black; width: 300px;} Let’s start by altering the text-align property:
text-align: center;What happens when you change the word centre to left or right?
How about the border property?
border: 2px solid black;2px in the code above means 2 pixels. What happens when you change 2px solid black to 4px dotted red?
Change the width of the poster to 400px. What happens to the poster?
Using what you have already learned about CSS, make the background yellow.
Your files should include the code below:
index.html
<!DOCTYPE html><html><head><title>Styling Web Pages Using CSS</title><link rel="stylesheet" href="style.css"></head><body><h1>This is a page that uses HTML and CSS!</h1><p>CSS allows us to make our websites better, by changing how things look. If we want to make a change to lots of pages at the same time, all we need to do is change one line of code in the style.css file of the website. If Instagram wanted to change their font, they only need to do that in one line of code of their style.css document.</p></body></html>style.css
body { background-color: lightblue;}h1 { color: white; text-align: center;}p { font-family: verdana; font-size: 20px;} Now that you have set up your web page to use CSS, we can experiment. Test out adding these lines of code in your CSS file. Make sure to put lines of code in between the { } squiggly brackets!
Task 1: Change the background color to a colour of your choice. If you would like a very specific colour, you can use this link to get the colour codes.
Test the following and make a note of what each does:
width: 50%;text-transform: uppercase;text-shadow: 3px 2px black;font-style: italic;font-family: impact;.top {background-color: purple;padding: 20px;}If you have made this changes correctly, yours should look something like mine:
Now, using the success criteria below, use all of the skills you have learnt to create the webpage that is shown to the right.
Extension:
index.html
style.css