Professional Documents
Culture Documents
AGENDA
❑ How Web works?
❑ HTML Introduction
▪ The structure of an HTML document
▪ HTML Tags and Attributes : <html>, <head>, <body>
▪ HTML Headings & Paragraphs
▪ HTML Text Formatting
▪ HTML Images
▪ HTML Hyperlinks
▪ HTML Lists
▪ Html Tables
▪ Html Container Tags
▪ Html5 Tags
▪ Html Forms
❑ Exercise
How Web Works ? (1)
▪ An HTML element is defined by a start tag, some content, and an end tag.
▪ The HTML element is everything from the start tag to the end tag.
▪ All HTML elements can have attributes
▪ Attributes provide additional information about elements
▪ Attributes are always specified in the start tag
▪ Attributes usually come in name/value pairs like: name="value"
❑ Paragraph
• The HTML <p> element defines a paragraph.
• A paragraph always starts on a new line, and browsers automatically add
some white space (a margin) before and after a paragraph.
<p>This is a paragraph.</p>
HTML Text Formatting
❑ HTML contains several elements for defining text with a special meaning.
HTML Images
❑ Images can improve the design and the appearance of a web page.
▪ The HTML <img> tag is used to embed an image in a web page.
▪ The <img> tag is empty, it contains attributes only, and does not have a closing tag.
▪ The <img> tag has two required attributes:
src - Specifies the path to the image
alt - Specifies an alternate text for the image
▪ A link does not have to be text. A link can be an image or any other HTML
element!
▪ The HTML <a> tag defines a hyperlink.
▪ The most important attribute of the <a> element is the href attribute, which
indicates the link's destination.
❑ In HTML there are some semantic elements that can be used to define different
parts of a web page:
▪ The HTML <form> element defines a form that is used to collect user input. An
HTML form contains form elements.
▪ Form elements are different types of input elements, like: text fields,
checkboxes, radio buttons, submit buttons, and more.
▪ The <input> element is the most important form element.
▪ The <input> element is displayed in several ways, depending on
the type attribute.
HTML Forms (2)
❑ An HTML form is used to collect user input. The user input can then be sent to a
server for processing.
• The rows attribute specifies the visible number of lines in a text area.
• The cols attribute specifies the visible width of a text area.
HTML Forms (3)
❑ An HTML form is used to collect user input. The user input can then be sent to a
server for processing.
▪ Define your own HTML page by using the elements studied in this module. Try
to be creative by creating a simple page with the theme you want (ex: create
a page for a blog ).
AGENDA
❑ CSS Introduction
▪ How to use CSS
▪ CSS Selectors
▪ CSS Priority
▪ CSS Properties
▪ CSS Font-Styling
▪ CSS Borders
▪ CSS Element Alignment
▪ CSS Box Model
▪ CSS Layout
▪ CSS Displaying Elements
▪ CSS Pseudo-Classes
▪ CSS3 Features
▪ CSS Libraries
❑ Exercise
CSS Introduction
❑ What is CSS?
▪ The height and width properties are used to set the height and width of an
element. It sets the height/width of the area inside the padding, border, and
margin of the element.
▪ The height and width properties may have the following values:
o auto - This is default. The browser calculates the height and width
o length - Defines the height/width in px, cm etc.
o % - Defines the height/width in percent of the containing block
o initial - Sets the height/width to its default value
o inherit - The height/width will be inherited from its parent value
div {
height: 200px;
width: 50%;
background-color: powderblue;
}
CSS Properties (2)
❑ CSS Color and Background Color Properties
▪ In CSS, a color can be specified by using a color name. In CSS, colors can also
be specified using RGB values, HEX values, HSL values, RGBA values, and HSLA
values.
▪ Color and background-color accept literal values (eg. green, red, magenta,…)
or functions like RGBA (eg. #000, #0FF9BB, …).
.serif {
font-family: "Times New Roman", Times, serif;
}
▪ The font-size property sets the size of the text. The font-size value can be an absolute,
or relative size.
▪ Absolute size:
o Sets the text to a specified size
o Does not allow a user to change the text size in all browsers (bad for accessibility
reasons)
o Absolute size is useful when the physical size of the output is known
▪ Relative size:
o Sets the size relative to surrounding elements
o Allows a user to change the text size in browsers
CSS Font-Styling
▪ The font-weight property sets how thick or thin characters in text should be
displayed.
p.normal {
font-weight: normal;
}
p.thick {
font-weight: bold;
}
p.thicker {
font-weight: 900;
}
CSS Font-Styling
❑ The text-decoration property accepts values like underline and strikethrough
and sets the decorations of the text.
h1 {
text-decoration: overline;
}
h2 {
text-decoration: line-through;
}
h3 {
text-decoration: underline;
}
h4 {
text-decoration: underline
overline;
}
CSS Borders
❑ The CSS border properties allow you to specify the style, width, and color of an
element's border.
▪ In CSS, there are also properties for specifying each of the borders (top, right,
bottom, and left)
• The border property is a shorthand property for the following individual border
properties: p{
border-width border-bottom: 6px solid red;
border-style (required) background-color: lightgrey;
border-color }
p{
border-top-style: dotted;
border-right-style: solid;
border-bottom-style: dotted;
border-left-style: solid;
}
CSS Element Alignment (1)
❑ Text-align property accepts left, right, center and justify values and aligns the text
horizontally within the container.
▪ To center the text inside an element, use text-align: center.
❑ The CSS padding properties are used to generate space around an element's
content, inside of any defined borders.
▪ CSS has properties for specifying the padding for each side of an element:
div {
padding-top border: 1px solid black;
padding-right background-color: lightblue;
padding-bottom padding-top: 50px;
padding-right: 30px;
padding-left
padding-bottom: 50px;
padding-left: 80px;
}
CSS Element Alignment (2)
❑ The CSS margin properties are used to create space around elements, outside of
any defined borders.
▪ There are properties for setting the margin for each side of an element (top, right,
bottom, and left).
▪ CSS has properties for specifying the margin for each side of an element:
margin-top div {
border: 1px solid black;
margin-right
margin-top: 100px;
margin-bottom margin-bottom: 100px;
margin-left margin-right: 150px;
margin-left: 80px;
background-color: lightblue;
}
CSS Box Model
❑ The following diagram demonstrates how the width, height, padding, border, and
margin CSS properties determines how much space an element can take on a
web page.
CSS Layout (1)
❑ All elements by default have a property named position.
▪ The position property specifies the type of positioning method used for an element
(static, relative, fixed, absolute or sticky).
▪ There are five different position values:
static relative
fixed absolute sticky
▪ Its default value is static, meaning the elements are just rendered straightforward
on the nearest available space.
▪ Elements are then positioned using the top, bottom, left, and right properties.
However, these properties will not work unless the position property is set first.
▪ An element with position : static is not positioned in any special way; it is always
positioned according to the normal flow of the page.
div.static {
position: static;
border: 3px solid #73AD21;
}
CSS Layout (2)
▪ An element with position : relative is positioned relative to its normal position.
div.relative {
position: relative;
left: 30px;
border: 3px solid #73AD21;
}
▪ An element with position: fixed; is positioned relative to the viewport, which means
it always stays in the same place even if the page is scrolled. The top, right,
bottom, and left properties are used to position the element.
div.fixed {
position: fixed;
bottom: 0;
right: 0;
width: 300px;
border: 3px solid #73AD21;
}
CSS Layout (3)
div.relative {
position: relative;
width: 400px;
height: 200px;
border: 3px solid #73AD21;
}
div.absolute {
position: absolute;
top: 80px;
right: 0;
width: 200px;
height: 100px;
border: 3px solid #73AD21;
}
▪ An element with position: sticky; is positioned based on the user's scroll position.
▪ A sticky element toggles between relative and fixed, depending on the scroll position.
CSS Displaying Elements
❑ The display property specifies the display behavior (the type of rendering box) of
an element. All elements by default have a display property but it varies on the
type of the element.
CSS Pseudo-Classes
❑ A pseudo-class is used to define a special state of an element.
selector:pseudo-class {
▪ The syntax of pseudo-classes:
property: value;
}
hover -> defines a style that should be applied to the element once it is
hovered by cursor.
first-child -> defines a style for the first element in a list of elements.
nth-child(n) -> does that for any of the child elements.
link -> is a style for unvisited links.
visited-> is a style for visited links.
active -> and focus -> are styles for elements that are currently focused on by
the user.
CSS3 Features (1)
▪ Border-radius - The border-radius property can be used to create rounded
corners. This property typically defines the shape of the corner of the outer border
edge.
.box {
width: 300px;
height: 150px;
background: #ffb6c1;
border: 2px solid #f08080;
border-radius: 20px;
}
h1 {
text-shadow: 5px 5px 10px #666;
}
h2 {
text-shadow: 5px 5px 10px red, 10px 10px 20px yellow;
}
▪ <script
To execute JS code, yousrc=“script.js”></script>
can simply put it in <script> tag in your HTML.
▪ The extension for a JavaScript file is .js
▪ In HTML, JavaScript code is inserted between <script> and </script> tags.
JS Alerts and Logs
❑ JavaScript can "display" the output in two ways :
▪ alert - > creates a dialog window
▪ console.log -> prints the output into Console tab in your browser
▪ document.write is used on an HTML page to display text on the screen.
<!DOCTYPE html>
<html>
<!DOCTYPE html>
<body>
<html>
<body>
<h1>My First Web Page</h1>
<p>My first paragraph.</p>
<script>
console.log(5 + 6);
<script>
</script>
alert(5 + 6);
</script>
</body>
</html>
</body>
</html>
JS Variables
❑ JavaScript is case-sensitive. This means that variables, language keywords,
function names, and other identifiers must always be typed with a consistent
capitalization of letters.
▪ You can define a variable with the var keyword, whereas the assignment
operator (=) is used to assign value to a variable, like this:
▪ In JavaScript, if a variable has been declared, but has not been assigned a
value explicitly, is automatically assigned the value undefined.
JS Data Comparison (1)
❑ The comparison operators are used to compare two values in a Boolean
fashion.
❑ There are two operators for comparison:
== compares values.
=== compares values and types.
JS Data Comparison (2)
JS Operators
❑ The arithmetic operators are used to perform common arithmetical operations,
such as addition, subtraction, multiplication.
JS Arrays (1)
❑ JavaScript arrays can store any valid value, including strings, numbers, objects,
functions, and even other arrays, thus making it possible to create more
complex data structures such as an array of objects or an array of arrays.
▪ Defining an array in JS:
▪ The length property returns the length of an array, which is the total number of
elements contained in the array.
JS Objects (1)
❑ A JavaScript object is just a collection of named values. These named values
are usually referred to as properties of the object.
▪ An object can be created with curly brackets {} with an optional list of
properties.
▪ A property is a "key: value" pair, where the key (or property name) is always a
string, and value (or property value) can be any data type, like strings,
numbers, Booleans or complex data type like arrays, functions, and other
objects.
JS Objects (2)
Accessing Object's Properties
▪ To access or get the value of a property, you can use the dot (.), or square
bracket ([]) notation.
JS Functions
Defining and Calling a Function
▪ The declaration of a function start with the function keyword, followed by the
name of the function you want to create, followed by parentheses i.e. () and
finally place your function's code between curly brackets {}.
Accessing HTML Elements (1)
❑ Selecting Elements by ID
▪ An element based on its unique ID can be accessed with
the getElementById() method.
▪ The getElementById() method will return the element as an object if the
matching element was found, or null if no matching element was found in the
document.
▪ Any HTML element can have an id attribute. The value of this attribute must be
unique within a page i.e. no two elements in the same page can have the
same ID.
❑ By convention, the names for event handlers always begin with the word "on",
so an event handler for the click event is called onclick, similarly an event
handler for the load event is called onload.
❑ There are several ways to assign an event handler. The simplest way is to add
them directly to the start tag of the HTML elements using the special event-
handler attributes.
JS Binding Events (2)
What is TypeScript?
❑ TypeScript is an open-source, object-oriented programing language.
❑ It is a language for application-scale JavaScript development, which can be
executed on any browser, any Host, and any Operating System.
❑ TypeScript is not directly run on the browser. It needs a compiler to compile
and generate in JavaScript file.
❑ TypeScript is the ES6 version of JavaScript with some additional features.
❑ It contains all elements of the JavaScript.
❑ TS is used in a variety of JS frameworks - including Angular
AGENDA
❑ Angular Introduction
▪ Angular Evolution
▪ How do Client-Side Frameworks Work ?
▪ Angular Architecture
▪ App Structure
▪ Angular Main Building Blocks
▪ Modules
▪ Components
▪ Templates
▪ Meta Data
▪ Data Binding
▪ Directives
▪ Event Handlers
▪ Routing
❑ Exercise
Angular Introduction
❑ Angular is a client-side framework written in TypeScript. Angular works on the
browser level and helps organize the view layer, plus handles the basic routing.
❑ Angular provides tools to connect to the backend layer that can be written
on any language – e.g. Java.
❑ Modules
❑ Components
❑ Templates
❑ Metadata
❑ Data binding
❑ Directives
❑ Services
❑ Dependency injection
Angular Modules (1)
❑ Angular apps are modular and Angular has its own modularity system called
Angular modules or NgModules.
❑ Every Angular app has at least one Angular module class, the root module,
conventionally named AppModule.
❑ An Angular module, whether a root or feature, is a class with an @NgModule
decorator.
❑ Decorators are functions that modify JavaScript classes.
Angular Modules (2)
❑ NgModule is a decorator function that takes a single metadata object whose
properties describe the module. The most important properties are:
▪ declarations - the view classes that belong to this module. Angular has three
kinds of view classes: components, directives, and pipes.
▪ exports - the subset of declarations that should be visible and usable in the
component templates of other modules.
▪ bootstrap - the main application view, called the root component, that hosts
all other app views. Only the root module should set this bootstrap property.
Angular Modules (3)
Angular Modules (5)
Angular Modules (4)
❑ Import Angular's Component decorator from the @angular/core library like this:
❑ You also import Angular modules from Angular libraries using JavaScript import
statements:
Angular Modules (4)
❑ If the application module needs material from within that BrowserModule, you
need to add it to the @NgModule metadata imports like this:
▪ selector: CSS selector that tells Angular to create and insert an instance of this
component where it finds a <app-root>tag which is Parent Component.
▪ templateUrl: module-relative address of this component's HTML template.
▪ providers: array of dependency injection providers for services that the
component requires.
❑ The metadata in the @Component tells Angular where to get the major
building blocks you specify for the component.
❑ The template, metadata, and component together describe a view.
Angular Data Binding (1)
❑ Data binding plays an important role in communication between a template and its
component.
❑ Angular supports data binding, a mechanism for coordinating parts of a template
with parts of a component. Add binding markup to the template HTML to tell
Angular how to connect both sides.
❖ *ngFor tells Angular to stamp out one <li> per hero in the heroes list.
❖ *ngIf includes the HeroDetail component only if a selected hero exists.
Angular Directives (2)
❑ Render a list using directive ngFor:
Angular Directives (3)
Angular Directives (4)