Introduction To HTML+CSS+Javascript - PPTX - 2
Introduction To HTML+CSS+Javascript - PPTX - 2
technologies
HTML + CSS + Javascript
● HTML
● CSS
● Javascript
Goals
Introduction to web technologies:
4
HTML Tags
● Most HTML tags work in pairs. There is an opening and a closing tag. For
example:
<p>Some content here.</p>
● The <p>…</p> tag displays a paragraph
● <p> opens the paragraph (opening tag)
● </p> closes the paragraph (closing tag)
● “Some content here.” will be displayed on the page
● Some HTML tags are self closing. For example:
<br />
● The <br /> tag will display a line break.
5
Required Tags
● All HTML documents should have html, head and body
tags, along with the DOCTYPE identifier.
8
Some Common HTML Tags and Their Meanings
● <p>…</p> -- Creates a paragraph
● <br /> -- Adds a line break
● <hr /> -- Separates sections with a
horizontal rule
● <h1>…</h1> -- Displays a heading (h1-h6)
● <!--…--> -- Inserts a comment
● <ol>…</ol> -- Creates an ordered list
● <ul>…</ul> -- Creates an unordered list
● <img /> -- Inserts an image into the
document
● <a>…</a> -- Inserts a link into the document
9
Paragraph Example
<p>
The exam next week will consist of T/F,
multiple choice, short answer and
pseudocode questions. You cannot use a
calculator.
</p>
<p> After the exam, we will learn JavaScript.
It should be fun!!
</p>
10
Paragraph Example Screenshot
11
Line Break Example
<p>
Roses are Red. <br />
Violets are Blue. <br />
You should study for Exam 1. <br />
It will be good for you!
</p>
12
Line Break Example Screenshot
13
Horizontal Rule Example
<p>
The exam next week will consist of T/F,
multiple choice, short answer and
pseudocode questions. You cannot use a
calculator.
</p>
<hr />
<p>
After the exam, we will learn JavaScript.
It should be fun!!
</p> 14
Horizontal Rule Example Screenshot
15
Heading Example
16
Heading Example Screenshot
17
Comment Example
18
Heading Example Screenshot
19
Ordered List Example
<ol>
<li>Print Review Questions for Exam 1.</li>
<li>Work on Review Questions for Exam
1.</li>
</ol>
20
Ordered List Screenshot
21
Unordered List Example
<ul>
<li>country music</li>
<li>monday mornings</li>
<li>brussels sprouts</li>
</ul>
22
Unordered List Screenshot
23
Link Example
24
Link Screenshot
25
Image Example
26
Image Screenshot
27
HTML: wrapping the info
We use HTML tags to wrap different
information on our site.
<div> <div>
Title <h1>Title</h1>
<p>Here is content.</p>
Here is some content <p>Here is more content</p>
Here is more content </div>
</div>
D O THIS
T
DON
HTML good use
It is good to have all the information properly wrapped in tags that give it some semantics.
We also can extend the code semantics by adding extra attributes to the tags:
● HTML
● CSS
● Javascript
CSS
CSS (Cascading Style Sheets) is a
stylesheet language used for describing the
look and formatting of a document written in
HTML or XML.
This will change all the tags in my web ( ‘*‘ means all) to look blue with font Tahoma with
14px, and leaving a margin of 10px around.
CSS how to add it
There are four ways to add CSS rules to your website:
div {
background-color: red;
}
This CSS rule means that every tag DIV found in our website should have a red background
color. Remember that DIVs are used mostly to represent areas of our website.
We could also change the whole website background by affecting the tag body:
body {
background-color: red;
}
CSS selectors
What if we want to change one specific tag (not all the tags of the same type).
We can specify more precise selectors besides the name of the tag. For instance, by class
or id. To specify a tag with a given class name, we use the dot:
p.intro {
color: red;
}
This will affect only the tags p with class name intro:
<p class="intro">
CSS Selectors
There are several selectors we can use to narrow our rules to very specific tags of our website.
This will affect to the p tags of class intro that are inside the tag div of id main
<div id="main">
<p class="intro">....</p> ← Affects this one
</div>
div#main.intro:hover { ... }
will apply the CSS to the any tag div with id main and class intro if the mouse is over.
And you do not need to specify a tag, you can use the class or id selectors without tag, this
means it will affect to any node of id main
#main { ... }
CSS Selectors
If you want to select only elements that are direct child of one element (not that have an
ancestor with that rule), use the > character:
Finally, if you want to use the same CSS actions to several selectors, you can use the
comma , character:
.grid-item1 {
background: blue;
border: black 5px solid;
grid-column-start: 1;
grid-column-end: 5;
grid-row-start: 1;
grid-row-end: 3;
}
CSS
Fullscreen divs html, body {
width: 100%;
height: 100%;
Sometimes we want to have a div that covers }
the whole screen (to make a webapp),
div {
instead of a scrolling website (more like margin: 0;
regular documents). padding: 0;
}
Understanding the Box Model: a good explanation of how to position the information on your
document.
● HTML
● CSS
● Javascript
Javascript
A regular programming language, easy to start, hard to master.
You can change the content of the HTML or the CSS applied to an element.
You can even send or retrieve information from the internet to update the content
of the web without reloading the page.
Javascript: insert code
There is three ways to execute javascript code in a website:
And the API keeps growing with every new update of the standard.
● Crawling the HTML tree (starting from the body, and traversing its children)
will return an array with all <p class="intro"> nodes in the web.
You can change an element CSS directly by accessing its property style.
<input type="text"/>
my_input_element.value = ""; //this will clear the text inside the input
Example of a website
HTML in index.html Javascript in code.js
<link href="style.css" rel="stylesheet"/> //fetch the button from the DOM
<h1>Welcome</h1> var button = document.querySelector(“button”);
<p>
<button>Click me</button> //attach and event when the user clicks it
</p> button.addEventListener(“click”, myfunction);
<script src=”code.js”/>
//create the function that will be called when the
button is pressed
CSS in style.css
function myfunction()
{
h1 { color: #333; } //this shows a popup window
button { alert(“button clicked!”);
border: 2px solid #AAA; }
background-color: #555;
}
Execution flow
It is important to have a clear understanding of
the execution flow of your code.
Structured like:
● Main container
○ Messages area
■ message
○ Typing area area
■ input
Further info
API References: DevDocs.io
To learn Javascript.
http://codeacademy.com
To learn jQuery:
http://docs.jquery.com/Tutorials