Movatterモバイル変換


[0]ホーム

URL:


PDF, PPTX4,833 views

Introduction to HTML-CSS-Javascript.pdf

The document provides an introduction to HTML, CSS, and JavaScript for creating web technologies. It discusses how to set up a development environment with a text editor and browser. It explains the basic structure and syntax of HTML, CSS, and JavaScript, including how to select and style elements with CSS and manipulate the DOM with JavaScript. Key topics covered include HTML tags, the box model, CSS selectors, layout systems like grid, and retrieving/modifying elements with JavaScript. The document serves as a high-level overview of the main technologies used for front-end web development.

Embed presentation

Download as PDF, PPTX
Introduction to webtechnologiesHTML + CSS + JavascriptJavi Agenjo (@tamat)
GoalsIntroduction to web technologies:● HTML to create the documentstructure and content● CSS to control is visual aspect● Javascript for interactivity
DeployWhat do we need to start:- a good web-browser (Chrome or Firefox)- the example HTML code to start- a good text editor like Editplus (win), VSCode (cross platform),textWrangler (osx), vim (unix) or sublime text (cross platform)
How can I test my codeJust open the index.html from the template in your text editor and in yourbrowser.When you do any change to the code, check it in the browser by pressingF5 (refresh site)To open the developer tools press:Windows: Control + Shift + I or F12OSX: Command + Opt + IOther tools are online editors like scratchpad or htmledit
Anatomy of a Browser
Inside a browserBrowsers have very differentiateparts.We are interested in two of them:● the Rendering Engine (incharge of transforming ourHTML+CSS in a visualimage).● The Javascript Interpreter(also known as VM), incharge of executing theJavascript code.
Technologies● HTML● CSS● Javascript
HTMLHTML means Hyper Text Markup Language.The HTML allow us to define the structure of a document or awebsite.HTML is NOT a programming language, it’s a markup language,which means its purpose is to give structure to the content of thewebsite, not to define an algorithm.It is a series of nested tags (it is a subset of XML) that contain allthe website information (like texts, images and videos). Here is anexample of tags:<title>This is a title</title>The HTML defines the page structure. A website can have severalHTMLs to different pages.<html><head></head><body><div><p>Hi</p></div></body></html>
HTML: basic rulesSome 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) calledDOM (Document Object Model).● It gives the document some semantic structure (pe. this is a title, this is a section, this isa form) which is helpful for computers to understand websites content.● It must not contain information related to how it should be displayed (that informationbelongs 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<div id="main"><!-- this is a comment -->This is text without a tag.<button class="mini">press me</button><img src="me.png" /></div>Tag nameattributescommenttext tagself-closing tag
DOM is a treeEvery node can only haveone parent, and every nodecan have several children,so the structure looks like atree.
Although there are lots of tags in the HTML specification, 99% of the webs use a subset ofHTML tags with less that 10 tags, the most important are:● <div>: a container, usually represents a rectangular area with information inside.● <img/>: an image● <a>: a clickable link to go to another URL● <p>: a text paragraph● <h1>: a title (h2,h3,h4 are titles of less importance)● <input>: a widget to let the user introduce information● <style>: to insert CSS rules● <script>: to execute Javascript● <span>: a null tag (doesn't do anything)HTML: main tags
HTML: other interesting tagsThere are some tags that could be useful sometimes:● <button>: to create a button● <audio>: for playing audio● <video>: to play video● <canvas>: to draw graphics from javascript● <iframe>: to put another website inside ours
HTML: wrapping the infoWe use HTML tags to wrap differentinformation on our site.The more structure has the information, theeasier will be to access it and present it.We can change the way the information isrepresented on the screen depending on thetags where it is contained, so we shouldn't beworried about using too many tags.
HTML: tagging correctlyTry to avoid doing this:<div>TitleHere is some contentHere is more content</div>Do this instead<div><h1>Title</h1><p>Here is content.</p><p>Here is more content</p></div>DONT DO THIS
HTML good useIt 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:● id: tells a unique identifier for this tag● class: tells a generic identifier for this tag<div id="profile-picture" class="mini-image">...</div>
HTML referencesHTML Reference: a description of all HTML tags.The 25 Most used tags: a list with information of the morecommon tags.HTML5 Good practices: some tips for starters
Technologies● HTML● CSS● Javascript
CSSCSS allows us to specify how to present(render) the document info stored in theHTML.Thanks to CSS we can control all theaspects of the visualization and some otherfeatures:● Colors: content, background, borders● Margins: interior margin, exteriormargin● Position: where to put it● Sizes: width, height● Behaviour: changes on mouse over
CSS example* {color: blue; /*a comment */margin: 10px;font: 14px Tahoma;}This will change all the tags in my web ( ‘*‘ means all) to look blue with font Tahoma with14px, and leaving a margin of 10px around.
CSS fieldsHere 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 itThere are four ways to add CSS rules to your website:● Inserting the code inside a style tag<style>p { color: blue }</style>● Referencing an external CSS file<link href="style.css" rel="stylesheet" />● Using the attribute style on a tag<p style="color: blue; margin: 10px">● Using Javascript (we will see this one later).
CSS selectorsLet's start by changing the background color of one tag of our website:div {background-color: red;}This CSS rule means that every tag DIV found in our website should have a red backgroundcolor. 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 selectorsWhat 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 classor 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 SelectorsThere are several selectors we can use to narrow our rules to very specific tags of our website.The main selectors are:● tag name: just the name of the tag○ p { ... } //affects to all <p> tags● dot (.): affects to tags with that class○ p.highlight { ... } //affects all <p> tags with class="highlight"● sharp character (#): specifies tags with that id○ p#intro { ... } //affects to the <p> tag with the id="intro"● two dots (:): behaviour states (mouse on top)○ p:hover { ... } //affects to <p> tags with the mouse over● brackets ([attr='value']): tags with the attribute attr with the value 'value'○ input[type="text"] {...} // affects to the input tags of the type text
CSS SelectorsYou can also specify tags by its context, for example: tags that are inside of tags matching aselector. Just separate the selectors by an space:div#main p.intro { ... }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><p class="intro">....</p> ← but not this one
CSS SelectorsAnd you can combine selectors to narrow it down more.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, thismeans it will affect to any node of id main#main { ... }
CSS SelectorsIf you want to select only elements that are direct child of one element (not that have anancestor with that rule), use the > character:ul.menu > li { ... }Finally, if you want to use the same CSS actions to several selectors, you can use thecomma , character:div, p { … } ← this will apply to all divs and p tags
HTML arrangeIt is important to understand how the browserarranges the elements on the screen.Check this tutorial where it explains thedifferent ways an element can be arrangedon the screen.You can change the way elements arearranged using the display property:div { display: inline-block; }Also check the property float.
Box ModelIt is important to note that by default anywidth and height specified to an element willnot take into account its margin, so a div withwidth 100px and margin 10px will measure120px on the screen, not 100px.This could be a problem breaking yourlayout.You can change this behaviour changing thebox model of the element so the width usesthe outmost border:div { box-sizing: border; }
LayoutOne of the hardest parts of CSS isconstruing the layout of your website (thestructure inside the window) .By default HTML tends to put everything inone column, which is not ideal.There has been many proposals in CSS toaddress this issue (tables, fixed divs, flex,grid, …).
Grid systemBecause most sites are structured in a grid, Irecommend to use the CSS Grid system.Check this tutorial to create the site structureeasilyHTML<div class="grid-container"><div class="grid-item1">1</div><div class="grid-item2">2</div></div>CSS.grid-container {display: grid;grid-template-rows: 100px; 100px;grid-template-columns: 100px; 100px; 100px;grid-gap: 5px;}.grid-item1 {background: blue;border: black 5px solid;grid-column-start: 1;grid-column-end: 5;grid-row-start: 1;grid-row-end: 3;}
Fullscreen divsSometimes we want to have a div that coversthe whole screen (to make a webapp),instead of a scrolling website (more likeregular documents).In that case remember to use percentages todefine the size of elements, but keep in mindthat percentages are relative to the element'sparent size, so you must set the size to the<body> element to use 100%.CSShtml, body {width: 100%;height: 100%;}div {margin: 0;padding: 0;}#main {width: 100%;height: 100%;}
Trick to center.horizontal-and-vertical-centering {display: flex;justify-content: center;align-items: center;}Centering divs can be hard sometimes, use this trick:
CSS further readingThere are many more rules for selectors.Check some of the links to understand them better.One line layouts tutorialsUnderstanding the Box Model: a good explanation of how to position the information on yourdocument.All CSS Selectors: the CSS selectors specification page.CSS Transition: how to make animations just using CSS
Technologies● HTML● CSS● Javascript
JavascriptA regular programming language, easy to start, hard to master.Allows to give some interactivity to the elements on the web.Syntax similar to C or Java but with no types.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 contentof the web without reloading the page.
#
#
Javascript example<html><body><h1>This is a title</h1><script>var title = document.querySelector("h1");title.innerHTML = "This is another title";</script></body></html>
Javascript APIJavascript comes with a rich API to do many things like:● Access the DOM (HTML nodes)● Do HTTP Requests● Play videos and sounds● Detect user actions (mouse move, key pressed)● Launch Threads● Access the GPU, get the Webcam image, ...And the API keeps growing with every new update of the standard.Check the WEB API reference to know more
#
#
#
#
#
#
Using InputsIf you want the user to be able to input some text we use the tag <input>:<input type="text"/>There are other inputs, you can check this list.From Javascript we can attach events like "click" or "keydown".To read or modify the content of the input:my_input_element.value = ""; //this will clear the text inside the input
Example of a websiteHTML in index.html<link href="style.css" rel="stylesheet"/><h1>Welcome</h1><p><button>Click me</button></p><script src=”code.js”/>CSS in style.cssh1 { color: #333; }button {border: 2px solid #AAA;background-color: #555;}Javascript in code.js//fetch the button from the DOMvar button = document.querySelector(“button”);//attach and event when the user clicks itbutton.addEventListener(“click”, myfunction);//create the function that will be called when thebutton is pressedfunction myfunction(){//this shows a popup windowalert(“button clicked!”);}
jQueryjQuery is a library that makes working with the DOM much easier, using an unifiedsyntax and taking advantage of selectors:$("p").remove(); //remove all tags p$("#main").hide(); //hides the element of id main$("#main").append("<h1>titulo</h1>") //adds content to an element$("#wrap").css({ color: "red" }); //change the css$("button#send").click( function() { /* code */ });To include this library just add this to your HTML:<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
Using the Dev ToolsPress Control + Shift + I (or F12) to open DevTools
ExerciseCreate the layout for amessaging application.Structured like:● Main container○ Messages area■ message○ Typing area area■ input
Further infoAPI References: DevDocs.ioSelectors: MDN TutorialTo learn Javascript.http://codeacademy.comTo learn jQuery:http://docs.jquery.com/Tutorials

Recommended

PPT
HTML & CSS.ppt
PPTX
Css ppt
PDF
Basic Details of HTML and CSS.pdf
PDF
Introduction to HTML and CSS
PPT
How Cascading Style Sheets (CSS) Works
PPTX
An Overview of HTML, CSS & Java Script
PPTX
Html, CSS & Web Designing
PPTX
Css pseudo-classes
PPTX
Css types internal, external and inline (1)
PPTX
Html links
PPTX
Css selectors
PDF
Introduction to HTML5
PPT
Hyperlinks in HTML
PPT
Introduction to html
PDF
Intro to HTML and CSS basics
PPT
Introduction to Web Programming - first course
PPT
Introduction to Cascading Style Sheets (CSS)
PPTX
ADOBE DREAMWEAVER
byNi
 
PPTX
Html5 and-css3-overview
PPT
cascading style sheet ppt
PPTX
Cascading Style Sheet (CSS)
PPTX
Html images syntax
PPTX
CSS Animations & Transitions
PPT
Box Model
PPTX
Web publishing
PPT
CSS Basics
PDF
Html table tags
PPT
Cascading Style Sheets (CSS) help
PPTX
Introduction to HTML+CSS+Javascript.pptx
PPTX
Introduction to HTML+CSS+Javascript.pptx

More Related Content

PPT
HTML & CSS.ppt
PPTX
Css ppt
PDF
Basic Details of HTML and CSS.pdf
PDF
Introduction to HTML and CSS
PPT
How Cascading Style Sheets (CSS) Works
PPTX
An Overview of HTML, CSS & Java Script
PPTX
Html, CSS & Web Designing
PPTX
Css pseudo-classes
HTML & CSS.ppt
Css ppt
Basic Details of HTML and CSS.pdf
Introduction to HTML and CSS
How Cascading Style Sheets (CSS) Works
An Overview of HTML, CSS & Java Script
Html, CSS & Web Designing
Css pseudo-classes

What's hot

PPTX
Css types internal, external and inline (1)
PPTX
Html links
PPTX
Css selectors
PDF
Introduction to HTML5
PPT
Hyperlinks in HTML
PPT
Introduction to html
PDF
Intro to HTML and CSS basics
PPT
Introduction to Web Programming - first course
PPT
Introduction to Cascading Style Sheets (CSS)
PPTX
ADOBE DREAMWEAVER
byNi
 
PPTX
Html5 and-css3-overview
PPT
cascading style sheet ppt
PPTX
Cascading Style Sheet (CSS)
PPTX
Html images syntax
PPTX
CSS Animations & Transitions
PPT
Box Model
PPTX
Web publishing
PPT
CSS Basics
PDF
Html table tags
PPT
Cascading Style Sheets (CSS) help
Css types internal, external and inline (1)
Html links
Css selectors
Introduction to HTML5
Hyperlinks in HTML
Introduction to html
Intro to HTML and CSS basics
Introduction to Web Programming - first course
Introduction to Cascading Style Sheets (CSS)
ADOBE DREAMWEAVER
byNi
 
Html5 and-css3-overview
cascading style sheet ppt
Cascading Style Sheet (CSS)
Html images syntax
CSS Animations & Transitions
Box Model
Web publishing
CSS Basics
Html table tags
Cascading Style Sheets (CSS) help

Similar to Introduction to HTML-CSS-Javascript.pdf

PPTX
Introduction to HTML+CSS+Javascript.pptx
PPTX
Introduction to HTML+CSS+Javascript.pptx
PPTX
gdg Introduction to HTML-CSS-Javascript.pptx
PPTX
Introduction to HTML-CSS-Javascript.pptx
PPTX
Introduction to HTML+CSS+Javascript.pptx
PPTX
Introduction to HTML+CSS+Javascript.pptx
PPTX
HTMLforbeginerslearntocodeforbeginersinfh
 
PPTX
wd project.pptx
PPTX
Introduction to HTML+CSS+Javascript.pptx
PPTX
Introduction to HTML+CSS+Javascript.pptx
PPTX
PPT ON SEMINAR REPORT.pptx. bhvhvhchchvhchch
PPTX
Tech Winter Break - GDG on Campus - PIET
PPTX
Introduction to HTML+CSS+Javascript.pptx
PPTX
Introduction to HTML+CSS+Javascript by Deepu.pptx
PDF
Web Design & Development - Session 2
PPTX
Html-Prabakaran
PPTX
Introduction to Web Technologies PPT.pptx
PPTX
GDG On Campus NBNSCOE Web Workshop Day 1 : HTML & CSS
PDF
HTML+CSS: how to get started
PPTX
Learn html and css from scratch
Introduction to HTML+CSS+Javascript.pptx
Introduction to HTML+CSS+Javascript.pptx
gdg Introduction to HTML-CSS-Javascript.pptx
Introduction to HTML-CSS-Javascript.pptx
Introduction to HTML+CSS+Javascript.pptx
Introduction to HTML+CSS+Javascript.pptx
HTMLforbeginerslearntocodeforbeginersinfh
 
wd project.pptx
Introduction to HTML+CSS+Javascript.pptx
Introduction to HTML+CSS+Javascript.pptx
PPT ON SEMINAR REPORT.pptx. bhvhvhchchvhchch
Tech Winter Break - GDG on Campus - PIET
Introduction to HTML+CSS+Javascript.pptx
Introduction to HTML+CSS+Javascript by Deepu.pptx
Web Design & Development - Session 2
Html-Prabakaran
Introduction to Web Technologies PPT.pptx
GDG On Campus NBNSCOE Web Workshop Day 1 : HTML & CSS
HTML+CSS: how to get started
Learn html and css from scratch

Recently uploaded

PPTX
Discipline presentation for organization.pptx
PDF
Highlighting Research Opportunities in Dentistry and Dental Surgery by Dr. Bo...
PPTX
search engine optimization for dmm1.pptx
PPTX
basit, lang & geder bas maazkal ppt.pptx
PPTX
ARTIFICAL INTELLIGENCE COMPLETE INTRO111
PDF
PPT-Probability and Distributions-APSCM.pdf
PDF
LECTURE 9 SCREENING FOR HEALTH, FITNESS AND WELLNESS.pdf
PDF
Banksman.pdf for to be the best banksman
PPT
pokayoke.ppt presentation for poka yoke tech
PDF
cte fvfvbdsvbjvng t p2 sci math jan 2024.pdf
PPTX
CYBER SECURITY TH GENERA DATA PROTECTION
PPTX
LinkedIn for Your Job Search December 2025
PDF
Stepwise Approach to Writing with Expert Research Proposal Help
PDF
Lecture 1 the 3rd line of defence ; Adaptive immunity.pdf
PDF
Cold_Resistant_Insects_and_Their_Impact_on_Winter_PMI_Estimation.pdf
PDF
Excursion_to_Manali_Kullu_Faridabad_Convent_School_Final 2.pdf
PPTX
COMPUTER SYSTEMS AND BINARY NUMBERS ARCH
DOCX
CONVERSATION FOR ORAL EXAMINATION CLASS II.docx
PPTX
M laxmikanth indian polity 7th edition by Amit
PDF
Product-Overview-Safetica-Data-Leak-Prevention.pdf
Discipline presentation for organization.pptx
Highlighting Research Opportunities in Dentistry and Dental Surgery by Dr. Bo...
search engine optimization for dmm1.pptx
basit, lang & geder bas maazkal ppt.pptx
ARTIFICAL INTELLIGENCE COMPLETE INTRO111
PPT-Probability and Distributions-APSCM.pdf
LECTURE 9 SCREENING FOR HEALTH, FITNESS AND WELLNESS.pdf
Banksman.pdf for to be the best banksman
pokayoke.ppt presentation for poka yoke tech
cte fvfvbdsvbjvng t p2 sci math jan 2024.pdf
CYBER SECURITY TH GENERA DATA PROTECTION
LinkedIn for Your Job Search December 2025
Stepwise Approach to Writing with Expert Research Proposal Help
Lecture 1 the 3rd line of defence ; Adaptive immunity.pdf
Cold_Resistant_Insects_and_Their_Impact_on_Winter_PMI_Estimation.pdf
Excursion_to_Manali_Kullu_Faridabad_Convent_School_Final 2.pdf
COMPUTER SYSTEMS AND BINARY NUMBERS ARCH
CONVERSATION FOR ORAL EXAMINATION CLASS II.docx
M laxmikanth indian polity 7th edition by Amit
Product-Overview-Safetica-Data-Leak-Prevention.pdf

Introduction to HTML-CSS-Javascript.pdf

  • 1.
    Introduction to webtechnologiesHTML+ CSS + JavascriptJavi Agenjo (@tamat)
  • 2.
    GoalsIntroduction to webtechnologies:● HTML to create the documentstructure and content● CSS to control is visual aspect● Javascript for interactivity
  • 3.
    DeployWhat do weneed to start:- a good web-browser (Chrome or Firefox)- the example HTML code to start- a good text editor like Editplus (win), VSCode (cross platform),textWrangler (osx), vim (unix) or sublime text (cross platform)
  • 4.
    How can Itest my codeJust open the index.html from the template in your text editor and in yourbrowser.When you do any change to the code, check it in the browser by pressingF5 (refresh site)To open the developer tools press:Windows: Control + Shift + I or F12OSX: Command + Opt + IOther tools are online editors like scratchpad or htmledit
  • 5.
  • 6.
    Inside a browserBrowsershave very differentiateparts.We are interested in two of them:● the Rendering Engine (incharge of transforming ourHTML+CSS in a visualimage).● The Javascript Interpreter(also known as VM), incharge of executing theJavascript code.
  • 7.
  • 8.
    HTMLHTML means HyperText Markup Language.The HTML allow us to define the structure of a document or awebsite.HTML is NOT a programming language, it’s a markup language,which means its purpose is to give structure to the content of thewebsite, not to define an algorithm.It is a series of nested tags (it is a subset of XML) that contain allthe website information (like texts, images and videos). Here is anexample of tags:<title>This is a title</title>The HTML defines the page structure. A website can have severalHTMLs to different pages.<html><head></head><body><div><p>Hi</p></div></body></html>
  • 9.
    HTML: basic rulesSomerules 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) calledDOM (Document Object Model).● It gives the document some semantic structure (pe. this is a title, this is a section, this isa form) which is helpful for computers to understand websites content.● It must not contain information related to how it should be displayed (that informationbelongs to the CSS), so no color information, font size, position, etc.
  • 10.
    HTML: syntax example<divid="main"><!-- this is a comment -->This is text without a tag.<button class="mini">press me</button><img src="me.png" /></div>
  • 11.
    HTML: syntax example<divid="main"><!-- this is a comment -->This is text without a tag.<button class="mini">press me</button><img src="me.png" /></div>Tag nameattributescommenttext tagself-closing tag
  • 12.
    DOM is atreeEvery node can only haveone parent, and every nodecan have several children,so the structure looks like atree.
  • 14.
    Although there arelots of tags in the HTML specification, 99% of the webs use a subset ofHTML tags with less that 10 tags, the most important are:● <div>: a container, usually represents a rectangular area with information inside.● <img/>: an image● <a>: a clickable link to go to another URL● <p>: a text paragraph● <h1>: a title (h2,h3,h4 are titles of less importance)● <input>: a widget to let the user introduce information● <style>: to insert CSS rules● <script>: to execute Javascript● <span>: a null tag (doesn't do anything)HTML: main tags
  • 15.
    HTML: other interestingtagsThere are some tags that could be useful sometimes:● <button>: to create a button● <audio>: for playing audio● <video>: to play video● <canvas>: to draw graphics from javascript● <iframe>: to put another website inside ours
  • 16.
    HTML: wrapping theinfoWe use HTML tags to wrap differentinformation on our site.The more structure has the information, theeasier will be to access it and present it.We can change the way the information isrepresented on the screen depending on thetags where it is contained, so we shouldn't beworried about using too many tags.
  • 17.
    HTML: tagging correctlyTryto avoid doing this:<div>TitleHere is some contentHere is more content</div>Do this instead<div><h1>Title</h1><p>Here is content.</p><p>Here is more content</p></div>DONT DO THIS
  • 18.
    HTML good useItis 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:● id: tells a unique identifier for this tag● class: tells a generic identifier for this tag<div id="profile-picture" class="mini-image">...</div>
  • 19.
    HTML referencesHTML Reference:a description of all HTML tags.The 25 Most used tags: a list with information of the morecommon tags.HTML5 Good practices: some tips for starters
  • 20.
  • 21.
    CSSCSS allows usto specify how to present(render) the document info stored in theHTML.Thanks to CSS we can control all theaspects of the visualization and some otherfeatures:● Colors: content, background, borders● Margins: interior margin, exteriormargin● Position: where to put it● Sizes: width, height● Behaviour: changes on mouse over
  • 22.
    CSS example* {color:blue; /*a comment */margin: 10px;font: 14px Tahoma;}This will change all the tags in my web ( ‘*‘ means all) to look blue with font Tahoma with14px, and leaving a margin of 10px around.
  • 23.
    CSS fieldsHere isa 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;
  • 24.
    CSS how toadd itThere are four ways to add CSS rules to your website:● Inserting the code inside a style tag<style>p { color: blue }</style>● Referencing an external CSS file<link href="style.css" rel="stylesheet" />● Using the attribute style on a tag<p style="color: blue; margin: 10px">● Using Javascript (we will see this one later).
  • 25.
    CSS selectorsLet's startby changing the background color of one tag of our website:div {background-color: red;}This CSS rule means that every tag DIV found in our website should have a red backgroundcolor. 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;}
  • 26.
    CSS selectorsWhat ifwe 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 classor 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">
  • 27.
    CSS SelectorsThere areseveral selectors we can use to narrow our rules to very specific tags of our website.The main selectors are:● tag name: just the name of the tag○ p { ... } //affects to all <p> tags● dot (.): affects to tags with that class○ p.highlight { ... } //affects all <p> tags with class="highlight"● sharp character (#): specifies tags with that id○ p#intro { ... } //affects to the <p> tag with the id="intro"● two dots (:): behaviour states (mouse on top)○ p:hover { ... } //affects to <p> tags with the mouse over● brackets ([attr='value']): tags with the attribute attr with the value 'value'○ input[type="text"] {...} // affects to the input tags of the type text
  • 28.
    CSS SelectorsYou canalso specify tags by its context, for example: tags that are inside of tags matching aselector. Just separate the selectors by an space:div#main p.intro { ... }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><p class="intro">....</p> ← but not this one
  • 29.
    CSS SelectorsAnd youcan combine selectors to narrow it down more.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, thismeans it will affect to any node of id main#main { ... }
  • 30.
    CSS SelectorsIf youwant to select only elements that are direct child of one element (not that have anancestor with that rule), use the > character:ul.menu > li { ... }Finally, if you want to use the same CSS actions to several selectors, you can use thecomma , character:div, p { … } ← this will apply to all divs and p tags
  • 31.
    HTML arrangeIt isimportant to understand how the browserarranges the elements on the screen.Check this tutorial where it explains thedifferent ways an element can be arrangedon the screen.You can change the way elements arearranged using the display property:div { display: inline-block; }Also check the property float.
  • 32.
    Box ModelIt isimportant to note that by default anywidth and height specified to an element willnot take into account its margin, so a div withwidth 100px and margin 10px will measure120px on the screen, not 100px.This could be a problem breaking yourlayout.You can change this behaviour changing thebox model of the element so the width usesthe outmost border:div { box-sizing: border; }
  • 33.
    LayoutOne of thehardest parts of CSS isconstruing the layout of your website (thestructure inside the window) .By default HTML tends to put everything inone column, which is not ideal.There has been many proposals in CSS toaddress this issue (tables, fixed divs, flex,grid, …).
  • 34.
    Grid systemBecause mostsites are structured in a grid, Irecommend to use the CSS Grid system.Check this tutorial to create the site structureeasilyHTML<div class="grid-container"><div class="grid-item1">1</div><div class="grid-item2">2</div></div>CSS.grid-container {display: grid;grid-template-rows: 100px; 100px;grid-template-columns: 100px; 100px; 100px;grid-gap: 5px;}.grid-item1 {background: blue;border: black 5px solid;grid-column-start: 1;grid-column-end: 5;grid-row-start: 1;grid-row-end: 3;}
  • 35.
    Fullscreen divsSometimes wewant to have a div that coversthe whole screen (to make a webapp),instead of a scrolling website (more likeregular documents).In that case remember to use percentages todefine the size of elements, but keep in mindthat percentages are relative to the element'sparent size, so you must set the size to the<body> element to use 100%.CSShtml, body {width: 100%;height: 100%;}div {margin: 0;padding: 0;}#main {width: 100%;height: 100%;}
  • 36.
    Trick to center.horizontal-and-vertical-centering{display: flex;justify-content: center;align-items: center;}Centering divs can be hard sometimes, use this trick:
  • 37.
    CSS further readingThereare many more rules for selectors.Check some of the links to understand them better.One line layouts tutorialsUnderstanding the Box Model: a good explanation of how to position the information on yourdocument.All CSS Selectors: the CSS selectors specification page.CSS Transition: how to make animations just using CSS
  • 38.
  • 39.
    JavascriptA regular programminglanguage, easy to start, hard to master.Allows to give some interactivity to the elements on the web.Syntax similar to C or Java but with no types.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 contentof the web without reloading the page.
  • 40.
  • 43.
    Javascript APIJavascript comeswith a rich API to do many things like:● Access the DOM (HTML nodes)● Do HTTP Requests● Play videos and sounds● Detect user actions (mouse move, key pressed)● Launch Threads● Access the GPU, get the Webcam image, ...And the API keeps growing with every new update of the standard.Check the WEB API reference to know more
  • 44.
    #"https://www.slideshare.net/slideshow/introduction-to-htmlcssjavascriptpdf/252377953#45">#"https://www.slideshare.net/slideshow/introduction-to-htmlcssjavascriptpdf/252377953#46">#"https://www.slideshare.net/slideshow/introduction-to-htmlcssjavascriptpdf/252377953#47">#"https://www.slideshare.net/slideshow/introduction-to-htmlcssjavascriptpdf/252377953#48">#"https://www.slideshare.net/slideshow/introduction-to-htmlcssjavascriptpdf/252377953#49">#"https://www.slideshare.net/slideshow/introduction-to-htmlcssjavascriptpdf/252377953#50">Using InputsIf youwant the user to be able to input some text we use the tag <input>:<input type="text"/>There are other inputs, you can check this list.From Javascript we can attach events like "click" or "keydown".To read or modify the content of the input:my_input_element.value = ""; //this will clear the text inside the input
  • 51.
    Example of awebsiteHTML in index.html<link href="style.css" rel="stylesheet"/><h1>Welcome</h1><p><button>Click me</button></p><script src=”code.js”/>CSS in style.cssh1 { color: #333; }button {border: 2px solid #AAA;background-color: #555;}Javascript in code.js//fetch the button from the DOMvar button = document.querySelector(“button”);//attach and event when the user clicks itbutton.addEventListener(“click”, myfunction);//create the function that will be called when thebutton is pressedfunction myfunction(){//this shows a popup windowalert(“button clicked!”);}
  • 52.
    jQueryjQuery is alibrary that makes working with the DOM much easier, using an unifiedsyntax and taking advantage of selectors:$("p").remove(); //remove all tags p$("#main").hide(); //hides the element of id main$("#main").append("<h1>titulo</h1>") //adds content to an element$("#wrap").css({ color: "red" }); //change the css$("button#send").click( function() { /* code */ });To include this library just add this to your HTML:<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
  • 53.
    Using the DevToolsPress Control + Shift + I (or F12) to open DevTools
  • 54.
    ExerciseCreate the layoutfor amessaging application.Structured like:● Main container○ Messages area■ message○ Typing area area■ input
  • 55.
    Further infoAPI References:DevDocs.ioSelectors: MDN TutorialTo learn Javascript.http://codeacademy.comTo learn jQuery:http://docs.jquery.com/Tutorials

[8]ページ先頭

©2009-2025 Movatter.jp