HTML Css and Java Script
HTML Css and Java Script
on
Web Design
Presented
By
Rajeev Gautam
B.Tech (CSE), 4th year
Roll No. 2004860100009
One of the nice things about developing for the web is that
the web provides a very rich and simple framework to Hardware
create applications that include lots of features, not only
interface but also access to peripherals (audio, input,
gamepads, etc), and this API is very easy to use.
Goals
Introduction to web technologies:
● HTML to create the document
structure and content
● CSS to control is visual aspect
● 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>
HTM
LHTML means Hyper Text Markup Language.
<html>
The HTML allow us to define the structure of a document or a <head>
website. </head>
<body>
<div>
HTML is NOT a programming language, it’s a markup language,
<p>Hi</p>
which means its purpose is to give structure to the content of the </div>
website, not to define an algorithm. </body>
</html>
It is a series of nested tags (it is a subset of XML) that contain all the
website information (like texts, images and videos). Here is an 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>
DOM is a tree
<div> <div>
<h1>Title</h1>
Title <p>Here is content.</p>
<p>Here is more content</p>
Here is some content </div>
Here is more
content DO THIS
T
DON
</div>
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 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
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;
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), instead of a
div {
scrolling website (more like regular documents). margin: 0;
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. To
<input type="text"/>
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/Tut
orials