SlideShare a Scribd company logo
Jimma Institute of Technology, Jimma University
Admas.abtew@ju.edu.et
0912499102
Faculty of Computing and Informatics
Internet Programming (IP)
Unit-01
Basics of HTML
and CSS
 Looping
Outline HTML
 Introduction to HTML
 What is a Web Page?
 My First HTML Page
 HTML Code Formatting
 Basic HTML Tags
 Heading
 Paragraph
 Color
 Font
 List
 Anchor
 Image
 HTML Tables
 HTML Forms
 HTML Meta tags
 Media tags
 HTML 5 tags and validation
Outline CSS
 What is CSS?
 Syntax and structure of CSS
 CSS rules for Backgrounds, Colors and properties
 Manipulating texts, Fonts
 The Box Model
 borders and boxes
 Margins and Padding
 Lists
 CSS Positioning and Float Property
 Animations
 Tooltip
 Style images
 Variables
 Media Queries
 Wildcard Selectors (*, ^ and $) in CSS
 Working with Gradients, Pseudo Class
 Pseudo elements
 basic of frameworks like Bootstrap
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 3
What is a Web Page?
 A webpage is a document, commonly written in HTML, that is viewed in an Internet browser.
 HTML – Hyper Text Markup Language is the notation for describing
 document structure (semantic markup)
 formatting (presentation markup)
 A web page can be accessed by entering a URL into a browser's address bar.
 A web page may contain text, graphics, and hyperlinks to other web pages and files.
 The first web page was created at CERN by Tim Berners-Lee on August 6, 1991.
 You can visit and browse the first website and the first web page at the info.cern.ch address.
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 4
Creating HTML Pages
 An HTML file must have an .htm or .html file extension
 HTML files can be created with text editors:
 NotePad, NotePad ++, PSPad
 Or HTML editors (WYSIWYG Editors):
 Microsoft FrontPage
 Macromedia Dreamweaver
 Netscape Composer
 Visual Studio
 Open any above mentioned editors and create a new file with .html extension and save the file.
 After saving the file you can open the file with any Web Browser in order to view the output.
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 5
First HTML Page
<!DOCTYPE HTML>
<html>
<head>
<title>My First HTML Page</title>
</head>
<body>
<p>This is some text...</p>
</body>
</html>
test.html
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 6
HTML Structure
 HTML is comprised of “elements” and “tags”
 Begins with <html> and ends with </html>
 Elements (tags) are nested one inside another:
 Tags have attributes:
 HTML describes structure using two main sections: <head> and <body>
 The HTML source code should be formatted to increase readability and facilitate debugging.
 Every block element should start on a new line.
 Every nested (block) element should be indented.
 Browsers ignore multiple whitespaces in the page source, so formatting is harmless.
 For performance reasons, formatting can be sacrificed
<html> <head></head> <body></body> </html>
<img src="logo.jpg" alt="logo" />
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 7
First HTML Page
<!DOCTYPE HTML>
<html>
<head>
<title>My First HTML Page</title>
</head>
<body>
<p>This is some text...</p>
</body>
</html>
Opening tag
Closing tag
HTML header
HTML body
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 8
Basic HTML Tags
1. Headings
2. Paragraph
3. Colors
4. Fonts
5. List
6. Anchor Tag
7. Image
8. Table
9. Form
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 9
1) Headings
 Headings are important because search engines use the headings to index the structure and
content of your web pages.
<h1> text </h1> -- largest of the six
<h2> text </h2>
<h3> text </h3>
<h4> text </h4>
<h5> text </h5>
<h6> text </h6> -- smallest of the six
align="position" --left (default), center or right
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 10
2) <p> Paragraph
 The HTML <p> element represents a paragraph.
 Paragraphs are usually represented in visual media as blocks of text separated from adjacent
blocks by blank lines and/or first-line indentation, but HTML paragraphs can be any structural
grouping of related content, such as images or form fields.
 Paragraphs are block-level elements, and notably will automatically close if another block-level
element is parsed before the closing </p> tag.
 We can use align attribute of the paragraph tag to specify the text alignment for the text inside
the paragraph, ex. <p align=“center”>our test</p>
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 11
3) Colors
 We can use color values for mainly two attributes named bgcolor and color.
 Possible values for the color are,
• many are predefined (red, blue, green, ...)
• all colors can be specified as a six character hexadecimal value: #RRGGBB
• #FF0000 – red
• #888888 – gray
• #00FF00 –green
• #000000 – black
 For example, <body bgcolor=“red”> or <body bgcolor=“#888888”>
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 12
4) Fonts
 The <font> tag specifies the font face, font size, and color of text.
 The <font> tag is not supported in HTML5.
<font color="red" size="2" face="Times Roman">
This is the text of line one
</font>
<br/>
<font color="green" size="4" face="Arial">
Line two contains this text
</font>
<br/>
<font color="#FF9933" size="6" face="Courier">
The third line has this additional text
</font>
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 13
5) List
Ordered List
1. Block-A
2. Block-B
3. Block-C
4. Block-D
Unordered List
• Block-A
• Block-B
• Block-C
• Block-D
a) Block-A
b) Block-B
c) Block-C
d) Block-D
o Block-A
o Block-B
o Block-C
o Block-D
A. Block-A
B. Block-B
C. Block-C
D. Block-D
 Block-A
 Block-B
 Block-C
 Block-D
i. Block-A
ii. Block-B
iii. Block-C
iv. Block-D
I. Block-A
II. Block-B
III. Block-C
IV. Block-D
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 14
5.1) Ordered List (OL)
<ol>
<li> Item one </li>
<li> Item two </li>
<ol type="I">
<li> Sublist item one </li>
<li> Sublist item two </li>
<ol type="i">
<li> Sub-sub list item one </li>
<li> Sub-sub list item two </li>
</ol>
</ol>
</ol>
Types:
Type = 1 (default)
Type = a
Type = A
Type = I
Type = i
Output
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 15
5.2) Unordered List (UL)
<ul>
<li> One </li>
<li> Two </li>
<ul type="circle">
<li> Three </li>
<li> Four </li>
<ul type="square">
<li> Five </li>
<li> Six </li>
</ul>
</ul>
</ul>
Types:
Type = disc (default)
Type = circle
Type = square
Output
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 16
6) <a> Anchor Tag (Hyperlinks)
 The <a> tag defines a hyperlink, which is used to link from one page to another.
 An Anchor tag have 3 important attributes:
 the href attribute (hypertext reference) defines the target address of the document.
 the name attribute of the anchor tag can be used to enable users to “jump” to a specific point on a page.
 the target attribute specifies how the destination page or the target document should be opened.
target="_ blank" is used for opening of the target page in a new tab.
 Link to an absolute URL:
 Example, <a href="http://www.darshan.ac.in"> Darshan </a>.
 Link to a relative URL:
 Example, <a href=“./index.php"> Home </a>.
 Link to a section within a URL:
 Example, <a href=“#reference"> Reference Section. </a>.
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 17
7) Images
 The HTML <img> element embeds an image into the document.
 Syntax: <img src= "pathToImage" />
 Attributes:
 the src attribute is required, and contains the path to the image we want to embed.
 the alt attribute holds a text description of the image, which isn't mandatory but is incredibly useful for
accessibility (screen readers read this description out to their users so they know what the image means). Alt
text is also displayed on the page if the image can't be loaded for some reason: for example, network errors,
content blocking etc…
 the width & height attribute can be in units of pixels or percentage of page or frame.
 the align attribute (currently deprecated) will aligns the image with its surrounding context (Use the float
and/or vertical-align CSS properties instead of this attribute).
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 18
8) Table
<table border=1>
<caption>Table Caption</caption>
<tr>
<th>Heading1</th>
<th>Heading2</th>
</tr>
<tr>
<td>Row1 Col1 Data</td>
<td>Row1 Col2 Data</td>
</tr>
<tr>
<td>Row2 Col1 Data</td>
<td>Row2 Col2 Data</td>
</tr>
</table>
<table> table tag
<caption> optional table title
<tr> table row
<th> table header
<td> table data element
Output
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 19
HTML Forms
 HTML forms are used to create GUIs on Web pages
• Usually the purpose is to ask the user for information
• The information is then sent back to the server
 A form is an area that can contain form elements
• The syntax is: <form parameters> ...form elements... </form>
• Form elements include: buttons, checkboxes, text fields, radio buttons, drop-down menus, etc
• Other kinds of HTML tags can be mixed in with the form elements
• A form usually contains a Submit button to send the information in the form elements to the server
• The form’s parameters tell browser how to send the information to the server (there are two different ways it
could be sent)
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 20
The <form> Tag
 The <form parameters> ... </form> tag encloses form elements (and probably other HTML
as well)
 The parameters to form tell what to do with the user input
• action="url" (required)
• Specifies where to send the data when the Submit button is clicked
• method="get" (default)
• Form data is sent as a URL with ?form_data info appended to the end
• Can be used only if data is all ASCII and not more than 100 characters
• method="post"
• Form data is sent in the body of the URL request
• Cannot be bookmarked by most browsers
• target="target"
• Tells where to open the page sent as a result of the request
• target= _blank means open in a new window
• target= _top means use the same window
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 21
Form Elements
 Input
 Select
 Textarea
 Button
 Label
 Fieldset
 Legend
 Etc…
Input Types (HTML4)
 text
 password
 checkbox
 radio
 submit
 button
 reset
 file
Input Types (HTML5)
 number
 email
 search
 url
 tel
 range
 color
 date
 time
 datetime-local
 month
 week
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 22
HTML5 Form Validation
 Form validation is a “technical process where a web-form checks if the information provided by
a user is correct.”
 The form will either alert the user that something is not in correct format and need to fix to
proceed, or the form will be validated and the user will be able to continue with their process.
 Form can be validated both in Client-Side as well as Server-Side, it is recommended to validate
the form in both the side.
 Form validation generally performs two functions.
1. Basic Validation
 Emptiness
 Length Validation etc……
