SlideShare a Scribd company logo
UNTANGLING THE WEB Class 4: HTML, CSS, and JS
AGENDA
--Project 1 presentations
--Quick introduction to javascript
 An introduction to code
 Using jsfiddle
--Using your web server
--CSS
--flexbox
PRESENTATIONS
Each group gets 10 minutes max for presentation and questions
Don’t worry if you don’t take all 10 minutes, if you can get across
why your business idea is so compelling in two minutes then you’re
way ahead of the game!
Make sure to leave a little bit of question time
After the presentation – send me an email (one per group) with a copy
of the presentation, or at least the business model canvas and
website design.
USING JSFIDDLE
JSFiddle.net is a site where you can make quick sketches of code and
see them run.
It’s sometimes easier to use a site like this than to code from scratch,
but in the end developing locally and on github is more useful
Console.log is very useful, but it doesn’t print on the page! Have to
use the dev console.
Access DevTools On Windows On Mac
Open Developer
Tools
F12, Ctrl + Shift +
I
Cmd + Opt + I
HTML AND JS TOGETHER
Separate code and data
 Kind of an old paradigm, hard to do that, but html/js comes about from when that
was the goal
 For simple stuff we’ll still treat them as separate. Except when they have to interact
 https://jsfiddle.net/xde554am/ (example we’ll walk through)
Of course, in some frameworks this is exactly backwards. JSX is a
form of javascript for the facebook react toolkit that is fully
intermingled data and presentation. EJS templates are another way of
doing that.
JSFIDDLE VERSUS SEPARATE
PAGES
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
In the head or body (not that you have these option in jsfiddle as well)
<script type="text/javascript" src="somefile.js"></script>
https://jsfiddle.net/xde554am/1/
WHAT IS JAVASCRIPT?
A programming language
- variables
- APIs (Application Programming Interfaces)
- control flow (if/then, while, switch, etc.)
- objects and methods – JS is an Object Oriented programming
language (OO)
There is another class of language called functional programming
that we may introduce later. Neither is superior, but the require
different ways of thinking, and some problems are best suited to one
or the other.
VARIABLES IN THE HTML
 https://jsfiddle.net/egrs4j7a/4/
 In the HTML
 <p id="foo"></p>
In the JS
 var myText = "Hello";
 document.getElementById('foo').innerHTML = myText;
BUTTONS
<input type="submit" id="byBtn" value="Change"
onclick="change()"/>
 Causes page refresh, server loop
 Some styling differences
Versus
<button id="byBtn" onclick="change()">click me</button>
 No page refresh
 Client side action only
 Issues prior to IE6, but don’t care about that anymore
