pH SCALE TUTORIAL

This tutorial is a companion to the video. You can copy/paste the large lines of code from here. Although this tutorial uses codepen.io,

you can use any environment that you are comfortable with eg local HTML/CSS with a text editor, repl.it, w 3 schools, Atom, Sublime Text

Use the blue buttons to see code and get help. It is recommended that you click the buttons after you have finished to close each section.

There is no javascript in this program, it is used to cover the basics of CSS that you will be using in other programs that do have javascript.


PREPARE HTML AND CSS


1) CREATE P ELEMENTS

Add three paragraph elements to the html section:

In the HTML section create 3 paragraph tags:

2) TARGET ALL OF THE P ELEMENTS WITH CSS

In the CSS section, target ALL paragraph elements:



You should see something like this:


3) TARGET EACH P ELEMENT INDIVIDUALLY WITH CSS

Use the id selector to target each element seperately.

To be able to target each element with CSS and give them different background colours use the id=”” attribute in each P tag.

In the HTML section, add in id="red", "green", and "purple" as below:




In the CSS section use the hash tag to target each element by its id as shown below:



Each of these id’s target the corresponding CSS element, and the code inside the curly braces affects the targeted element.



The output should be something like this:

hint! - scroll back up to close this section by using the blue button


4) UPDATE ID NAMES AND #CSS

Update the id names and #CSS to better reflect when we have all 15 elements in there.

Copy and paste the following two sections of code over the HTML and CSS sections and check your code.



HTML section:

<p id="zero" > 00 Acidic </p >
<p id="one" > 01 </p >
<p id="two" > 02 </p >
<p id="three" > 03 </p >
<p id="four" > 04 </p >
<p id="five" > 05 </p >
<p id="six" > 06 </p >
<p id="seven" > 07 Neutral</p >
<p id="eight" > 08 </p >
<p id="nine" > 09 </p >
<p id="ten" > 10 </p >
<p id= "eleven" > 11 </p >
<p id="twelve"> 12 </p >
<p id="thirteen" > 13 </p >
<p id="fourteen" > 14 Alkaline </p >


CSS section:

#zero{
    background-color: red;
}

#seven{
    background-color: green;
}

#fourteen {
    background-color: purple;
}


Check your work:

The output should be something like this:


Even though we have 15 elements, only 3 of them have been targeted by the CSS



5) UPDATE COLOURS TO HEXADECIMAL CODE

Using Hexadecimal code to select colours gives us more of a range:


Hexadecimal = #RRGGBB (red, green, blue)

#ff0000 is 2 red values, 0 green values and 0 blues values

#00ff00 is 0 red values, 2 green values, and 0 blues values

#ff00ff is 2 red values, 0 green values and 2 blue values


Copy and paste the following CSS code to change from words to Hexadecimal:

#zero{

     background-color: #0000ff;

}

#seven{

     background-color: #00ff00;

}

#fourteen{

     background-color: #ff00ff;

}



Check your work:



3 elements selected now using CSS rgb colour selection.



6) UPDATE COLOURS TO RGB CODE

Start with these three updated CSS identifiers and check your result.

#zero{

    background-color: rgb(0, 136, 221);

}

#seven{

     background-color: rgb(0, 187, 136);

}

#fourteen {

    background-color: rgb(238, 62, 128);

}




7) UPDATE CSS FOR ALL ELEMENTS

Copy and paste this CSS over the three selectors


#zero {

     background-color: rgb(231, 32, 25);

}

#one {

     background-color: rgb(237, 104, 1);

}

#two {

     background-color: rgb(246, 198, 0);

}

#three{

     background-color: rgb(244, 237, 0);

}

#four{

     background-color: rgb(182, 211, 0);

}

#five {

     background-color: rgb(137, 195, 23);

}

#six {

     background-color: rgb(91, 182,51);

}

#seven{

     background-color: rgb(66,168,59);

}

#eight {

     background-color: rgb(58, 180, 97);

}

#nine{

     background-color: rgb(49,183,184);

}

#ten {

     background-color: rgb(74,141,209);

}

#eleven{

     background-color: rgb(56,82,169);

}

#twelve {

     background-color: rgb(88,80,165);

}

#thirteen {

     background-color: rgb(97,67,163);

}

#fourteen {

     background-color: rgb(67,42,134);

}

Check your work:





FROM VERTICAL TO HORIZONTAL


8) TARGET BODY AND ALL P ELEMENTS

Use CSS to target the body and paragraph elements.

Centre text, change font to white and 25px;

body {

     Text-align: center;

}

p {

     color: white;

     font-size: 25px;

}




9) FLOAT P ELEMENTS

Now we want to make the P elements horizontal instead of vertical

Add in these three lines to the P CSS one at a time so you can see the effect.





10) ADD TITLE

Create a h1 element

Target the h1 element using CSS