2. Data Format Validation
Secondly, the data that is entered must be checked for correct form and value.
 Email Validation
 Mobile Number Validation
 Enrollment Number Validation etc….
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 23
HTML5 Form Validation (Cont…)
 We can use required attribute in order to stop user sending empty data to server.
 We can use pattern attribute in order to force some format on user before sending the data to
server.
 We can use title attribute for custom error message.
<input type="text" name="txtName" required/>
1
<input type="text" name="txtName" pattern="[0-9]{10}"/>
1
<input type="text" name="txtName"
pattern="[0-9]{10}"
title="Please enter 10 digit mobile number"
required/>
1
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 24
META Tag
 Metadata is data (information) about data.
 The <meta> tag provides metadata about the HTML document.
 Metadata will not be displayed on the page.
 Meta elements are typically used to specify page description, keywords, author of the
document, last modified and other metadata.
 The metadata can be used by search engines (keywords), browsers (how to display content or
reload page) or other web services.
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 25
Meta Tag Attributes
Attribute Value Description
charset character_set Specifies the character encoding for the HTML document
name
author
description
keywords
robots
expires
Specifies a name for the metadata
http-equiv
content-type
default-style
refresh
Provides an HTTP header for the information/value of the
content attribute
content text
Gives the value associated with the http-equiv or name
attribute
scheme
format/URI
USA/Europe
Not supported in HTML5. Specifies a scheme to be used to
interpret the value of the content attribute
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 26
Media Tags
 Video tag
 Audio tag
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 27
Video Tag
 The HTML <video> element is used to show a video on a web page.
 The controls attribute adds video controls, like play, pause, and volume.
 The width and height attributes are used to set width and height respectively.
 The autoplay attribute start a video automatically.
 The muted attribute will mute your video sound.
 The <source> element allows you to specify alternative video files in src attribute which the
browser may choose from. The browser will use the first recognized format.
 The text written in between the <video> and </video> tags will display only if browser do not
support the <video> element.
<video width="300" height="200" autoplay muted>
<source src=“video.mp4" type="video/mp4">
<source src=“video.ogg" type="video/ogg">
The video tag is not supported in your browser.
</video>
1
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 28
Audio Tag
 The HTML <audio> element is used to play an audio file on a web page.
 The controls attribute adds audio controls, like play, pause, and volume.
 The autoplay attribute start a audio automatically.
 The muted attribute will mute your audio sound.
 The <source> element allows you to specify alternative audio files in src attribute which the
browser may choose from. The browser will use the first recognized format.
 The text written in between the <audio> and </audio> tags will display only if browser do not
support the <audio> element.
<audio controls autoplay muted>
<source src=“myaudio.ogg" type="audio/ogg">
<source src=“myaudio.mp3" type="audio/mpeg">
The audio tag is not supported in your browser.
</audio>
1
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 29
What is CSS?
 Cascading Style Sheets, fondly referred to as CSS, is a simple design language intended to
simplify the process of making web pages presentable.
 CSS defines layout of HTML documents. For example, CSS covers Fonts, colors, margins, lines,
height, width, background images, advanced positions and many other things.
 Importance of CSS :
 CSS defines HOW HTML elements are to be displayed.
 Styles are normally saved in external .css files.
 External style sheets enable you to change the appearance and layout of all the pages in a Web site, just by
editing one single file.
 Advantages :
 Improves Website Presentation
 External CSS makes Updates Easier and Smoother
 External CSS helps Web Pages Load Faster
 Disadvantages :
 Browser Dependent
 Difficult to retrofit in old websites
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 30
Basic Syntax of CSS
 A CSS rule has two main parts: a selector, and one or more declarations
 The selector can be HTML element, id or class.
 Each declaration consists of a property and a value.
 The property is the style attribute you want to change. Each property has a value.
h1 {color:blue; font-size: 12px;}
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 31
The “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 "#“ in css.
 The style rule below will be applied to the element with id="para1":
HTML
<h1 id=“para1”>
Hello Friends
</h1>
<h1>
How are you
</h1>
CSS
#para1{
color: blue;
}
Output
Hello Friends
How are you
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 32
The “class” selector
 The class selector is used to specify a style for a group of elements.
 The class selector uses the HTML class attribute, and is defined with a ".“ in css.
HTML
<h1 class=“myClass”>
Hello Friends
</h1>
<h1>
How are you
</h1>
<h1 class=“myClass”>
How are you
</h1>
CSS
.myClass{
color: blue;
}
Output
Hello Friends
How are you
How are you
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 33
Different ways to write CSS
 There are three ways of writing a style sheet:
1. Inline Style
2. Internal/Embedded Style sheet
3. External Style Sheet
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 34
1) Inline Style
 It is possible to place CSS right in your HTML code, and this method of CSS usage is referred to
as inline css.
 Inline CSS has the highest priority out of external, internal, and inline CSS.
 This means that you can override styles that are defined in external or internal by using inline
CSS.
 If you want to add a style inside an HTML element all you have to do is specify the desired CSS
properties with the style HTML attribute.
 Example:
HTML
<p style="background: blue; color: white;"> My Inline CSS </p>
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 35
2) Internal Style Sheet
 This type of CSS is only for Single Web Page.
 When using internal CSS, we must add a new tag, <style>, inside the <head> tag.
 The HTML code below contains an example of <style>'s usage.
HTML
<html><head>
<style type="text/css">
p{ color: red;}
</style>
</head><body>
<p>Your page's content!</p></body>
</html>
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 36
3) External Style Sheet
 When using CSS it is preferable to keep the CSS separate from your HTML.
 Placing CSS in a separate file allows the web designer to completely differentiate between
content (HTML) and design (CSS).
 External CSS is a file that contains only CSS code and is saved with a ".css" file extension.
 This CSS file is then referenced in your HTML using the <link> instead of <style>.
Demo.html
<html>
<head>
<link rel=“stylesheet” type=“text/css”
href=“test.css”>
</head>
<body>
<p> Hello Friends </p>
<p id=“para1”> How are you? </p>
</body>
</html>
test.css
#para1{
text-align: center;
}
p
{
color : blue;
}
Output
Hello Friends
How are you?
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 37
3) External Style Sheet (Cont.)
 Advantages:
 It keeps your website design and content separate.
 It's much easier to reuse your CSS code if you have it in a separate file. Instead of typing the same CSS code
on every web page you have, simply have many pages refer to a single CSS file with the "link" tag.
 You can make drastic changes to your web pages with just a few changes in a single CSS file.
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 38
Assign Multiple Classes
 We can apply different class to same html element by giving space separated class names in
the class attribute:
Demo.html
<html>
<head>
<link rel=“stylesheet” type=“text/css”
href=“test.css”>
</head>
<body>
<h1 class=“class1 class2”>
How are you?
</h1>
</body>
</html>
test.css
. class1
{
color : blue;
}
. class2
{
text-align : center;
}
Output
How are you?
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 39
Multiple Selection
 We can apply same css to multiple selectors using comma separated selector list, for example
: Demo.html
<html>
<head>
<link rel=“stylesheet” type=“text/css”
href=“test.css”>
</head>
<body>
<p> Hello Friends </p>
<h1> How are you? </h1>
</body>
</html>
test.css
p, h1
{
color : blue;
}
Output
Hello Friends
How are you?
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 40
Multi-level Selection
 We can use hierarchical path to target html element by space separated element/class/id
names, for example :
Demo.html
<html>
<head>
<link rel=“stylesheet” type=“text/css”
href=“test.css”>
</head>
<body>
<h1>Hello Friends…</h1>
<div>
<h1>How are you?</h1>
</div>
</body>
</html>
test.css
div h1
{
color : blue;
}
Output
Hello Friends…
How are you?
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 41
Background Property
 Background Color (background-color)
 Background Image (background-image)
 Background Image Repeat (background-repeat)
 Fixed Background Image (background-attachment)
 Background Image Positioning (background-position)
Property Name
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 42
Background Color
 The background-color property specifies the background color of an element.
 The background color of a page is defined in the body selector:
 Below is example of CSS backgrounds
test.css
body
{
background-color : red;
background-color : #FF0000;
background-color : rgb(255,0,0);
}
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 43
Background Image
 The background-image property specifies an image to use as the background of an element.
 For Example,
test.css
body
{
background-image : url(‘pathToImage.jpg’);
}
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 44
Background Image Repeat
 You can have a background image repeat vertically (y-axis), horizontally (x-axis), in both
directions, or in neither direction.
test.css
body
{
background-image : url(‘pathToImage.jpg’);
background-repeat : repeat;
background-repeat : repeat-x;
background-repeat : repeat-y;
background-repeat : no-repeat;
}
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 45
Fixed Background Image
 The background-attachment property sets whether a background image is fixed or scrolls with
the rest of the page.
 For Example,
test.css
body
{
background-image : url(‘pathToImage.jpg’);
background-repeat : no-repeat;
background-attachment : fixed;
}
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 46
Background Image Positioning
 The background-position property sets the starting position of a background image.
test.css
body
{
background-image : url(‘pathToImage.jpg’);
background-repeat : no-repeat;
background-position: 20px 10px;
background-position: 30%30%;
background-position: top center;
}
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 47
CSS Font
 CSS font properties define the font family, boldness, size, and the style of a text.
1. Font Color (color)
2. Font Family (font-family)
3. Font Size (font-size)
4. Font Style (font-style)
5. Font Weight (font-weight)
6. Font Variant (font-variant)
Property Name
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 48
CSS Font (Cont.)
 Font Color
 Set the text-color for different elements
 Font Family
 The font family of a text is set with the font-family property.
 Font Size
 The font-size property sets the size of the text.
 font-size : 120%
 font-size : 10px;
 font-size : x-large;