See http://particletree.com/features/rediscovering-the-button-
element/
PAGES ON THE WEBSERVER
For most of the rest of this class, you will be placing you pages on
the webserver. These are the credentials that I emailed to each of you
today. For instance, my silly simplest webpage example from last
week is now being served up at:
http://cspubl.uvic.ca/~dev00/testrepo/file.html
It still doesn’t do anything useful, of course, but I want to show you
how it got there
INSTALLING AN SSH CLIENT
(OPTIONAL)
Your bash shell can technically do SSH commands, but in order to
save typing I like to use a client to open my remote shells for me
I use KiTTY on windows (http://kitty.9bis.net/) or PuTTY
(http://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html) on
Unix
The terminal app directly does this on Mac.
Basically the only advantage is that it saves all of your settings across
sessions. So for this exercise we will just use the Bash shell
Untangling spring week4
IN DETAIL
ssh dev00@206.12.96.242
“dev00” gets replaced by your userid on the server from the email
206.12.96.242 is the ip address of the server we’ll be using for the rest of
the term
Can also use ssh dev00@cspubl.uvic.ca instead. (Why? DNS)
The first time it will say “the authenticity of the host cannot be established”
and ask you if you want to continue. Say yes.
Then enter your password (from the email)
WHAT NOW?
This is a bash shell on a remote server.
You won’t want to interact much on here, but there are a few things
you’ll want to do:
-- clone your webpage projects from git
-- possibly move files up and down manually
-- eventually install and build your webpage, when we get to pages
that require that
We’ll talk only about the first one today
SERVER DIRECTORIES
The public_html directory is the root of your webserver. (actually
there is one webserver for the whole class, but you each have a virtual
root)
This is accessed from cspubl.uvic.ca/~dev00
So if there were an “index.html” file at that root it would be displayed
when you type the above into your address bar (substituting your
devXX number, of course)
But we’ll want multiple projects on there, so we need to clone into
subdirectories and navigate there
CLONING FROM AN EXISTING
PROJECT
Go to github and copy the clone address (green button, for instance
https://github.com/derekja/testrepo.git)
“cd public_html” to get into the root of your webserver
“git clone https://github.com/derekja/testrepo.git” to make the new
subdirectory and populate with the contents of your project
Navigate in a browser, for instance
http://cspubl.uvic.ca/~dev00/testrepo/file.html
EXERCISE 1
Log onto your webserver, and clone your homework 2 or 3 project
(whichever has a better html file)
CSS INTRO – CASCADING STYLE
SHEETS
CSS is just styling on top of HTML
Everything should generally run the same without it, it will just look
ugly
In my example site a few weeks ago, I was using LESS. LESS and SASS
(among others) are CSS variants that compile down to CSS files but
use variables and some program control to make expressions easier
WAYS OF SELECTING TEXT
#id
 #id { color: black;}
.class
 .class { font-size:30px;}
tag
 p { text-align: center;}
CASCADING
HTML tags get superseded by classes and specific id’s
Classes get superseded by specific id’s
Specific id’s win
Unless something is marked important!
CSS EXERCISES
https://jsfiddle.net/sw465f3a/
Make “I’m a paragraph” green and 40px high
Make “another paragraph” blue
Make “more text” and the button red
EXERCISE ANSWERS
https://jsfiddle.net/sw465f3a/1/
Can you make all the paragraph tags blue without changing the class
or id specifiers?
https://jsfiddle.net/sw465f3a/2/
FLEXBOX
This is a system to allow elements to be flexibly positioned
Property Chrome IE Firefox Safari Opera
Basic support
(single-line flexbox)
29.0
21.0 -
webkit-
11.0 22.0
18.0 -moz-
6.1 -
webkit-
12.1 -
webkit-
Multi-line flexbox 29.0
21.0 -
webkit-
11.0 28.0 6.1 -
webkit-
17.0
15.0 -
webkit-
12.1
FLEXBOX FROGGY
Let’s take 10 or 15 minutes to do some examples
http://flexboxfroggy.com/
HOMEWORK 4
1) Build a website that uses HTML and CSS
 Can be very simple, but must have both elements in different files
 Use flexbox for full marks, but just changing colours or something will get you
most of the marks
2) Check the website into a new repository on github called “hw4”
3) Clone that repository onto your web server
Send me a link to the repo and a link to your running web page.
4 points – flexbox for positioning, show that you know how to target CSS by class,
id, and tag
3 points – working CSS that provides some styling
2 points – working pages, but only on github and not your server
2) For one point, include some javascript that prints something out to the console

More Related Content

PPTX
Untangling spring week5
PPTX
Untangling spring week8
PPTX
Untangling spring week10
PPTX
Untangling spring week9
PPTX
Untangling the web11
PPTX
Untangling the web10
PPTX
Untangling7
PPTX
Untangling the web - fall2017 - class 4
Untangling spring week5
Untangling spring week8
Untangling spring week10
Untangling spring week9
Untangling the web11
Untangling the web10
Untangling7
Untangling the web - fall2017 - class 4

What's hot (20)

