1 Introduction to HTML CSS Javascript
1 Introduction to HTML CSS Javascript
technologies
HTML + CSS + Javascript
Introduction
When you decide to develop an application using any
programming language, one of the first problem you Your Code
face is that programming languages do not include a
library to create User Interfaces.
Framework
You need to use some framework to access the OS
layer. Every programming language has at least one, Operative System
but you need to choose it first.
● HTML
● CSS
● Javascript
Browsers as a renderer
Browser's act as a renderer that takes documents
and construct a visual representation of them.
You can try, drop any .txt file into your browser to
visualize it.
My name is <b>Javi</b>
HTML
HTML means Hyper Text Markup Language.
<html>
The HTML allow us to define the structure of a document or a <head>
website. </head>
<body>
HTML is NOT a programming language, it’s a markup language,
<div>
which means its purpose is to give structure to the content of the
website, not to define an algorithm. <p>Hi</p>
</
It is a series of nested tags (it is a subset of XML) that contain all div>
the website information (like texts, images and videos). Here is an </body>
</html>
example of tags:
<title>This is a title</title>
The HTML defines the page structure. A website can have several
HTMLs to different pages.
HTML: basic rules
Some rules about HTML:
● It uses XML syntax (tags with attributes, can contain other tags).
<tag_name attribute="value"> content </tag_name>
● It stores all the information that must be shown to the user.
● There are different HTML elements for different types of information and behaviour.
● The information is stored in a tree-like structure (nodes that contain nodes inside) called
DOM (Document Object Model).
● It gives the document some semantic structure (pe. this is a title, this is a section, this is
a form) which is helpful for computers to understand websites content.
● It must not contain information related to how it should be displayed (that information
belongs to the CSS), so no color information, font size, position, etc.
HTML: syntax example
<div id="main">
<!-- this is a comment -->
This is text without a tag.
<button class="mini">press me</button>
<img src="me.png" />
</div>
HTML: syntax example
Tag name
attributes
<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>
DO 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:
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Portfolio</title>
</head>
<body>
<h1>Isso é um título</h1>
<p>Isso é um parágrafo</p>
<img src="html.png" alt="Logo do HTML 5">
</body>
</html>
Extensão para atualização automática do Código
Instalar Live server
Estrutura Básica HTML
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
</body>
</html>
Figma - Prototipagem de Interfaces
Depois de estar com uma conta conectada, é a hora de criar uma cópia do layout
para a sua conta do Figma, assim garantindo o acesso de edição. Para fazer isso,
entre no link do layout original que está acima e no menu superior da plataforma,
clique no nome do arquivo: Portfolio - Curso 1. Irão abrir algumas opções, clique
em “Duplicate to your drafts”.
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Portfolio</title>
</head>
<body>
<header></header>
<main></main>
<footer></footer>
</body>
</html>
Technologies
● HTML
● CSS
● Javascript
CSS
CSS allows us to specify how to present
(render) the document info stored in the
HTML.
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 fields
Here is a list of the most common CSS fields and an example:
● color: #FF0000; red; rgba(255,00,100,1.0); //different ways to specify
colors
● background-color: red;
● background-image: url('file.png');
● font: 18px 'Tahoma';
● border: 2px solid black;
● border-top: 2px solid red;
● border-radius: 2px; //to remove corners and make them more round
● margin: 10px; //distance from the border to the outer elements
● padding: 2px; //distance from the border to the inner elements
● width: 100%; 300px; 1.3em; //many different ways to specify distances
● height: 200px;
● text-align: center;
● box-shadow: 3px 3px 5px black;
● cursor: pointer;
● display: inline-block;
● overflow: hidden;
CSS how to add it
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;
padding: 0;
regular documents). }
Understanding the Box Model: a good explanation of how to position the information on your
document.
strong {
color: #22D4FD;
}
Trabalhando posicionamento - Projeto 1
.titulo {
height: 100px;
width: 400px;
margin: 100px 200px;
position: absolute;
}
.imagem {
height: 100px;
width: 400px;
margin: 100px 600px;
position: absolute;
}
Trabalhando com Posicionamento - Projeto 1
.botaolink {
height: 100px;
width: 400px;
/* width: 50%; */
margin: 450px 200px;
position: absolute;
display: inline;
left: 30px;
}
Trabalhando com Posicionamento - Projeto 1
button {
border-radius: 12px;
background-color: #22D4FD;
/* Green */
border: none;
color: black;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 20px;
padding: 12px 28px;
height: 20px;
width: 150px;
transition-duration: 0.4s;
cursor: pointer;
}
Trabalhando com Posicionamento - Projeto 1
button:hover {
color: white;
}
Criando uma Página Produtos do IFPA
1- Abrir projeto inicial
2- Criar página produtos.html
3- Criar arquivo css produtos.css
Criando links para o Menu com uma Lista
<body>
<header>
<h1>
<img src="/imagens/logo.png">
</h1>
<ul>
</nav>
produtos.css
header {
background: #BBBBBB;
}
nav li{
display: inline; /*coloca um texto ao lado do outro*/
margin:0 0 0 15px; /* coloca espaço ao lado esquerdo de cada item */
}
nav a {
text-transform: uppercase; /* letras maiusculas*/
color:#000000;
font-weight: bold;
font-size: 22px;
text-decoration: none; /* tira toda decoração do texto (tira o sublinhado do link) */
}
Limpando o CSS (excluindo os estilos do navegador)
https://www.w3schools.com/css/tryit.asp?filename=trycss_inline-block_span1
https://www.w3schools.com/css/tryit.asp?filename=trycss_image_text_top_left
https://www.w3schools.com/css/tryit.asp?filename=trycss_inline-block_nav
Construindo o Header - Principais tags
header {
background: #BBBBBB;
padding: 20px 0; /* 20 px para cima e baixo e 0 para direita e esquerda*/
}
nav li{
display: inline; /*coloca um texto ao lado do outro*/
margin:0 0 0 15px; /* coloca espaço ao lado esquerdo de cada item */
}
nav a {
text-transform: uppercase; /* letras maiusculas*/
color:#000000;
font-weight: bold;
font-size: 22px;
text-decoration: none; /* tira toda decoração do texto (tira o sublinhado do link) */
}
Construindo o Header - Principais tags
nav {
position:absolute;
top:125px; /* para ficar no meio da imagen considerand que a imagem tem
250 px (metade 125px) verificar no inspector do navegador*/
right:0;
}
.caixa { /* marcando uma classe do css que veio do html */
width: 940px; /* padrão pois a maioria das resoluções usam 1000 e alguns px */
position: relative; /*para o menu ficar dentro da div*/
margin: 0 auto; /* 0 em cima e embaixo - auto para esquerda e direita */
}
Construindo o <main> - Principais Tags
.produtos li{
display: inline-block;
text-align: center;
width: 30%; /* cada botão ocupa 1/3 da parte relativa */
vertical-align: top; /* alinhamento pela parte de cima*/
/* background: #CCCCCC; para verificar melhor as margens */
margin:0 1.5%; /*0 para cima e baixo e 1,5% para cada lado totalizando 3% para
cada item que no final somando = 9% resultando nos 100% da página uma vez que cada
item ocupa 30%*/
padding: 30px 20px; /* ao fazer isso vai descconfigurar, porém podemos avisar o
navegador para contabilizar o pasdding dentro do limite do total de 100% ajustando
corretamente*/
box-sizing: border-box;
Borders Aplly
/* border-color:#000000 ;
border-width:2px ;
border-style:solid; isso é o mesmo que a linha abaixo
*/
border:2px solid #000000;
Arredondando a Borda
/* border-color:#000000 ;
border-width:2px ;
border-style:solid; isso é o mesmo que a linha abaixo */
border:2px solid #000000;
border-radius: 10px;
/* border-radius: 10px 20ox 30x 40px; arredondando os 4
cantos diferentes*/
Utilizando o hover no <header> <nav>
nav a:hover {
color:#C78C19;
text-decoration: underline;
}
Utilizando hover e active no <main> <li>
.produtos li:hover{
border-color:#C78C19; /*muda a cor da borda da lista quando o mouse passa
em cima*/
}
.produtos li:active{
border-color: #098C19; /*muda a borda quando clica*/
}
.produtos li:hover h2{
font-size: 34px; /*muda o tamanho do h2 quando mouse passa em cima da
lista*/
}
Trabalhando no <footer>
footer {
text-align: center;
background:url("/imagens/bg.jpg"); /* colocando uma imagem de
fundo (pode ser
pequena, pois o css expande ela várias vezes)*/
padding: 40px 0;
}
Copyright -
.copyright {
color:#FFFFFF;
font-size: 13px;
margin-top: 10px;
}
No HTML:
<p class="copyright">©Copyright IFPA 2023</p>
<!-- $copy pode ser buscado no site unicode table (google) , simbolo especial
-->
<!-- https://unicode-table.com/pt/ -->
Formulário
1- Copiar header e footer da página produtos.html
Tags <form>
<main>
<label for="nomesobrenome"> Nome e Sobrenome</label>
<input type="text" id="nomesobrenome">
}
form input {
display: block; /*tirando o padrão do inline e colocando para quebrar a linha*/
margin: 0 0 20px; /*colocando margem para baixo 20px*/
padding: 10px 25px;/* 10 px para cima e para baixo e 25px para os lados
espaçamento interto*/
width: 50%; /*input ocupando 50% da página*/
}
Mais Tags <form>
<label for="mensagem"> Mensagem</label>
<textarea id="mensagem" cols="70" rows="10"> </textarea>
Radio e Checkbox
<label for="radio-email"> Email</label>
<input type="radio" name="contato" value="email" id="radio-email">
p{
}
É sobrescrito por
Form p{
}
É sobrescrito por:
Inline Classe 10 Tag 1 .teste {
Id 100
1000000000 }
É sobrescrito {
#teste {
}
É sobrescrito por:
<p style="color; rede">
Qual será a cor do Objeto?
<p class="paragrafo">
p{
color: blue;
}
p paragrafo {
color: red;
}
.paragrafo {
color: purple;
}
Mobile inputs types
http://mobileinputtypes.com/
.enviar:hover {
background: darkorange;
}
Aumentando o Objeto proporcionalmente
(transform)
.enviar:hover {
background: darkorange;
transform: scale(1.2);/*aumentando nosso objeto em 20%*,
aumentando margin, padding, fonte etc.*/
transform: rotate(70deg);/*inclina meu item em graus*/
}
}
Criação de Tabela
<table>
<tr> <!-- Linhas-->
<td>Dia</td> <!-- Colunas-->
<td>Horário</td>
</tr>
<tr>
<td>Segunda</td>
<td>08:00 ~ 20:00</td>
</tr>
<tr>
<td>Quarta</td>
<td>08:00 ~ 20:00</td>
</tr>
<tr>
<td>Sexta</td>
<td>08:00 ~ 20:00</td>
</tr>
</table>
Melhorando a Semântica da Tabela <thead>
<thead> <!-- CABEÇALHO-->
<tr> <!-- Linhas-->
<td>Dia</td> <!-- Colunas-->
<td>Horário</td>
</tr>
</thead>
Melhorando a Semântica da Tabela <tbody>
<tbody>
<tr>
<td>Segunda</td>
<td>08:00 ~ 20:00</td>
</tr>
<tr>
<td>Quarta</td>
<td>08:00 ~ 20:00</td>
</tr>
<tr>
<td>Sexta</td>
<td>08:00 ~ 20:00</td>
</tr>
</tbody>
Estilos da Tabela
table { /* tabela toda*/
margin:20px 0 40px;
}
thead { /*cabeçalho*/
background:#555555;
color: white;
font-weight: bold;
}
td, tr { /*ITENS*/
border: 1px solid #000000;
padding: 8px 15px; /*espaçamento interno para cima e para baixo de 8px e para os
lados de 15px*/
}
Technologies
● 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)
From javascript you have different variables that you can access to get
information about the website:
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