h4{
color : red;
}
h4{
font-family : sans-serif;
}
h4{
font-size: 120%;
font-size : 10px;
font-size : small;
font-size : smaller;
font-size : x-small;
font-size : xx-small;
font-size : large;
font-size : larger;
font-size : x-large;
font-size : xx-large;
font-size : medium;
}
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 49
CSS Font (Cont.)
 Font Style
 The font-style property is mostly used to specify italic text.
 Font Weight
 The font-weight property sets how thick or thin characters in text
should be displayed.
 Font Variant
 The font-variant property specifies whether or not a text should be
displayed in a small-caps font.
 font-variant : small-caps;
h4{
font-style: italic ;
}
h4{
font-weight : 300;
font-weight : bolder;
font-weight : lighter;
}
h4{
font-variant: small-caps;
}
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 50
CSS Text Property
 While CSS Font covers most of the traditional ways to format your text, CSS Text allows you to
control the spacing, decoration, and alignment of your text.
1. Text Decoration (text-decoration)
2. Text Indent (text-indent)
3. Text Align (text-align)
4. Text Transform (text-transform)
5. White Space (white-space)
6. Word Spacing (word-spacing)
7. Letter Spacing (letter-spacing)
8. Line Height (line-height)
Property Name
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 51
CSS Text Property (Cont.)
 Text Decoration
 The text-decoration property is used to set or remove decorations
from text.
 The text-decoration property is mostly used to remove underlines
from links for design purposes.
 Text Indent
 The text-indentation property is used to specify the indentation of the
first line of a text.
 Text Align
 The text-align property is used to set the horizontal alignment of a
text.
h4{
text-decoration : line-through;
text-decoration : overline;
text-decoration : underline;
text-decoration : none;
}
h4{
text-indent : 20px;
text-indent : 30%;
}
h4{
text-align : right;
text-align : justify;
text-align : left;
text-align : center;
}
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 52
CSS Text Property (Cont.)
 Text Transform
 The text-transform property is used to specify uppercase and
lowercase letters in a text.
 White Space
 The white-space attribute allows you to prevent text from wrapping
until you place a break <br /> into your text.
 Word Spacing
 With the CSS attribute word-spacing you are able to specify the exact
value of the spacing between your words. Word-spacing should be
defined with exact values.
h4{
text-transform : capitalize;
text-transform : uppercase;
text-transform : lowercase;
}
h4{
white-space : nowrap;
white-space : normal;
white-space : pre;
}
h4{
word-spacing : 10px;
}
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 53
CSS Text Property (Cont.)
 Letter Spacing
 With the CSS attribute letter-spacing you are able to specify the exact
value of the spacing between your letters. Letter-spacing should be
defined with exact values.
 Line Height
 The line-height attribute will set the height of the line in the page.
h4{
letter-spacing : 3px;
}
h4{
line-height : 10px;
}
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 54
The Box Model
 All HTML elements can be considered as boxes. In CSS, the term "box model" is used when
talking about design and layout.
 The CSS box model is essentially a box that wraps around HTML elements, and it consists of:
margins, borders, padding, and the actual content.
 The box model allows us to place a border around elements and space elements in relation to
other elements.
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 55
The Box Model (Cont)
 The image below illustrates the box model:
Margin
Border
Padding
Content
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 56
The Box Model (Cont)
Content
padding-top
padding-bottom
padding-right
padding-left
border-top
margin-top
border-right
margin-right
border-bottom
margin-bottom
border-left
margin-left
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 57
CSS Padding
 The CSS padding properties define the space between the
element border and the element content.
 The top, right, bottom, and left padding can be changed
independently using separate properties.
 A shorthand padding property can also be used, to change all
padding at once.
h4{
padding : 10px;
}
h4{
padding-top : 10px;
padding-right : 20px;
padding-bottom : 30 px;
padding-left : 40 px;
}
h4{
padding : 10px 20px 30px 40px;
}
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 58
CSS Border
 The CSS border properties allow you to specify the style and
color of an element's border.
 Border Style Types
 The border-style property specifies what kind of border to display.
 Border Width
 The border-width property is used to set the width of the border.
 Border Color
 The border-color property is used to set the color of the border.
 Border colors can be any color defined by RGB, hexadecimal, or key
terms. Below is an example of each of these types.
 The top, right, bottom, and left border can be changed
independently using separate properties.
h4{
border : 1px solid red;
}
h4{
border-style : solid;
border-style : dotted;
border-style : double;
}
h4{
border-width : 7px;
}
h4{
border-color : red;
}
h4{
border-top : 1px solid red;
}
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 59
CSS Margin
 The CSS margin properties define the space around
elements
 The top, right, bottom, and left margin can be changed
independently using separate properties.
 A shorthand margin property can also be used, to change all
margins at once.
h4{
margin: 10px;
}
h4{
margin -top : 10px;
margin -right : 20px;
margin -bottom : 30 px;
margin -left : 40 px;
}
h4{
margin : 10px 20px 30px 40px;
}
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 60
CSS Positioning
 Absolute Positioning
 With absolute positioning, you define the exact pixel value where
the specified HTML element will appear.
 The point of origin is the top-left of the browser's viewable area,
so be sure you are measuring from that point.
 Relative Positioning
 Relative positioning changes the position of the HTML element
relative to where it normally appears
 Fixed Positioning
 The element is positioned relative to the browser window, in
fixed position, element will be in the same place even we scroll
the screen.
 Sticky Positioning
 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.
h1{
position : absolute;
left : 50px;
top : 100px;
}
h1{
position : relative;
left : 50px;
top : 100px;
}
h1{
position : fixed;
top : 50px;
left : 100px;
}
h1{
position : sticky;
top : 0px;
}
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 61
CSS Layers
 CSS allows you to control which item will appear on
top with the use of layers.
 In CSS, each element is given a priority.
 If there are two overlapping CSS positioned elements,
the element with the higher priority will appear on top
of the other.
 To manually define a priority, set the z-index value.
The larger the value, the higher the priority the
element will have.
CSS
#division1{
position : absolute;
height : 100px;
width : 100px;
left : 100px;
top : 150px;
background-color : red;
z-index : 5;
}
#division2{
position : absolute;
height : 200px;
width : 200px;
left : 50px;
top : 100px;
background-color : blue;
z-index : 2;
}
HTML
<div id="division1">
</div>
<div id="division2">
</div>
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 62
CSS Float Property
 The CSS float property defines that an element should be taken out of the normal flow of the
document and placed along the left or right side of its containing block.
 Text and inline elements will then wrap around this element.
HTML
<div id="division1">
ABC Content
</div>
<div id="division2">
XYZ Content
</div>
CSS
#division1{
background-color : red;
float : left;
width: 40%;
}
#division2{
background-color : blue;
float : right;
width: 40%;
}
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 63
Introduction to CSS3
 CSS3 is the latest standard for CSS.
 CSS3 is completely backwards-compatible with earlier versions of CSS.
 CSS3 has been split into "modules". It contains the "old CSS specification" (which has been
split into smaller pieces). In addition, new modules are added.
 CSS3 Transitions are a presentational effect which allow property changes in CSS values, such
as those that may be defined to occur on :hover or :focus, to occur smoothly over a specified
duration – rather than happening instantaneously as is the normal behavior.
 Transition effects can be applied to a wide variety of CSS properties, including background-
color, width, height, opacity, and many more.
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 64
Introduction to CSS3 (Cont)
 Some of the most important CSS3 modules are:
 CSS Animations and Transitions
 Calculating Values With calc()
 Advanced Selectors
 Generated Content and Counters
 Gradients
 Webfonts
 Box Sizing
 Border Images
 Media Queries
 Multiple Backgrounds
 CSS Columns
Courtesy : http://tutorialzine.com/2013/10/12-awesome-css3-features-you-can-finally-use/
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 65
Animations
 CSS animations make it possible to animate transitions from one CSS style configuration to
another.
 Animations consist of two components,
 a style describing the CSS animation
 a set of keyframes that indicate the start and end states of the animation’s style, as well as possible
intermediate waypoints.
 There are three key advantages to CSS animations over traditional script-driven animation
techniques:
 They’re easy to use for simple animations; you can create them without even having to know JavaScript.
 The animations run well, even under moderate system load. Simple animations can often perform poorly in
JavaScript. The rendering engine can use frame-skipping and other techniques to keep the performance as
smooth as possible.
 Letting the browser control the animation sequence lets the browser optimize performance and efficiency by,
for example, reducing the update frequency of animations running in tabs that aren't currently visible.
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 66
Configuring the animation
 To create a CSS animation sequence, you style the element you want to animate with the
animation property or its sub-properties. This lets you configure the timing, duration, and other
details of how the animation sequence should progress.
 Note: This does not configure the actual appearance of the animation, which is done using the @keyframes
 The sub-properties of the animation property are:
 animation-name : Specifies the name of the @keyframes at-rule describing the animation’s keyframes.
 animation-duration : Configures the length of time that an animation should take to complete one cycle.
 animation-timing-function : Configures the timing of the animation; that is, how the animation transitions
through keyframes, by establishing acceleration curves. (linear, ease, ease-in, ease-out etc…)
 animation-delay : Configures the delay between the time the element is loaded and the beginning of the
animation sequence.
 animation-iteration-count : Configures the number of times the animation should repeat; you can specify
infinite to repeat the animation indefinitely.
 animation-direction : Configures whether or not the animation should alternate direction on each run through
the sequence or reset to the start point and repeat itself. (normal, reverse, alternate etc…)
 animation-fill-mode : Configures what values are applied by the animation before and after it is executing.
 animation-play-state : Lets you pause and resume the animation sequence.
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 67
Defining the animation sequence using keyframes
 Once you’ve configured the animation’s timing, you need to define the appearance of the
animation. This is done by establishing two or more keyframes using the @keyframes at-rule.
 Each keyframe describes how the animated element should render at a given time during the
animation sequence.
 Example