PPTX
Untangling spring week11
PPTX
Untangling spring week6
PPTX
Untangling the web9
PPTX
Untangling6
PPTX
Untangling - fall2017 - week6
PPTX
Untangling - fall2017 - week 7
PPTX
Untangling spring week7
PPTX
Untangling fall2017 week1
PPTX
Untangling spring week2
PPTX
Untangling spring week12
PPTX
Untangling - fall2017 - week 8
PPTX
Untangling - fall2017 - week 9
PPTX
Untangling8
PPTX
Untangling - fall2017 - week 10
PPTX
Untangling11
PPTX
What is HTML 5?
PPTX
SharePoint Development 101
PDF
The What & Why of Pattern Lab
PPTX
5 things STILL! TOO! HARD! in Plone 5
PDF
Plone 5 theming
Untangling spring week11
Untangling spring week6
Untangling the web9
Untangling6
Untangling - fall2017 - week6
Untangling - fall2017 - week 7
Untangling spring week7
Untangling fall2017 week1
Untangling spring week2
Untangling spring week12
Untangling - fall2017 - week 8
Untangling - fall2017 - week 9
Untangling8
Untangling - fall2017 - week 10
Untangling11
What is HTML 5?
SharePoint Development 101
The What & Why of Pattern Lab
5 things STILL! TOO! HARD! in Plone 5
Plone 5 theming
Ad

Viewers also liked (14)

PPTX
Untangling spring week3
PPTX
Untangling spring week1
PPTX
Untangling the web week1
PPTX
Untangling the web week 2 - SEO
PPTX
Untangling4
PPTX
Untangling the web - week 3
PPTX
Biohacking
PDF
How to Become a Thought Leader in Your Niche
PPTX
PPTX
Discapacidad visual
PPTX
Mapa mental cooperativas
PDF
Ryan del rosario
PDF
Desigualdade de gênero no brasil
PDF
Beyond the Gig Economy
Untangling spring week3
Untangling spring week1
Untangling the web week1
Untangling the web week 2 - SEO
Untangling4
Untangling the web - week 3
Biohacking
How to Become a Thought Leader in Your Niche
Discapacidad visual
Mapa mental cooperativas
Ryan del rosario
Desigualdade de gênero no brasil
Beyond the Gig Economy
Ad

Similar to Untangling spring week4 (20)

PPTX
HTML and CSS.pptx
PPTX
HTML, CSS, and Javascript for Web developed by hu
PDF
Html5, css3 y js
PDF
BYOWHC823
PDF
Code & Design your first website 4/18
PDF
Code &amp; design your first website (3:16)
PDF
Cape Cod Web Technology Meetup - 3
PDF
web development
PPTX
25444215.pptx
PDF
Introduction to web programming with JavaScript
PDF
Intro to-html-backbone-angular
PDF
Javascript Html Css A Stepbystep Guide Student Student
PPTX
025444215.pptx
PPTX
workshopsisnotreallyrrwardingitsinot.pptx
PPTX
EdTechJoker Spring 2020 - Lecture 4 - HTML
PDF
Having Fun Building Web Applications (Day 1 Slides)
PDF
Build a Web App with JavaScript and jQuery (5:18:17, Los Angeles)
PDF
Hello Html5 Css3 A User Friendly Reference Guide Rob Crowther
PPTX
Workshop html5, css3 & github
PDF
Week 05 Web, App and Javascript_Brandon, S.H. Wu
HTML and CSS.pptx
HTML, CSS, and Javascript for Web developed by hu
Html5, css3 y js
BYOWHC823
Code & Design your first website 4/18
Code &amp; design your first website (3:16)
Cape Cod Web Technology Meetup - 3
web development
25444215.pptx
Introduction to web programming with JavaScript
Intro to-html-backbone-angular
Javascript Html Css A Stepbystep Guide Student Student
025444215.pptx
workshopsisnotreallyrrwardingitsinot.pptx
EdTechJoker Spring 2020 - Lecture 4 - HTML
Having Fun Building Web Applications (Day 1 Slides)
Build a Web App with JavaScript and jQuery (5:18:17, Los Angeles)
Hello Html5 Css3 A User Friendly Reference Guide Rob Crowther
Workshop html5, css3 & github
Week 05 Web, App and Javascript_Brandon, S.H. Wu

