Introduction To Internet, HTML & CSS WEB DEV
Introduction To Internet, HTML & CSS WEB DEV
INTERNET, HTML
& CSS
1
Neema
Rajabu
Contact Me
neyrajy@gmail.com;
0769129676
UNDERSTANDING
THE WEB AND THE
INTERNET
Outline
What is the internet? Navigate with DNS and IP
What is the web? addresses
Databases
4
What is the
Internet
The internet is a global system of interconnected computer
networks.
The Web
The term refers to all the interlinked
HTML pages that can be accessed
over the Internet.
The World Wide Web was originally
designed in 1991 by Tim Berners-Lee
10
READY TO
CODE?
Web
TheDesign
term “web design” has come to encompass a number of
disciplines,
including:
Visual (graphic) design
User interface and experience design
Web document and style sheet production
Scripting and programming
Content strategy
Multimedia
What Does a Web Designer Do?
Design
User Experience, Interaction, and User Interface design
Before picking colors and fonts, it is important to identify the site’s goals, how it
will be used, and how visitors move through it.
The goal of the Interaction Designer is to make the site as easy, efficient, and
delightful to use as possible.
Site designs often start with user research, including interviews and
observations, in order to gain a better understanding of how the site
can solve problems or how it will be used.
At web design firms, the team that handles the creation of the
files that make up the website (or templates for pages that get
assembled dynamically) is usually called the development or
production department.
Web developers may not design the look or structure of the site
themselves, but they do need to communicate well with
designers and understand the intended site goals so they may
suggest solutions that meet those goals.
Continued..
The broad disciplines that fall under development are:-
Authoring
Styling and
Scripting/Programming.
Authoring/Markup
Authoring is the term used for the process of preparing
content for delivery on the Web, or more specifically,
marking up the content with HTML tags that describe its
content and function.
We’ll get deep into CSS in next few chapters of the course
(including what “cascading” means!), but for now just know
that in contemporary web design, the appearance of the
page is handled separately from the HTML markup of the
page.
Scripting and Programming
JavaScript is the language that makes elements on web
pages do things. It adds behaviors and functionality to
elements in the page and even to the browser window
itself.
The HTML document itself begins with <html> and ends with
</html>.
<body>
<h1>Heading One</h1>
<p>My first paragraph.</p>
</body>
</html>
The first line <!DOCTYPE html> is the document type declaration.
It instructs the web browser that this document is an HTML5 document. It is case-
insensitive.
The <head> element is a container for the tags that provides information about the
document, for example, <title> tag defines the title of the document.
The <body> element contains the document's actual content (paragraphs, links,
images, tables, and so on) that is rendered in the web browser and displayed to the
user.
**A DOCTYPE declaration appears at the top of a web page before all other elements;
however the doctype declaration itself is not an HTML tag. Every HTML document
requires a document type declaration to insure that your pages are displayed
correctly.
HTML Elements
An HTML element is defined by a start tag, some content, and an end tag.
<tagname>Text...</tagname>.
Example <p>My paragraph</p>
Some HTML elements have no content (like the <br> element). These
elements are called empty elements. Empty elements do not have an end
tag!
<p>My paragraph <br/> is too long</p>
HTML Attributes
Paragraphs: A paragraph always starts on a new line, and is usually a block of tex
Example <p>My first paragraph</p>
Images: A paragraph always starts on a new line, and is usually a block of text.
Example <img src="img_girl.jpg">
Lists: HTML lists allow web authors to group a set of related items in lists.
Example:
Ordered List Unordered List
<ol> <ol>
<li>Tea</li> <li>Tea</li>
<li>Coffee<li> <li>Coffee<li>
</ol> </ol>
HTML Basic Elements
Tables: They allow web authors to arrange data like text, images, links,
other tables, etc. into rows and columns of cells. Example
<!DOCTYPE html>
<html>
<head> <title>HTML Tables</title> </head>
<body>
<table border = "1">
<tr>
<td>Row 1, Column 1</td>
<td>Row 1, Column 2</td>
</tr>
<tr>
<td>Row 2, Column 1</td>
<td>Row 2, Column 2</td>
</tr>
</table>
</body>
</html> 40
HTML Basic Elements
Forms: HTML Forms are required, when you want to collect some data
from the site visitor. For example, during user registration you would like
to collect information such as name, email address, credit card, etc..
Example
<!DOCTYPE html>
<html>
<head> <title>HTML Forms</title> </head>
<body>
<form action = "Script URL" method = "GET|POST">
First name: <input type = "text" name = "first_name" ><br>
Last name: <input type = "text" name = "last_name" />
</form>
</body>
</html>
41
HTML Form Elements
Tag Description
<form>: Defines an HTML form for user input
<input>: Defines an input control
<textarea>: Defines a multiline input control (text area)
<label>: Defines a label for an <input>
element
<fieldset>: Groups related elements in a form
<legend>: Defines a caption for a <fieldset> element
<select>: Defines a drop-down list
<option> Defines an option in a drop-down list
<button> Defines a clickable button
42
Frames
While all modern browser offer support for frames today, the W3C has
unequivocally stated that frames “are not to be used by Web developers” and that
support for frames in web browsers is offered for historical purposes only.
Usability challenges: With the rise in popularity of mobile devices and tablets with
small displays it’s more important than ever that websites offer multiple views
which change based on the size of the device viewport. While frames can be
manipulated to provide a certain degree of responsiveness, they are simply not
well-suited to creating responsive websites.
43
HTML5 Structural Elements
<header>: The section at the top of a web page that often includes a logo and
sometimes a nav
<nav>: A set of menu items that allow a user to navigate to different pages on
a site
<section>
<!--content-->
</section>
<article>
<!--content-->
</article>
<footer>
<!--content-->
</footer>
HTML Block and Inline Elements
49
HTML Block and Inline Elements
Block-level elements include: Inline elements include:
Headings
Paragraphs (p) Images (img)
Lists and list items (ul, ol, li) Emphasized text (em)
Structuring elements (header, nav,
Strong text (strong)
section, article, aside, figure, footer)
Links (a)
50
HTML Block and Inline Elements
HTML Block and Inline Elements
Group Content with Divs and Spans
The difference between divs and spans is simple: one is block-level,
and the other is inline.
Divs
Divs are a block-level element used to group content together, not dissimilar to <header>,
<nav>, <section>, <article>, <footer>, <figure>, and <aside>. There's one key
difference, though.
Most of the time, when you want to group content together, you'll be able to do it using an
HTML5 semantic element like header, nav, section, article, footer, figure, or aside.
However,
sometimes your content doesn't really fit any of these categories! In that case, you're
encouraged to use divs to create block-level content groups.
Divs
Divs
Spans
Spans are similar to divs, except they are inline elements.
You might use them to group words together, since words appear inline and not each
on their own line.
Imagine the newspaper above always prints its name in bolded light green. You need
to grab those two words — "Sun Journal" — to be able to apply CSS to them. Why not
wrap them in a <span>?
Spans
Add Classes and Ids to elements
Class and id tags will revolutionize your HTML. They're absolutely necessary when your
pages start becoming more complex.
Add Classes and Ids to elements
Classes and ids are custom attributes you can add to your elements in order to
distinguish them from one another.
Classes apply to groups of elements, and ids apply to only one single element on an
entire page. Let's check out classes first.
These examples will include basic CSS to help you visualize how ids and classes are
used, but you're not expected to know CSS yet! Don't stress about it.
Classes
Classes Example
Classes Example
Ids
Ids are just like classes,they are custom attributes that can be added to elements —
except they'll only apply to one element per page.
There were multiple warning paragraphs. On the same page, let's say we want to have
one single key takeaway (added to the HTML above):
<p id="key-takeaway">Therefore, this is the one thing you should remember from the
whole page.</p>
There will only be one key takeaway per page, so we're safe to use an id on this
element instead of a class!
Now in CSS, you can adapt that one element's appearance!
HTML Comment Tags
You can add comments to your HTML source by using the following syntax:
<!-- Write your comments here -->
Notice that there is an exclamation point (!) in the start tag, but not in the end tag.
Comments are not displayed by the browser, but they can help document your HTML
source code. With comments you can place notifications and reminders in your HTML
code:
HTML Comment Tags
Example
<!-- My comment goes here-->
<p>This is a paragraph.</p>
<!-- Remember to add more information here -->
CSS
HTML is the language that handles the first concern: creating structured content to tell a
story.
CSS covers the second concern: customizing the appearance of that content to visually
bring it to life.
67
CSS
CSS stands for Cascading
Style Sheet.
Definition of css
Cascading Style Sheets (CSS)
Is a style sheet language used for describing the look and formatting of
a document written in a markup language.
You write CSS rules in elements, and modify properties of those
elements such as color, background color, width, border, font etc.
69
CSS
• Cascading style sheets, or CSS, is a style sheet language used on the
web
• CSS specifications are maintained by the world wide web consortium
(W3C)
• Three versions of CSS exist: CSS1, CSS2, and CSS3
70
CSS applied to HTML
There are two steps while using CSS to make your HTML look awesome:
Identify and select the relevant HTML element (ex. paragraph, header, etc).
Add some styles (specify how it should look).
Example Syntax
p{ selector { property: value }
color: blue;
font-family: Arial;
}
Methods for adding css
There are 3 ways to associate styles with your HTML document. Most
commonly used methods are inline CSS and external CSS.
1. Embedded css - the <style> element
You can put your css rules into an html document using the <style>
element. This tag is placed inside the <head>...</head> tags.
<head>
<style type="text/css"
style rules
............
</style>
</head> 72
2. Inline CSS - the style attribute
You can use style attribute of any HTML element to define style rules. These rules
will be applied to that element only. Here is the generic syntax:
<element style="...style rules....">
<h1 style =" color:red;"> This is inline CSS </h1>
3. External CSS - the <link> element
The <link> element can be used to include an external stylesheet file in your
HTML document.
An external style sheet is a separate text file with .css extension.
You define all the style rules within this text file and then you can include this file
in any HTML document using <link> element.
Here is the generic syntax of including external css file:
<head>
<link type="text/css" rel="stylesheet" href="..." />
</head>
73
74
CSS Syntax
A CSS comprises of style rules that are interpreted by the browser and then applied to the
corresponding elements in your document. A style rule is made of three parts:
• Selector: A selector is an HTML tag at which a style will be applied. This could be any tag
like <h1> or <table> etc.
• Property: a property is a type of attribute of html tag. Put simply, all the HTML attributes
are converted into CSS properties. They could be color, border, etc.
• Value: values are assigned to properties. For example, color property can have the value
either red or #F1F1F1 etc.
You can put css style rule syntax as follows:
Selector { property: value; }
Example: you can define a table border as follows:
table{ border :1px solid #c00; }
75
Selectors
Selectors are used to declare which part of the markup a style applies to, a
kind of match expression.
3 types of selectors
1. Tag selectors (body, p, div, a)
2. ID selectors (#wrapper, #sidebar)
3. Class selectors (.content, .menu)
76
Tag selectors (body, p, div, a)
The element selector selects HTML elements based on the element
name. Forexample,
p{
text-align: center;
color: red;
}
Id Selector
The id selector is used to specify a style for a single, unique element.
The id selector uses the id attribute of the html element, and is defined
with a "#".
The style rule below will be applied to the element with id="wrapper":
#wrapper
For example, to identify a paragraph as “head”,
{
use the code:
text-align : center;
border : 1px solid red;
<div id=“wrapper”>… </div>
width: 200px;
height: 100px
} 78
Class selectors
The class selector is used to specify a style for a group of elements.
The class selector is most often used on several elements. This allows you to
set a particular style for many html elements with the same class.
The class selector uses the html class attribute, and is defined with a "."
<h1 class=“heading”>Heading 1</h1>
.heading { h1.black { color: #000000; }
This rule renders the content
color: #000000; in black for only <h1> elements
background-color: blueviolet; with class attribute set to black.
}
Property & Value
The property is the style attribute you want to change. Each property
has a value
82
CSS: Color
CSS uses color values to specify a color. Typically, these are used to set
a color either for the foreground of an element (i.e., Its text) or for the
background of the element. They can also be used to affect the color
of borders and other decorative effects.
You can specify your color values in various formats. Following table
lists all the possible formats:
83
Size Properties - Element, Padding,
Margin, Border
width - Override element defaults Borders
height border-bottom-color
border-bottom-style
Padding border-bottom-width
padding-top border-left-color
padding-right border-left-style
padding-bottom border-left-width
padding-left border-right-color
border-right-style
Margin border-right-width
margin-top etc.
margin-right p {
margin-bottom border: 5px solid red;
margin-left }
84
Box Model
All HTML elements can be considered as boxes. In CSS, the term "box model" is used
when talking about design and layout.
85
Elements as boxes
87
Some More Common Properties
• Background-image: image for element's background
• Background-repeat: should background image be displayed in a
repeating pattern (versus once only)
• Font, font-family, font-size, font-weight, font-style: Font information
for text
• Text-align, vertical-align: alignment: center, left, right
88
Safe Web Fonts
89
Element Visibility Control Properties
• Display: none; - element is not displayed and takes no space in layout.
• Display: inline; - element is treated as an inline element.
• Display: block; - element is treated as a block element.
• Display: flex; - element is treated as a flex container(Layout one
dimension (row or column) of elements).
• Display: grid; - element is treated as a grid container(Layout in two
dimensions (rows and columns) of elements).
• Visibility: hidden; - element is hidden but space still allocated.
• Visibility: visible; - element is normally displayed
90
CSS Units
CSS supports a number of measurements including absolute units and
relative units.
The absolute length units are fixed and a length expressed in any of
these will appear as exactly that size.
Absolute length units are not recommended for use on screen, because
screen sizes vary so much. However, they can be used if the output
medium is known, such as for print layout) such as inches, centimeters,
points, and so on.
91
CSS Units
Relative length units specify a length relative to another length
property. Relative length units scales better between different
rendering mediums.) such as percentages and em units.
You need these values while specifying various measurements in your
style rules e.g. border="1px solid red".
92
93
THANKS!
ANY QUESTIONS?