CSS
p {
animation-duration: 3s;
animation-name: slidein;
}
@keyframes slidein {
from { /* or 0% */
margin-left: 100%;
width: 300%;
}
to { /* or 100% */
margin-left: 0%;
width: 100%;
}
}
HTML
<p>
Hello World
</p>
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 68
Specifying Intermediate steps
CSS
p {
animation-duration: 4s;
animation-name: changeColors;
}
@keyframes changeColors {
0% {background-color: yellow;}
25% {background-color: blue;}
50% {background-color: green;}
100% {background-color: red;}
}
HTML
<p>
Hello World
</p>
 We can specify intermediate steps using percentage of time in @keyframes, similar to the
example given below.
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 69
Tooltip
 A tooltip is often used to specify extra information about something when the user moves the
mouse pointer over an element.
CSS
.tooltip {
position: relative;
display: inline-block;
border-bottom: 1px dotted black;
}
HTML
<div class="tooltip">Hover here to see tooltip
<span class="tooltiptext">Tooltip text</span>
</div>
CSS
.tooltip .tooltiptext {
visibility: hidden;
width: 120px;
background-color: black;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
}
.tooltip:hover .tooltiptext {
visibility: visible;
}
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 70
Style Images
 We can use many properties with Images like,
 opacity
 border-radius
 margin-left, margin-right to be auto and display to be block (to make it aligned center)
 max-width to be 100% and height to be auto (to make it responsive)
 filter
 etc…
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 71
CSS Variables / Custom Properties
 Custom properties (sometimes referred to as CSS variables or cascading variables) are entities
defined by CSS authors that contain specific values to be reused throughout a document.
 Advantages of using CSS variables are:
 makes the code easier to read (more understandable)
 makes it much easier to change.
 CSS variables can have a global or local scope.
 Global variables can be accessed/used through the entire document.
 To create a variable with global scope, declare it inside the :root selector. The :root selector matches the document's
root element.
 local variables can be used only inside the selector where it is declared.
 To create a variable with local scope, declare it inside the selector that is going to use it.
 We can use var() function in order to access the variable set in the css.
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 72
CSS Variables (Example)
HTML
<p>
Hello World
</p>
<div>
How are you?
</div>
CSS
:root{
--myFavColor : orange;
--myNextFacColor : green;
}
p{
background-color: var(--myFavColor);
color: var(--myNextFacColor);
}
div{
background-color: var(--myNextFacColor);
color: var(--myFavColor);
}
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 73
Media Queries
 Media queries are a way to target browser by certain characteristics, features, and user
preferences, then apply styles or run other code based on those things.
 Perhaps the most common media queries in the world are those that target particular viewport
ranges and apply custom styles, which is the whole idea of responsive design.
 General syntax for the media queries in CSS is,
 It consists of:
 A media type, which tells the browser what kind of media this code is for (e.g. print, screen etc…).
 A media feature, which is a rule, or test that must be passed for the contained CSS to be applied.
 A set of CSS rules that will be applied if the test passes and the media type is correct.
Syntax
@media [media-type] ([media-feature]) {
/* Styles! */
}
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 74
Media Query (Cont.)
 Media Types:
 all
 print
 screen
 speech
 Media Features:
 width & height
 min-width, min-height, max-width & max-height
 orientation
 The viewport meta tag:
<meta name="viewport" content="width=device-width, initial-scale=1.0">
 This is needed because by default, most mobile browsers lie about their viewport width.
 Non-responsive sites commonly look really bad when rendered in a narrow viewport, so mobile browsers
usually render the site with a viewport width wider than the real device width by default (usually 960 pixels),
and then shrink the rendered result so that it fits in the display.
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 75
Media Query (Example)
HTML
<div id="div1">
Hello
</div>
<div id="div2">
World
</div>
CSS
#div1{
background-color: red;
width: 50%;
float: left;
}
#div2{
background-color: yellow;
width: 50%;
float: left;
}
@media (max-width: 600px){
#div1{
width: 100%;
}
#div2{
width: 100%;
}
}
Note: you have to add viewport meta tag in the head section
<meta name="viewport" content=
"width=device-width, initial-scale=1.0">
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 76
Media Query (cont.)
 We can also use and/or logic in media query, for example
 We can use and as a separator if we want two condition to satisfy before applying the CSS.
 We can use , (comma) as a separator if we want anyone of the condition to satisfy before applying the CSS.
CSS
@media screen and (min-width: 600px) and (max-width: 900px) {
body {
color: blue;
}
}
CSS
@media (min-width: 600px), (orientation: landscape) {
body {
color: blue;
}
}
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 77
Wild Card Selectors
 Wildcard selector is used to select multiple elements simultaneously.
 It selects similar type of class name or attribute and apply CSS property.
 Some of the wild card selector are,
 [attribute*=”str”] Selector ( e.g. [class*="str"] )
 It will select all the elements with the given attribute containing the str.
 [attribute^=”str”] Selector ( e.g. [class^="str"] )
 It will select all the elements with the given attribute starts with the str.
 [attribute$=”str”] Selector ( e.g. [class$="str"] )
 It will select all the elements with the given attribute ends with the str.
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 78
Gradients
 CSS gradients let you display smooth transitions between two or more specified colors.
 CSS defines two types of gradients:
 Linear Gradients (goes down/up/left/right/diagonally)
 To create a linear gradient you must define at least two color stops.
 Color stops are the colors you want to render smooth transitions among.
 You can also set a starting point and a direction (or an angle) along with the gradient effect.
 Radial Gradients (defined by their center)
 The radial-gradient() function sets a radial gradient as the background image.
 A radial gradient is defined by its center.
 To create a radial gradient you must define at least two color stops.
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 79
Linear Gradients
 To create a linear gradient you must define at least two color stops.
 Color stops are the colors you want to render smooth transitions among.
 You can also set a starting point and a direction (or an angle) along with the gradient effect.
 direction:
 to bottom
 to top
 to right
 to left
 to bottom left
 180deg
 Etc…
Syntax
background-image: linear-gradient(direction, color-stop1, color-stop2, ...);
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 80
Linear Gradients (Example)
 Example:
 Output:
CSS
background-image: linear-gradient(red, yellow);
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 81
Radial Gradients
 To create a linear gradient you must define at least two color stops.
 Color stops are the colors you want to render smooth transitions among.
 You can also set a starting point and a direction (or an angle) along with the gradient effect.
 shape:
 Ellipse (defalt)
 Circle
 size:
 farthest-corner (default)
 closest-corner
 farthest-side
 closest-side
 position:
 Center (default)
 Etc…
Syntax
background-image: radial-gradient(shape size at position, start-color, ..., last-color);
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 82
Radial Gradients (Example)
 Example:
 Output:
CSS
background-image: radial-gradient(red, green, yellow);
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 83
Pseudo Classes
 A pseudo-class is used to define a special state of an element.
 For example, it can be used to:
 Style an element when a user mouse over it
 Style visited and unvisited links differently
 Style an element when it gets focus
 Some important pseudo classes are:
 active
 disabled
 first-child
 nth-child()
 focus
 hover
 visited
Syntax
selector:pseudo-class {
property: value;
}
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 84
Pseudo Elements
 A CSS pseudo-element is used to style specified parts of an element.
 For example, it can be used to:
 Style the first letter, or line, of an element
 Insert content before, or after, the content of an element
 pseudo elements are,
 after
 before
 first-letter
 first-line
 selection
Syntax
selector::pseudo-element {
property: value;
}
Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 85
Bootstrap
 Bootstrap is Free front-end framework made of HTML, CSS and JavaScript Plugins (optional)
for developing Responsive Websites.
 Responsive websites means websites which Automatically Adjust themselves to look good on
all devices like mobile, desktop etc…
 Why to Use Bootstrap?
 Easy to use
 Anybody with just basic knowledge of HTML and CSS can start using Bootstrap
 Responsive features
 It's responsive CSS adjusts to phones, tablets, and desktops
 Mobile-first approach
 Mobile-first styles are part of the core framework
 Browser compatibility
 Compatible with all modern browsers (Chrome, Firefox, Internet Explorer, Safari, and Opera)
 Free
Jimma Institute of Technology, Jimma University
Thank
You
Admas.abtew@ju.edu.et
0912499102
Faculty of Computing and Informatics
Internet Programming (IP)

More Related Content

PPTX
Basics of Front End Web Dev PowerPoint
PDF
Introduction to HTML
PPT
Unit 1-HTML Final.ppt
PPTX
Lecture 2 - HTML Basics
PDF
Unit 2 (it workshop)
PPT
Web Design-III IT.ppt
PDF
GDI Seattle Intro to HTML and CSS - Class 1
PPT
IntroHTMzczczscasasaklahduasihiaSUJScgGJKKL.ppt
Basics of Front End Web Dev PowerPoint
Introduction to HTML
Unit 1-HTML Final.ppt
Lecture 2 - HTML Basics
Unit 2 (it workshop)
Web Design-III IT.ppt
GDI Seattle Intro to HTML and CSS - Class 1
IntroHTMzczczscasasaklahduasihiaSUJScgGJKKL.ppt

Similar to Chapter_One-Internet Programming.Prepare a ppt of video compression techniques based on the information provided earlier and this ppt that includes at least 20 pages and explain clearly in an organized and efficient manner (20)

PDF
2a web technology html basics 1
PPT
HyperTextMarkupLanguage.ppt
PPTX
PPTX
PPTX
PPTX
html css intro sanskar , saurabh.pptx
PPTX
Html css java script basics All about you need
PPTX
Lab1_HTML.pptx
PPTX
Html n CSS
PPTX
Html starting
PDF
Html & Html5 from scratch
PPTX
Lecture 2 HTML part 1.pptxLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
PPT
Introduction to Web Technology and Web Page Development
PPTX
University undergraduate HTML notes for free for CSIT
PPTX
INTRODUCTION CODING - THE HTML AND CSS.pptx
PPTX
Web development (html)
PPT
Introduction to HTML, CSS, and Scripting In the world of web development, thr...
PPTX
Session ii(html)
PPTX
HTML.pptx
2a web technology html basics 1
HyperTextMarkupLanguage.ppt
html css intro sanskar , saurabh.pptx
Html css java script basics All about you need
Lab1_HTML.pptx
Html n CSS
Html starting
Html & Html5 from scratch
Lecture 2 HTML part 1.pptxLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Introduction to Web Technology and Web Page Development
University undergraduate HTML notes for free for CSIT
INTRODUCTION CODING - THE HTML AND CSS.pptx
Web development (html)
Introduction to HTML, CSS, and Scripting In the world of web development, thr...
Session ii(html)
HTML.pptx
Ad