Recently uploaded (20)

PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Insiders guide to clinical Medicine.pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Complications of Minimal Access Surgery at WLH
PDF
Basic Mud Logging Guide for educational purpose
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Business Ethics Teaching Materials for college
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Classroom Observation Tools for Teachers
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Pre independence Education in Inndia.pdf
Microbial diseases, their pathogenesis and prophylaxis
Insiders guide to clinical Medicine.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Complications of Minimal Access Surgery at WLH
Basic Mud Logging Guide for educational purpose
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Business Ethics Teaching Materials for college
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Classroom Observation Tools for Teachers
human mycosis Human fungal infections are called human mycosis..pptx
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
Final Presentation General Medicine 03-08-2024.pptx
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Microbial disease of the cardiovascular and lymphatic systems
Pre independence Education in Inndia.pdf

Untangling spring week4

  • 1. UNTANGLING THE WEB Class 4: HTML, CSS, and JS
  • 2. AGENDA --Project 1 presentations --Quick introduction to javascript  An introduction to code  Using jsfiddle --Using your web server --CSS --flexbox
  • 3. PRESENTATIONS Each group gets 10 minutes max for presentation and questions Don’t worry if you don’t take all 10 minutes, if you can get across why your business idea is so compelling in two minutes then you’re way ahead of the game! Make sure to leave a little bit of question time After the presentation – send me an email (one per group) with a copy of the presentation, or at least the business model canvas and website design.
  • 4. USING JSFIDDLE JSFiddle.net is a site where you can make quick sketches of code and see them run. It’s sometimes easier to use a site like this than to code from scratch, but in the end developing locally and on github is more useful Console.log is very useful, but it doesn’t print on the page! Have to use the dev console. Access DevTools On Windows On Mac Open Developer Tools F12, Ctrl + Shift + I Cmd + Opt + I
  • 5. HTML AND JS TOGETHER Separate code and data  Kind of an old paradigm, hard to do that, but html/js comes about from when that was the goal  For simple stuff we’ll still treat them as separate. Except when they have to interact  https://jsfiddle.net/xde554am/ (example we’ll walk through) Of course, in some frameworks this is exactly backwards. JSX is a form of javascript for the facebook react toolkit that is fully intermingled data and presentation. EJS templates are another way of doing that.
  • 6. JSFIDDLE VERSUS SEPARATE PAGES <head> <link rel="stylesheet" type="text/css" href="mystyle.css"> </head> In the head or body (not that you have these option in jsfiddle as well) <script type="text/javascript" src="somefile.js"></script> https://jsfiddle.net/xde554am/1/
  • 7. WHAT IS JAVASCRIPT? A programming language - variables - APIs (Application Programming Interfaces) - control flow (if/then, while, switch, etc.) - objects and methods – JS is an Object Oriented programming language (OO) There is another class of language called functional programming that we may introduce later. Neither is superior, but the require different ways of thinking, and some problems are best suited to one or the other.
  • 8. VARIABLES IN THE HTML  https://jsfiddle.net/egrs4j7a/4/  In the HTML  <p id="foo"></p> In the JS  var myText = "Hello";  document.getElementById('foo').innerHTML = myText;
  • 9. BUTTONS <input type="submit" id="byBtn" value="Change" onclick="change()"/>  Causes page refresh, server loop  Some styling differences Versus <button id="byBtn" onclick="change()">click me</button>  No page refresh  Client side action only  Issues prior to IE6, but don’t care about that anymore See http://particletree.com/features/rediscovering-the-button- element/
  • 10. PAGES ON THE WEBSERVER For most of the rest of this class, you will be placing you pages on the webserver. These are the credentials that I emailed to each of you today. For instance, my silly simplest webpage example from last week is now being served up at: http://cspubl.uvic.ca/~dev00/testrepo/file.html It still doesn’t do anything useful, of course, but I want to show you how it got there
  • 11. INSTALLING AN SSH CLIENT (OPTIONAL) Your bash shell can technically do SSH commands, but in order to save typing I like to use a client to open my remote shells for me I use KiTTY on windows (http://kitty.9bis.net/) or PuTTY (http://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html) on Unix The terminal app directly does this on Mac. Basically the only advantage is that it saves all of your settings across sessions. So for this exercise we will just use the Bash shell
  • 13. IN DETAIL ssh dev00@206.12.96.242 “dev00” gets replaced by your userid on the server from the email 206.12.96.242 is the ip address of the server we’ll be using for the rest of the term Can also use ssh dev00@cspubl.uvic.ca instead. (Why? DNS) The first time it will say “the authenticity of the host cannot be established” and ask you if you want to continue. Say yes. Then enter your password (from the email)
  • 14. WHAT NOW? This is a bash shell on a remote server. You won’t want to interact much on here, but there are a few things you’ll want to do: -- clone your webpage projects from git -- possibly move files up and down manually -- eventually install and build your webpage, when we get to pages that require that We’ll talk only about the first one today
  • 15. SERVER DIRECTORIES The public_html directory is the root of your webserver. (actually there is one webserver for the whole class, but you each have a virtual root) This is accessed from cspubl.uvic.ca/~dev00 So if there were an “index.html” file at that root it would be displayed when you type the above into your address bar (substituting your devXX number, of course) But we’ll want multiple projects on there, so we need to clone into subdirectories and navigate there
  • 16. CLONING FROM AN EXISTING PROJECT Go to github and copy the clone address (green button, for instance https://github.com/derekja/testrepo.git) “cd public_html” to get into the root of your webserver “git clone https://github.com/derekja/testrepo.git” to make the new subdirectory and populate with the contents of your project Navigate in a browser, for instance http://cspubl.uvic.ca/~dev00/testrepo/file.html
  • 17. EXERCISE 1 Log onto your webserver, and clone your homework 2 or 3 project (whichever has a better html file)
  • 18. CSS INTRO – CASCADING STYLE SHEETS CSS is just styling on top of HTML Everything should generally run the same without it, it will just look ugly In my example site a few weeks ago, I was using LESS. LESS and SASS (among others) are CSS variants that compile down to CSS files but use variables and some program control to make expressions easier
  • 19. WAYS OF SELECTING TEXT #id  #id { color: black;} .class  .class { font-size:30px;} tag  p { text-align: center;}
  • 20. CASCADING HTML tags get superseded by classes and specific id’s Classes get superseded by specific id’s Specific id’s win Unless something is marked important!
  • 21. CSS EXERCISES https://jsfiddle.net/sw465f3a/ Make “I’m a paragraph” green and 40px high Make “another paragraph” blue Make “more text” and the button red
  • 22. EXERCISE ANSWERS https://jsfiddle.net/sw465f3a/1/ Can you make all the paragraph tags blue without changing the class or id specifiers? https://jsfiddle.net/sw465f3a/2/
  • 23. FLEXBOX This is a system to allow elements to be flexibly positioned Property Chrome IE Firefox Safari Opera Basic support (single-line flexbox) 29.0 21.0 - webkit- 11.0 22.0 18.0 -moz- 6.1 - webkit- 12.1 - webkit- Multi-line flexbox 29.0 21.0 - webkit- 11.0 28.0 6.1 - webkit- 17.0 15.0 - webkit- 12.1
  • 24. FLEXBOX FROGGY Let’s take 10 or 15 minutes to do some examples http://flexboxfroggy.com/
  • 25. HOMEWORK 4 1) Build a website that uses HTML and CSS  Can be very simple, but must have both elements in different files  Use flexbox for full marks, but just changing colours or something will get you most of the marks 2) Check the website into a new repository on github called “hw4” 3) Clone that repository onto your web server Send me a link to the repo and a link to your running web page. 4 points – flexbox for positioning, show that you know how to target CSS by class, id, and tag 3 points – working CSS that provides some styling 2 points – working pages, but only on github and not your server 2) For one point, include some javascript that prints something out to the console