Recently uploaded (20)

PDF
final_dropping_the_baton_-_how_america_is_failing_to_use_russia_sanctions_and...
PDF
Mathematical Economics 23lec03slides.pdf
PDF
1a In Search of the Numbers ssrn 1488130 Oct 2009.pdf
PDF
Copia de Minimal 3D Technology Consulting Presentation.pdf
PDF
Bitcoin Layer August 2025: Power Laws of Bitcoin: The Core and Bubbles
PPTX
EABDM Slides for Indifference curve.pptx
PDF
ABriefOverviewComparisonUCP600_ISP8_URDG_758.pdf
PDF
Predicting Customer Bankruptcy Using Machine Learning Algorithm research pape...
PPTX
introuction to banking- Types of Payment Methods
PPTX
How best to drive Metrics, Ratios, and Key Performance Indicators
PPTX
Unilever_Financial_Analysis_Presentation.pptx
PDF
Corporate Finance Fundamentals - Course Presentation.pdf
PDF
discourse-2025-02-building-a-trillion-dollar-dream.pdf
PPTX
Session 11-13. Working Capital Management and Cash Budget.pptx
PDF
Q2 2025 :Lundin Gold Conference Call Presentation_Final.pdf
PDF
ECONOMICS AND ENTREPRENEURS LESSONSS AND
PDF
Dr Tran Quoc Bao the first Vietnamese speaker at GITEX DigiHealth Conference ...
PDF
Buy Verified Stripe Accounts for Sale - Secure and.pdf
PDF
way to join Real illuminati agent 0782561496,0756664682
PPTX
Session 14-16. Capital Structure Theories.pptx
final_dropping_the_baton_-_how_america_is_failing_to_use_russia_sanctions_and...
Mathematical Economics 23lec03slides.pdf
1a In Search of the Numbers ssrn 1488130 Oct 2009.pdf
Copia de Minimal 3D Technology Consulting Presentation.pdf
Bitcoin Layer August 2025: Power Laws of Bitcoin: The Core and Bubbles
EABDM Slides for Indifference curve.pptx
ABriefOverviewComparisonUCP600_ISP8_URDG_758.pdf
Predicting Customer Bankruptcy Using Machine Learning Algorithm research pape...
introuction to banking- Types of Payment Methods
How best to drive Metrics, Ratios, and Key Performance Indicators
Unilever_Financial_Analysis_Presentation.pptx
Corporate Finance Fundamentals - Course Presentation.pdf
discourse-2025-02-building-a-trillion-dollar-dream.pdf
Session 11-13. Working Capital Management and Cash Budget.pptx
Q2 2025 :Lundin Gold Conference Call Presentation_Final.pdf
ECONOMICS AND ENTREPRENEURS LESSONSS AND
Dr Tran Quoc Bao the first Vietnamese speaker at GITEX DigiHealth Conference ...
Buy Verified Stripe Accounts for Sale - Secure and.pdf
way to join Real illuminati agent 0782561496,0756664682
Session 14-16. Capital Structure Theories.pptx
Ad

Chapter_One-Internet Programming.Prepare a ppt of video compression techniques based on the information provided earlier and this ppt that includes at least 20 pages and explain clearly in an organized and efficient manner

  • 1. Jimma Institute of Technology, Jimma University Admas.abtew@ju.edu.et 0912499102 Faculty of Computing and Informatics Internet Programming (IP) Unit-01 Basics of HTML and CSS
  • 2.  Looping Outline HTML  Introduction to HTML  What is a Web Page?  My First HTML Page  HTML Code Formatting  Basic HTML Tags  Heading  Paragraph  Color  Font  List  Anchor  Image  HTML Tables  HTML Forms  HTML Meta tags  Media tags  HTML 5 tags and validation Outline CSS  What is CSS?  Syntax and structure of CSS  CSS rules for Backgrounds, Colors and properties  Manipulating texts, Fonts  The Box Model  borders and boxes  Margins and Padding  Lists  CSS Positioning and Float Property  Animations  Tooltip  Style images  Variables  Media Queries  Wildcard Selectors (*, ^ and $) in CSS  Working with Gradients, Pseudo Class  Pseudo elements  basic of frameworks like Bootstrap
  • 3. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 3 What is a Web Page?  A webpage is a document, commonly written in HTML, that is viewed in an Internet browser.  HTML – Hyper Text Markup Language is the notation for describing  document structure (semantic markup)  formatting (presentation markup)  A web page can be accessed by entering a URL into a browser's address bar.  A web page may contain text, graphics, and hyperlinks to other web pages and files.  The first web page was created at CERN by Tim Berners-Lee on August 6, 1991.  You can visit and browse the first website and the first web page at the info.cern.ch address.
  • 4. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 4 Creating HTML Pages  An HTML file must have an .htm or .html file extension  HTML files can be created with text editors:  NotePad, NotePad ++, PSPad  Or HTML editors (WYSIWYG Editors):  Microsoft FrontPage  Macromedia Dreamweaver  Netscape Composer  Visual Studio  Open any above mentioned editors and create a new file with .html extension and save the file.  After saving the file you can open the file with any Web Browser in order to view the output.
  • 5. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 5 First HTML Page <!DOCTYPE HTML> <html> <head> <title>My First HTML Page</title> </head> <body> <p>This is some text...</p> </body> </html> test.html
  • 6. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 6 HTML Structure  HTML is comprised of “elements” and “tags”  Begins with <html> and ends with </html>  Elements (tags) are nested one inside another:  Tags have attributes:  HTML describes structure using two main sections: <head> and <body>  The HTML source code should be formatted to increase readability and facilitate debugging.  Every block element should start on a new line.  Every nested (block) element should be indented.  Browsers ignore multiple whitespaces in the page source, so formatting is harmless.  For performance reasons, formatting can be sacrificed <html> <head></head> <body></body> </html> <img src="logo.jpg" alt="logo" />
  • 7. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 7 First HTML Page <!DOCTYPE HTML> <html> <head> <title>My First HTML Page</title> </head> <body> <p>This is some text...</p> </body> </html> Opening tag Closing tag HTML header HTML body
  • 8. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 8 Basic HTML Tags 1. Headings 2. Paragraph 3. Colors 4. Fonts 5. List 6. Anchor Tag 7. Image 8. Table 9. Form
  • 9. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 9 1) Headings  Headings are important because search engines use the headings to index the structure and content of your web pages. <h1> text </h1> -- largest of the six <h2> text </h2> <h3> text </h3> <h4> text </h4> <h5> text </h5> <h6> text </h6> -- smallest of the six align="position" --left (default), center or right
  • 10. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 10 2) <p> Paragraph  The HTML <p> element represents a paragraph.  Paragraphs are usually represented in visual media as blocks of text separated from adjacent blocks by blank lines and/or first-line indentation, but HTML paragraphs can be any structural grouping of related content, such as images or form fields.  Paragraphs are block-level elements, and notably will automatically close if another block-level element is parsed before the closing </p> tag.  We can use align attribute of the paragraph tag to specify the text alignment for the text inside the paragraph, ex. <p align=“center”>our test</p>
  • 11. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 11 3) Colors  We can use color values for mainly two attributes named bgcolor and color.  Possible values for the color are, • many are predefined (red, blue, green, ...) • all colors can be specified as a six character hexadecimal value: #RRGGBB • #FF0000 – red • #888888 – gray • #00FF00 –green • #000000 – black  For example, <body bgcolor=“red”> or <body bgcolor=“#888888”>
  • 12. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 12 4) Fonts  The <font> tag specifies the font face, font size, and color of text.  The <font> tag is not supported in HTML5. <font color="red" size="2" face="Times Roman"> This is the text of line one </font> <br/> <font color="green" size="4" face="Arial"> Line two contains this text </font> <br/> <font color="#FF9933" size="6" face="Courier"> The third line has this additional text </font>
  • 13. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 13 5) List Ordered List 1. Block-A 2. Block-B 3. Block-C 4. Block-D Unordered List • Block-A • Block-B • Block-C • Block-D a) Block-A b) Block-B c) Block-C d) Block-D o Block-A o Block-B o Block-C o Block-D A. Block-A B. Block-B C. Block-C D. Block-D  Block-A  Block-B  Block-C  Block-D i. Block-A ii. Block-B iii. Block-C iv. Block-D I. Block-A II. Block-B III. Block-C IV. Block-D
  • 14. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 14 5.1) Ordered List (OL) <ol> <li> Item one </li> <li> Item two </li> <ol type="I"> <li> Sublist item one </li> <li> Sublist item two </li> <ol type="i"> <li> Sub-sub list item one </li> <li> Sub-sub list item two </li> </ol> </ol> </ol> Types: Type = 1 (default) Type = a Type = A Type = I Type = i Output
  • 15. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 15 5.2) Unordered List (UL) <ul> <li> One </li> <li> Two </li> <ul type="circle"> <li> Three </li> <li> Four </li> <ul type="square"> <li> Five </li> <li> Six </li> </ul> </ul> </ul> Types: Type = disc (default) Type = circle Type = square Output
  • 16. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 16 6) <a> Anchor Tag (Hyperlinks)  The <a> tag defines a hyperlink, which is used to link from one page to another.  An Anchor tag have 3 important attributes:  the href attribute (hypertext reference) defines the target address of the document.  the name attribute of the anchor tag can be used to enable users to “jump” to a specific point on a page.  the target attribute specifies how the destination page or the target document should be opened. target="_ blank" is used for opening of the target page in a new tab.  Link to an absolute URL:  Example, <a href="http://www.darshan.ac.in"> Darshan </a>.  Link to a relative URL:  Example, <a href=“./index.php"> Home </a>.  Link to a section within a URL:  Example, <a href=“#reference"> Reference Section. </a>.
  • 17. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 17 7) Images  The HTML <img> element embeds an image into the document.  Syntax: <img src= "pathToImage" />  Attributes:  the src attribute is required, and contains the path to the image we want to embed.  the alt attribute holds a text description of the image, which isn't mandatory but is incredibly useful for accessibility (screen readers read this description out to their users so they know what the image means). Alt text is also displayed on the page if the image can't be loaded for some reason: for example, network errors, content blocking etc…  the width & height attribute can be in units of pixels or percentage of page or frame.  the align attribute (currently deprecated) will aligns the image with its surrounding context (Use the float and/or vertical-align CSS properties instead of this attribute).
  • 18. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 18 8) Table <table border=1> <caption>Table Caption</caption> <tr> <th>Heading1</th> <th>Heading2</th> </tr> <tr> <td>Row1 Col1 Data</td> <td>Row1 Col2 Data</td> </tr> <tr> <td>Row2 Col1 Data</td> <td>Row2 Col2 Data</td> </tr> </table> <table> table tag <caption> optional table title <tr> table row <th> table header <td> table data element Output
  • 19. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 19 HTML Forms  HTML forms are used to create GUIs on Web pages • Usually the purpose is to ask the user for information • The information is then sent back to the server  A form is an area that can contain form elements • The syntax is: <form parameters> ...form elements... </form> • Form elements include: buttons, checkboxes, text fields, radio buttons, drop-down menus, etc • Other kinds of HTML tags can be mixed in with the form elements • A form usually contains a Submit button to send the information in the form elements to the server • The form’s parameters tell browser how to send the information to the server (there are two different ways it could be sent)
  • 20. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 20 The <form> Tag  The <form parameters> ... </form> tag encloses form elements (and probably other HTML as well)  The parameters to form tell what to do with the user input • action="url" (required) • Specifies where to send the data when the Submit button is clicked • method="get" (default) • Form data is sent as a URL with ?form_data info appended to the end • Can be used only if data is all ASCII and not more than 100 characters • method="post" • Form data is sent in the body of the URL request • Cannot be bookmarked by most browsers • target="target" • Tells where to open the page sent as a result of the request • target= _blank means open in a new window • target= _top means use the same window
  • 21. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 21 Form Elements  Input  Select  Textarea  Button  Label  Fieldset  Legend  Etc… Input Types (HTML4)  text  password  checkbox  radio  submit  button  reset  file Input Types (HTML5)  number  email  search  url  tel  range  color  date  time  datetime-local  month  week
  • 22. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 22 HTML5 Form Validation  Form validation is a “technical process where a web-form checks if the information provided by a user is correct.”  The form will either alert the user that something is not in correct format and need to fix to proceed, or the form will be validated and the user will be able to continue with their process.  Form can be validated both in Client-Side as well as Server-Side, it is recommended to validate the form in both the side.  Form validation generally performs two functions. 1. Basic Validation  Emptiness  Length Validation etc…… 2. Data Format Validation Secondly, the data that is entered must be checked for correct form and value.  Email Validation  Mobile Number Validation  Enrollment Number Validation etc….
  • 23. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 23 HTML5 Form Validation (Cont…)  We can use required attribute in order to stop user sending empty data to server.  We can use pattern attribute in order to force some format on user before sending the data to server.  We can use title attribute for custom error message. <input type="text" name="txtName" required/> 1 <input type="text" name="txtName" pattern="[0-9]{10}"/> 1 <input type="text" name="txtName" pattern="[0-9]{10}" title="Please enter 10 digit mobile number" required/> 1
  • 24. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 24 META Tag  Metadata is data (information) about data.  The <meta> tag provides metadata about the HTML document.  Metadata will not be displayed on the page.  Meta elements are typically used to specify page description, keywords, author of the document, last modified and other metadata.  The metadata can be used by search engines (keywords), browsers (how to display content or reload page) or other web services.
  • 25. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 25 Meta Tag Attributes Attribute Value Description charset character_set Specifies the character encoding for the HTML document name author description keywords robots expires Specifies a name for the metadata http-equiv content-type default-style refresh Provides an HTTP header for the information/value of the content attribute content text Gives the value associated with the http-equiv or name attribute scheme format/URI USA/Europe Not supported in HTML5. Specifies a scheme to be used to interpret the value of the content attribute
  • 26. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 26 Media Tags  Video tag  Audio tag
  • 27. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 27 Video Tag  The HTML <video> element is used to show a video on a web page.  The controls attribute adds video controls, like play, pause, and volume.  The width and height attributes are used to set width and height respectively.  The autoplay attribute start a video automatically.  The muted attribute will mute your video sound.  The <source> element allows you to specify alternative video files in src attribute which the browser may choose from. The browser will use the first recognized format.  The text written in between the <video> and </video> tags will display only if browser do not support the <video> element. <video width="300" height="200" autoplay muted> <source src=“video.mp4" type="video/mp4"> <source src=“video.ogg" type="video/ogg"> The video tag is not supported in your browser. </video> 1
  • 28. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 28 Audio Tag  The HTML <audio> element is used to play an audio file on a web page.  The controls attribute adds audio controls, like play, pause, and volume.  The autoplay attribute start a audio automatically.  The muted attribute will mute your audio sound.  The <source> element allows you to specify alternative audio files in src attribute which the browser may choose from. The browser will use the first recognized format.  The text written in between the <audio> and </audio> tags will display only if browser do not support the <audio> element. <audio controls autoplay muted> <source src=“myaudio.ogg" type="audio/ogg"> <source src=“myaudio.mp3" type="audio/mpeg"> The audio tag is not supported in your browser. </audio> 1
  • 29. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 29 What is CSS?  Cascading Style Sheets, fondly referred to as CSS, is a simple design language intended to simplify the process of making web pages presentable.  CSS defines layout of HTML documents. For example, CSS covers Fonts, colors, margins, lines, height, width, background images, advanced positions and many other things.  Importance of CSS :  CSS defines HOW HTML elements are to be displayed.  Styles are normally saved in external .css files.  External style sheets enable you to change the appearance and layout of all the pages in a Web site, just by editing one single file.  Advantages :  Improves Website Presentation  External CSS makes Updates Easier and Smoother  External CSS helps Web Pages Load Faster  Disadvantages :  Browser Dependent  Difficult to retrofit in old websites
  • 30. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 30 Basic Syntax of CSS  A CSS rule has two main parts: a selector, and one or more declarations  The selector can be HTML element, id or class.  Each declaration consists of a property and a value.  The property is the style attribute you want to change. Each property has a value. h1 {color:blue; font-size: 12px;}
  • 31. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 31 The “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 "#“ in css.  The style rule below will be applied to the element with id="para1": HTML <h1 id=“para1”> Hello Friends </h1> <h1> How are you </h1> CSS #para1{ color: blue; } Output Hello Friends How are you
  • 32. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 32 The “class” selector  The class selector is used to specify a style for a group of elements.  The class selector uses the HTML class attribute, and is defined with a ".“ in css. HTML <h1 class=“myClass”> Hello Friends </h1> <h1> How are you </h1> <h1 class=“myClass”> How are you </h1> CSS .myClass{ color: blue; } Output Hello Friends How are you How are you
  • 33. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 33 Different ways to write CSS  There are three ways of writing a style sheet: 1. Inline Style 2. Internal/Embedded Style sheet 3. External Style Sheet
  • 34. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 34 1) Inline Style  It is possible to place CSS right in your HTML code, and this method of CSS usage is referred to as inline css.  Inline CSS has the highest priority out of external, internal, and inline CSS.  This means that you can override styles that are defined in external or internal by using inline CSS.  If you want to add a style inside an HTML element all you have to do is specify the desired CSS properties with the style HTML attribute.  Example: HTML <p style="background: blue; color: white;"> My Inline CSS </p>
  • 35. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 35 2) Internal Style Sheet  This type of CSS is only for Single Web Page.  When using internal CSS, we must add a new tag, <style>, inside the <head> tag.  The HTML code below contains an example of <style>'s usage. HTML <html><head> <style type="text/css"> p{ color: red;} </style> </head><body> <p>Your page's content!</p></body> </html>
  • 36. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 36 3) External Style Sheet  When using CSS it is preferable to keep the CSS separate from your HTML.  Placing CSS in a separate file allows the web designer to completely differentiate between content (HTML) and design (CSS).  External CSS is a file that contains only CSS code and is saved with a ".css" file extension.  This CSS file is then referenced in your HTML using the <link> instead of <style>. Demo.html <html> <head> <link rel=“stylesheet” type=“text/css” href=“test.css”> </head> <body> <p> Hello Friends </p> <p id=“para1”> How are you? </p> </body> </html> test.css #para1{ text-align: center; } p { color : blue; } Output Hello Friends How are you?
  • 37. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 37 3) External Style Sheet (Cont.)  Advantages:  It keeps your website design and content separate.  It's much easier to reuse your CSS code if you have it in a separate file. Instead of typing the same CSS code on every web page you have, simply have many pages refer to a single CSS file with the "link" tag.  You can make drastic changes to your web pages with just a few changes in a single CSS file.
  • 38. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 38 Assign Multiple Classes  We can apply different class to same html element by giving space separated class names in the class attribute: Demo.html <html> <head> <link rel=“stylesheet” type=“text/css” href=“test.css”> </head> <body> <h1 class=“class1 class2”> How are you? </h1> </body> </html> test.css . class1 { color : blue; } . class2 { text-align : center; } Output How are you?
  • 39. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 39 Multiple Selection  We can apply same css to multiple selectors using comma separated selector list, for example : Demo.html <html> <head> <link rel=“stylesheet” type=“text/css” href=“test.css”> </head> <body> <p> Hello Friends </p> <h1> How are you? </h1> </body> </html> test.css p, h1 { color : blue; } Output Hello Friends How are you?
  • 40. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 40 Multi-level Selection  We can use hierarchical path to target html element by space separated element/class/id names, for example : Demo.html <html> <head> <link rel=“stylesheet” type=“text/css” href=“test.css”> </head> <body> <h1>Hello Friends…</h1> <div> <h1>How are you?</h1> </div> </body> </html> test.css div h1 { color : blue; } Output Hello Friends… How are you?
  • 41. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 41 Background Property  Background Color (background-color)  Background Image (background-image)  Background Image Repeat (background-repeat)  Fixed Background Image (background-attachment)  Background Image Positioning (background-position) Property Name
  • 42. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 42 Background Color  The background-color property specifies the background color of an element.  The background color of a page is defined in the body selector:  Below is example of CSS backgrounds test.css body { background-color : red; background-color : #FF0000; background-color : rgb(255,0,0); }
  • 43. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 43 Background Image  The background-image property specifies an image to use as the background of an element.  For Example, test.css body { background-image : url(‘pathToImage.jpg’); }
  • 44. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 44 Background Image Repeat  You can have a background image repeat vertically (y-axis), horizontally (x-axis), in both directions, or in neither direction. test.css body { background-image : url(‘pathToImage.jpg’); background-repeat : repeat; background-repeat : repeat-x; background-repeat : repeat-y; background-repeat : no-repeat; }
  • 45. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 45 Fixed Background Image  The background-attachment property sets whether a background image is fixed or scrolls with the rest of the page.  For Example, test.css body { background-image : url(‘pathToImage.jpg’); background-repeat : no-repeat; background-attachment : fixed; }
  • 46. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 46 Background Image Positioning  The background-position property sets the starting position of a background image. test.css body { background-image : url(‘pathToImage.jpg’); background-repeat : no-repeat; background-position: 20px 10px; background-position: 30%30%; background-position: top center; }
  • 47. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 47 CSS Font  CSS font properties define the font family, boldness, size, and the style of a text. 1. Font Color (color) 2. Font Family (font-family) 3. Font Size (font-size) 4. Font Style (font-style) 5. Font Weight (font-weight) 6. Font Variant (font-variant) Property Name
  • 48. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 48 CSS Font (Cont.)  Font Color  Set the text-color for different elements  Font Family  The font family of a text is set with the font-family property.  Font Size  The font-size property sets the size of the text.  font-size : 120%  font-size : 10px;  font-size : x-large; h4{ color : red; } h4{ font-family : sans-serif; } h4{ font-size: 120%; font-size : 10px; font-size : small; font-size : smaller; font-size : x-small; font-size : xx-small; font-size : large; font-size : larger; font-size : x-large; font-size : xx-large; font-size : medium; }
  • 49. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 49 CSS Font (Cont.)  Font Style  The font-style property is mostly used to specify italic text.  Font Weight  The font-weight property sets how thick or thin characters in text should be displayed.  Font Variant  The font-variant property specifies whether or not a text should be displayed in a small-caps font.  font-variant : small-caps; h4{ font-style: italic ; } h4{ font-weight : 300; font-weight : bolder; font-weight : lighter; } h4{ font-variant: small-caps; }
  • 50. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 50 CSS Text Property  While CSS Font covers most of the traditional ways to format your text, CSS Text allows you to control the spacing, decoration, and alignment of your text. 1. Text Decoration (text-decoration) 2. Text Indent (text-indent) 3. Text Align (text-align) 4. Text Transform (text-transform) 5. White Space (white-space) 6. Word Spacing (word-spacing) 7. Letter Spacing (letter-spacing) 8. Line Height (line-height) Property Name
  • 51. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 51 CSS Text Property (Cont.)  Text Decoration  The text-decoration property is used to set or remove decorations from text.  The text-decoration property is mostly used to remove underlines from links for design purposes.  Text Indent  The text-indentation property is used to specify the indentation of the first line of a text.  Text Align  The text-align property is used to set the horizontal alignment of a text. h4{ text-decoration : line-through; text-decoration : overline; text-decoration : underline; text-decoration : none; } h4{ text-indent : 20px; text-indent : 30%; } h4{ text-align : right; text-align : justify; text-align : left; text-align : center; }
  • 52. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 52 CSS Text Property (Cont.)  Text Transform  The text-transform property is used to specify uppercase and lowercase letters in a text.  White Space  The white-space attribute allows you to prevent text from wrapping until you place a break <br /> into your text.  Word Spacing  With the CSS attribute word-spacing you are able to specify the exact value of the spacing between your words. Word-spacing should be defined with exact values. h4{ text-transform : capitalize; text-transform : uppercase; text-transform : lowercase; } h4{ white-space : nowrap; white-space : normal; white-space : pre; } h4{ word-spacing : 10px; }
  • 53. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 53 CSS Text Property (Cont.)  Letter Spacing  With the CSS attribute letter-spacing you are able to specify the exact value of the spacing between your letters. Letter-spacing should be defined with exact values.  Line Height  The line-height attribute will set the height of the line in the page. h4{ letter-spacing : 3px; } h4{ line-height : 10px; }
  • 54. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 54 The Box Model  All HTML elements can be considered as boxes. In CSS, the term "box model" is used when talking about design and layout.  The CSS box model is essentially a box that wraps around HTML elements, and it consists of: margins, borders, padding, and the actual content.  The box model allows us to place a border around elements and space elements in relation to other elements.
  • 55. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 55 The Box Model (Cont)  The image below illustrates the box model: Margin Border Padding Content
  • 56. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 56 The Box Model (Cont) Content padding-top padding-bottom padding-right padding-left border-top margin-top border-right margin-right border-bottom margin-bottom border-left margin-left
  • 57. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 57 CSS Padding  The CSS padding properties define the space between the element border and the element content.  The top, right, bottom, and left padding can be changed independently using separate properties.  A shorthand padding property can also be used, to change all padding at once. h4{ padding : 10px; } h4{ padding-top : 10px; padding-right : 20px; padding-bottom : 30 px; padding-left : 40 px; } h4{ padding : 10px 20px 30px 40px; }
  • 58. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 58 CSS Border  The CSS border properties allow you to specify the style and color of an element's border.  Border Style Types  The border-style property specifies what kind of border to display.  Border Width  The border-width property is used to set the width of the border.  Border Color  The border-color property is used to set the color of the border.  Border colors can be any color defined by RGB, hexadecimal, or key terms. Below is an example of each of these types.  The top, right, bottom, and left border can be changed independently using separate properties. h4{ border : 1px solid red; } h4{ border-style : solid; border-style : dotted; border-style : double; } h4{ border-width : 7px; } h4{ border-color : red; } h4{ border-top : 1px solid red; }
  • 59. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 59 CSS Margin  The CSS margin properties define the space around elements  The top, right, bottom, and left margin can be changed independently using separate properties.  A shorthand margin property can also be used, to change all margins at once. h4{ margin: 10px; } h4{ margin -top : 10px; margin -right : 20px; margin -bottom : 30 px; margin -left : 40 px; } h4{ margin : 10px 20px 30px 40px; }
  • 60. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 60 CSS Positioning  Absolute Positioning  With absolute positioning, you define the exact pixel value where the specified HTML element will appear.  The point of origin is the top-left of the browser's viewable area, so be sure you are measuring from that point.  Relative Positioning  Relative positioning changes the position of the HTML element relative to where it normally appears  Fixed Positioning  The element is positioned relative to the browser window, in fixed position, element will be in the same place even we scroll the screen.  Sticky Positioning  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. h1{ position : absolute; left : 50px; top : 100px; } h1{ position : relative; left : 50px; top : 100px; } h1{ position : fixed; top : 50px; left : 100px; } h1{ position : sticky; top : 0px; }
  • 61. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 61 CSS Layers  CSS allows you to control which item will appear on top with the use of layers.  In CSS, each element is given a priority.  If there are two overlapping CSS positioned elements, the element with the higher priority will appear on top of the other.  To manually define a priority, set the z-index value. The larger the value, the higher the priority the element will have. CSS #division1{ position : absolute; height : 100px; width : 100px; left : 100px; top : 150px; background-color : red; z-index : 5; } #division2{ position : absolute; height : 200px; width : 200px; left : 50px; top : 100px; background-color : blue; z-index : 2; } HTML <div id="division1"> </div> <div id="division2"> </div>
  • 62. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 62 CSS Float Property  The CSS float property defines that an element should be taken out of the normal flow of the document and placed along the left or right side of its containing block.  Text and inline elements will then wrap around this element. HTML <div id="division1"> ABC Content </div> <div id="division2"> XYZ Content </div> CSS #division1{ background-color : red; float : left; width: 40%; } #division2{ background-color : blue; float : right; width: 40%; }
  • 63. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 63 Introduction to CSS3  CSS3 is the latest standard for CSS.  CSS3 is completely backwards-compatible with earlier versions of CSS.  CSS3 has been split into "modules". It contains the "old CSS specification" (which has been split into smaller pieces). In addition, new modules are added.  CSS3 Transitions are a presentational effect which allow property changes in CSS values, such as those that may be defined to occur on :hover or :focus, to occur smoothly over a specified duration – rather than happening instantaneously as is the normal behavior.  Transition effects can be applied to a wide variety of CSS properties, including background- color, width, height, opacity, and many more.
  • 64. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 64 Introduction to CSS3 (Cont)  Some of the most important CSS3 modules are:  CSS Animations and Transitions  Calculating Values With calc()  Advanced Selectors  Generated Content and Counters  Gradients  Webfonts  Box Sizing  Border Images  Media Queries  Multiple Backgrounds  CSS Columns Courtesy : http://tutorialzine.com/2013/10/12-awesome-css3-features-you-can-finally-use/
  • 65. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 65 Animations  CSS animations make it possible to animate transitions from one CSS style configuration to another.  Animations consist of two components,  a style describing the CSS animation  a set of keyframes that indicate the start and end states of the animation’s style, as well as possible intermediate waypoints.  There are three key advantages to CSS animations over traditional script-driven animation techniques:  They’re easy to use for simple animations; you can create them without even having to know JavaScript.  The animations run well, even under moderate system load. Simple animations can often perform poorly in JavaScript. The rendering engine can use frame-skipping and other techniques to keep the performance as smooth as possible.  Letting the browser control the animation sequence lets the browser optimize performance and efficiency by, for example, reducing the update frequency of animations running in tabs that aren't currently visible.
  • 66. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 66 Configuring the animation  To create a CSS animation sequence, you style the element you want to animate with the animation property or its sub-properties. This lets you configure the timing, duration, and other details of how the animation sequence should progress.  Note: This does not configure the actual appearance of the animation, which is done using the @keyframes  The sub-properties of the animation property are:  animation-name : Specifies the name of the @keyframes at-rule describing the animation’s keyframes.  animation-duration : Configures the length of time that an animation should take to complete one cycle.  animation-timing-function : Configures the timing of the animation; that is, how the animation transitions through keyframes, by establishing acceleration curves. (linear, ease, ease-in, ease-out etc…)  animation-delay : Configures the delay between the time the element is loaded and the beginning of the animation sequence.  animation-iteration-count : Configures the number of times the animation should repeat; you can specify infinite to repeat the animation indefinitely.  animation-direction : Configures whether or not the animation should alternate direction on each run through the sequence or reset to the start point and repeat itself. (normal, reverse, alternate etc…)  animation-fill-mode : Configures what values are applied by the animation before and after it is executing.  animation-play-state : Lets you pause and resume the animation sequence.
  • 67. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 67 Defining the animation sequence using keyframes  Once you’ve configured the animation’s timing, you need to define the appearance of the animation. This is done by establishing two or more keyframes using the @keyframes at-rule.  Each keyframe describes how the animated element should render at a given time during the animation sequence.  Example CSS p { animation-duration: 3s; animation-name: slidein; } @keyframes slidein { from { /* or 0% */ margin-left: 100%; width: 300%; } to { /* or 100% */ margin-left: 0%; width: 100%; } } HTML <p> Hello World </p>
  • 68. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 68 Specifying Intermediate steps CSS p { animation-duration: 4s; animation-name: changeColors; } @keyframes changeColors { 0% {background-color: yellow;} 25% {background-color: blue;} 50% {background-color: green;} 100% {background-color: red;} } HTML <p> Hello World </p>  We can specify intermediate steps using percentage of time in @keyframes, similar to the example given below.
  • 69. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 69 Tooltip  A tooltip is often used to specify extra information about something when the user moves the mouse pointer over an element. CSS .tooltip { position: relative; display: inline-block; border-bottom: 1px dotted black; } HTML <div class="tooltip">Hover here to see tooltip <span class="tooltiptext">Tooltip text</span> </div> CSS .tooltip .tooltiptext { visibility: hidden; width: 120px; background-color: black; color: #fff; text-align: center; border-radius: 6px; padding: 5px 0; position: absolute; z-index: 1; } .tooltip:hover .tooltiptext { visibility: visible; }
  • 70. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 70 Style Images  We can use many properties with Images like,  opacity  border-radius  margin-left, margin-right to be auto and display to be block (to make it aligned center)  max-width to be 100% and height to be auto (to make it responsive)  filter  etc…
  • 71. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 71 CSS Variables / Custom Properties  Custom properties (sometimes referred to as CSS variables or cascading variables) are entities defined by CSS authors that contain specific values to be reused throughout a document.  Advantages of using CSS variables are:  makes the code easier to read (more understandable)  makes it much easier to change.  CSS variables can have a global or local scope.  Global variables can be accessed/used through the entire document.  To create a variable with global scope, declare it inside the :root selector. The :root selector matches the document's root element.  local variables can be used only inside the selector where it is declared.  To create a variable with local scope, declare it inside the selector that is going to use it.  We can use var() function in order to access the variable set in the css.
  • 72. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 72 CSS Variables (Example) HTML <p> Hello World </p> <div> How are you? </div> CSS :root{ --myFavColor : orange; --myNextFacColor : green; } p{ background-color: var(--myFavColor); color: var(--myNextFacColor); } div{ background-color: var(--myNextFacColor); color: var(--myFavColor); }
  • 73. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 73 Media Queries  Media queries are a way to target browser by certain characteristics, features, and user preferences, then apply styles or run other code based on those things.  Perhaps the most common media queries in the world are those that target particular viewport ranges and apply custom styles, which is the whole idea of responsive design.  General syntax for the media queries in CSS is,  It consists of:  A media type, which tells the browser what kind of media this code is for (e.g. print, screen etc…).  A media feature, which is a rule, or test that must be passed for the contained CSS to be applied.  A set of CSS rules that will be applied if the test passes and the media type is correct. Syntax @media [media-type] ([media-feature]) { /* Styles! */ }
  • 74. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 74 Media Query (Cont.)  Media Types:  all  print  screen  speech  Media Features:  width & height  min-width, min-height, max-width & max-height  orientation  The viewport meta tag: <meta name="viewport" content="width=device-width, initial-scale=1.0">  This is needed because by default, most mobile browsers lie about their viewport width.  Non-responsive sites commonly look really bad when rendered in a narrow viewport, so mobile browsers usually render the site with a viewport width wider than the real device width by default (usually 960 pixels), and then shrink the rendered result so that it fits in the display.
  • 75. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 75 Media Query (Example) HTML <div id="div1"> Hello </div> <div id="div2"> World </div> CSS #div1{ background-color: red; width: 50%; float: left; } #div2{ background-color: yellow; width: 50%; float: left; } @media (max-width: 600px){ #div1{ width: 100%; } #div2{ width: 100%; } } Note: you have to add viewport meta tag in the head section <meta name="viewport" content= "width=device-width, initial-scale=1.0">
  • 76. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 76 Media Query (cont.)  We can also use and/or logic in media query, for example  We can use and as a separator if we want two condition to satisfy before applying the CSS.  We can use , (comma) as a separator if we want anyone of the condition to satisfy before applying the CSS. CSS @media screen and (min-width: 600px) and (max-width: 900px) { body { color: blue; } } CSS @media (min-width: 600px), (orientation: landscape) { body { color: blue; } }
  • 77. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 77 Wild Card Selectors  Wildcard selector is used to select multiple elements simultaneously.  It selects similar type of class name or attribute and apply CSS property.  Some of the wild card selector are,  [attribute*=”str”] Selector ( e.g. [class*="str"] )  It will select all the elements with the given attribute containing the str.  [attribute^=”str”] Selector ( e.g. [class^="str"] )  It will select all the elements with the given attribute starts with the str.  [attribute$=”str”] Selector ( e.g. [class$="str"] )  It will select all the elements with the given attribute ends with the str.
  • 78. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 78 Gradients  CSS gradients let you display smooth transitions between two or more specified colors.  CSS defines two types of gradients:  Linear Gradients (goes down/up/left/right/diagonally)  To create a linear gradient you must define at least two color stops.  Color stops are the colors you want to render smooth transitions among.  You can also set a starting point and a direction (or an angle) along with the gradient effect.  Radial Gradients (defined by their center)  The radial-gradient() function sets a radial gradient as the background image.  A radial gradient is defined by its center.  To create a radial gradient you must define at least two color stops.
  • 79. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 79 Linear Gradients  To create a linear gradient you must define at least two color stops.  Color stops are the colors you want to render smooth transitions among.  You can also set a starting point and a direction (or an angle) along with the gradient effect.  direction:  to bottom  to top  to right  to left  to bottom left  180deg  Etc… Syntax background-image: linear-gradient(direction, color-stop1, color-stop2, ...);
  • 80. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 80 Linear Gradients (Example)  Example:  Output: CSS background-image: linear-gradient(red, yellow);
  • 81. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 81 Radial Gradients  To create a linear gradient you must define at least two color stops.  Color stops are the colors you want to render smooth transitions among.  You can also set a starting point and a direction (or an angle) along with the gradient effect.  shape:  Ellipse (defalt)  Circle  size:  farthest-corner (default)  closest-corner  farthest-side  closest-side  position:  Center (default)  Etc… Syntax background-image: radial-gradient(shape size at position, start-color, ..., last-color);
  • 82. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 82 Radial Gradients (Example)  Example:  Output: CSS background-image: radial-gradient(red, green, yellow);
  • 83. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 83 Pseudo Classes  A pseudo-class is used to define a special state of an element.  For example, it can be used to:  Style an element when a user mouse over it  Style visited and unvisited links differently  Style an element when it gets focus  Some important pseudo classes are:  active  disabled  first-child  nth-child()  focus  hover  visited Syntax selector:pseudo-class { property: value; }
  • 84. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 84 Pseudo Elements  A CSS pseudo-element is used to style specified parts of an element.  For example, it can be used to:  Style the first letter, or line, of an element  Insert content before, or after, the content of an element  pseudo elements are,  after  before  first-letter  first-line  selection Syntax selector::pseudo-element { property: value; }
  • 85. Admas A. #3160713 (WP)  Unit 01 –HTML, CSS 85 Bootstrap  Bootstrap is Free front-end framework made of HTML, CSS and JavaScript Plugins (optional) for developing Responsive Websites.  Responsive websites means websites which Automatically Adjust themselves to look good on all devices like mobile, desktop etc…  Why to Use Bootstrap?  Easy to use  Anybody with just basic knowledge of HTML and CSS can start using Bootstrap  Responsive features  It's responsive CSS adjusts to phones, tablets, and desktops  Mobile-first approach  Mobile-first styles are part of the core framework  Browser compatibility  Compatible with all modern browsers (Chrome, Firefox, Internet Explorer, Safari, and Opera)  Free
  • 86. Jimma Institute of Technology, Jimma University Thank You Admas.abtew@ju.edu.et 0912499102 Faculty of Computing and Informatics Internet Programming (IP)