Unit - 2 - Hypertext Markup Language & Cascading Style Sheets
DhavalChandarana
672 views
127 slides
Aug 22, 2024
Slide 1 of 127
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
About This Presentation
HTML: HTML page structure, Basic HTML tags like heading, formatting tags paragraph, formatting text, organizing text, list, anchor, images, HTML tables, HTML forms, meta tags, multimedia tags, links, frames, HTML5 tags in relation to validations.
CSS: Introduction to CSS, Basic Syntax and structure ...
HTML: HTML page structure, Basic HTML tags like heading, formatting tags paragraph, formatting text, organizing text, list, anchor, images, HTML tables, HTML forms, meta tags, multimedia tags, links, frames, HTML5 tags in relation to validations.
CSS: Introduction to CSS, Basic Syntax and structure of CSS, Need for CSS, Types of CSS, Background Properties, manipulating text and font, The Box Model, styling list, CSS Positioning, Colors and properties, borders and boxes, Margins, Padding Lists, CSS2, CSS3, Animations, Tool-Tips, Style images, Variables, Flex Box, Media Queries, Working with Gradients.
Size: 10.11 MB
Language: en
Added: Aug 22, 2024
Slides: 127 pages
Slide Content
Web Development
UNIT - 2
HTML & CSS
Outline...
>HTML
+ HTML page structure
+ Formatting tags in HTML
* Tables
* Links
+ Images
+ Meta tags
* Frames
* Html form tags
» Media
+ HTMLS tag in relation to validations
Outline...
>CSS
* Need for CSS
* Basic syntax and structure
+ Backgrounds
* Colors and properties
+ Manipulating texts, Fonts
+ Borders and boxes
+ Margins, Padding Lists
*CS52, CSS3
* Animations
+ Tool-Tips
Outline...
>CSS
* Style images
+ Variables
* Flex Box
+ Media Queries
* Wildcard Selectors (*, * and $) in CSS
* Working with Gradients
* Pseudo Class, Pseudo elements
* CSS variables
HTML page structure
+ HTML is the standard markup language for creating Web pages.
* What is HTML?
+ HTML stands for Hyper Text Markup Language
* HTMLis the standard markup language for creating Web pages
+ HTML describes the structure of a Web page
+ HTML consists of a series of elements
+ HTML elements tell the browser how to display the content
+ HTML elements label pieces of content such as "this is a heading", "this is
a paragraph", "this is a link", etc.
HTML page structure
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
HTML page structure
* The <!DOCTYPE html> declaration defines that this document is an
HTMLS document
* The <html> element is the root element of an HTML page
* The <head> element contains meta information about the HTML page
* The <title> element specifies a title for the HTML page (which is
shown in the browser's title bar or in the page's tab)
* The <body> element defines the document's body, and is a container
for all the visible contents, such as headings, paragraphs, images,
hyperlinks, tables, lists, etc.
* The <h1> element defines a large heading
* The <p1> element defines a paragraph
HTML page structure
+ What is an HTML Element?
+ An HTML element is defined by a start tag, some content, and an end
tag:
<tagname> Content goes here... </tagname>
* The HTML element is everything from the start tag to the end tag:
+ Some HTML elements have no content (like the <br> element). These
elements are called empty elements. Empty elements do not have an
end tag!
Line two contains this text </font>
<font color="#FF9933" size="6" face="Courier“>
The third line has this additional text </font>
List
* HTML offers web authors three ways for specifying lists of
information. All lists must contain one or more list elements.
* <ul> - An unordered list. This will list items using plain bullets.
+ <ol> - An ordered list. This will use different schemes of numbers to
list your items.
+ <dl> - A definition list. This arranges your items in the same way as
they are arranged in a dictionary.
Unordered Lists
* An unordered list is a collection of related items that have no special order
or sequence. This list is created by using HTML <ul> tag. Each item in the
list is marked with a bullet.
<ul>
Types:
<li> One </li> yp
<li> Two </li>
Type = disc (default)
<ul type="circle"> Type = circle
<li> Three </li> Type = square
<li> Four </li>
<ultype="square"> Output
<li> Five </li> | Fone 7
<li> Six </li> lia |
</ul> | ae Five |
|
= Six
</ul>
¡Pr A
</ul>
Ordered List
* If you are required to put your items in a numbered list instead of bulleted,
then HTML ordered list will be used. This list is created by using <ol> tag.
The numbering starts at one and is incremented by one for each successive
ordered list element tagged with <li>.
<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 =!
Type =i
Output
1. Item one |
| "ae
L Sublist item one |
| IL Sublist item two
i. Sub-sub list item one |
LL i. Sub-sub list tem two y
Definition Lists
+ HTML and XHTML supports a list style which is called definition lists
where entries are listed like in a dictionary or encyclopedia. The
definition list is the ideal way to present a glossary, list of terms, or
other name/value list.
* Definition List makes use of following three tags.
* <dl> - Defines the start of the list
+ <dt> — A term
+ <dd> - Term definition
+ </dl> - Defines the end of the list
Definition Lists
<!DOCTYPE html>
<html>
<head>
HM,
“This sands for Hyper Tex Mashup Language
rTP
<title>HTML Definition List</title> |,
Shea “This wand foc Hyper Test Transfer Protocol
<body>
<dl>
<dt><b>HTML</b></dt>
<dd>This stands for Hyper Text Markup Language</dd>
<dt><b>HTTP</b></dt>
<dd>This stands for Hyper Text Transfer Protocol</dd>
</dl>
</body>
</html>
Tables
* The HTML tables allow web authors to arrange data like text, images,
links, other tables, etc. into rows and columns of cells.
* The HTML tables are created using the <table> tag in which the <tr>
tag is used to create table rows and <td> tag is used to create data
cells.
* The elements under <td> are regular and left aligned by default.
* Table Heading
* Table heading can be defined using <th> tag. This tag will be put to
replace <td> tag, which is used to represent actual data cell.
+ Headings, which are defined in <th> tag are centered and bold by
default.
Tables
* Cellpadding and Cellspacing Attributes
* There are two attributes called cellpadding and cellspacing which you
will use to adjust the white space in your table cells.
* The cellspacing attribute defines space between table cells, while
cellpadding represents the distance between cell borders and the
content within a cell.
* Colspan and Rowspan Attributes
+ You will use colspan attribute if you want to merge two or more
columns into a single column.
« Similar way you will use rowspan if you want to merge two or more
rows.
Tables
* Tables Backgrounds
* bgcolor attribute - You can set background color for whole table or
just for one cell.
* background attribute - You can set background image for whole table
or just for one cell.
* bordercolor attribute - You can also set border color.
* Table Height and Width
*You can set a table width and height using width and height
attributes.
* You can specify table width or height in terms of pixels or in terms of
percentage of available screen area.
Tables
* Table Caption
* The caption tag will serve as a title or explanation for the table and it
shows up at the top of the table.
* Table Header, Body, and Footer
* Tables can be divided into three portions - a header, a body, and a
foot.
+ <thead> - to create a separate table header.
* <tbody> - to indicate the main body of the table.
* <tfoot> - to create a separate table footer.
» A table may contain several <tbody> elements to indicate different
pages or groups of data. But it is notable that <thead> and <tfoot>
tags should appear before <tbody>
Tables
+ Valid for the table row:
+ align -- left, center, right
+ valign -- top, middle, bottom
* A webpage can contain various links that take you directly to other
pages and even specific parts of a given page. These links are known
as hyperlinks.
* Hyperlinks allow visitors to navigate between Web sites by clicking on
words, phrases, and images.
« A link is specified using HTML tag <a>. This tag is called anchor
tag and anything between the opening <a> tag and the closing </a>
tag becomes part of the link and a user can click that part to reach to
the linked document.
* When you move the mouse over a link, the mouse arrow will turn
into a little hand.
* A webpage can contain various links that take you directly to other
pages and even specific parts of a given page. These links are known
as hyperlinks.
* Hyperlinks allow visitors to navigate between Web sites by clicking on
words, phrases, and images.
« A link is specified using HTML tag <a>. This tag is called anchor
tag and anything between the opening <a> tag and the closing </a>
tag becomes part of the link and a user can click that part to reach to
the linked document.
* When you move the mouse over a link, the mouse arrow will turn
into a little hand.
+ Images are very important to beautify as well as to depict many
complex concepts in simple way on your web page.
* Insert Image
* You can insert any image in your web page by using <img> tag.
<img src = "Image URL" alt=" " ... attributes-list/>
* The <img> tag is an empty tag, which means that, it can contain only
list of attributes and it has no closing tag.
* You can use PNG, JPEG or GIF image file based on your comfort but
make sure you specify correct image file name in src attribute. Image
name is always case sensitive.
+ The alt attribute is a mandatory attribute which specifies an alternate
text for an image, if the image cannot be displayed.
Images
* Set Image Width/Height
+ You can set image width and height based on your requirement
using width and height attributes.
* You can specify width and height of the image in terms of either pixels
or percentage of its actual size.
<img src = "test.png" alt = "Test Image" width = "150" height = "100"/>
* Set Image Border
* By default, image will have a border around it, you can specify border
thickness in terms of pixels using border attribute. A thickness of O
means, no border around the picture.
+ The META elements can be used to include name/value pairs
describing properties of the HTML document, such as author, expiry
date, a list of keywords, document author etc.
* The <meta> tag is used to provide such additional information. This
tag is an empty element and so does not have a closing tag but it
carries information within its attributes.
* You can include one or more meta tags in your document based on
what information you want to keep in your document but in general,
meta tags do not impact physical appearance of the document so
from appearance point of view, it does not matter if you include them
or not.
Meta Tags
* Specifying Keywords
* You can use <meta> tag to specify important keywords related to the
document and later these keywords are used by the search engines
while indexing your webpage for searching purpose.
<meta name = "keywords" content = "HTML, Meta Tags, Metadata" />
* Document Description
» You can use <meta> tag to give a short description about the
document. This again can be used by various search engines while
indexing your webpage for searching purpose.
<meta name = "description" content = "Learning about Meta Tags." />
Meta Tags
* Document Revision Date
* You can use <meta> tag to give information about when last time the
document was updated. This information can be used by various web
browsers while refreshing your webpage.
+ A <meta> tag can be used to specify a duration after which your web
page will keep refreshing automatically.
<meta http-equiv = "refresh" content = "5" />
Meta Tags
* Page Redirection
* You can use <meta> tag to redirect your page to any other webpage.
You can also specify a duration if you want to redirect the page after a
certain number of seconds.
* Cookies are data, stored in small text files on your computer and it is
exchanged between web browser and web server to keep track of
various information based on your web application need.
* You can use <meta> tag to store cookies on client side and later this
information can be used by the Web Server to track a site visitor.
* Setting Author Name
* You can set an author name in a web page using meta tag.
<meta name = "author" content = “abc" />
* Specify Character Set
+ You can use <meta> tag to specify character set used within the
webpage.
« By default, Web servers and Web browsers use ISO-8859-1 (Latin1)
encoding to process Web pages. Following is an example to set UTF-8
encoding -
* HTML frames are used to divide your browser window into multiple
sections where each section can load a separate HTML document.
* A collection of frames in the browser window is known as a frameset.
The window is divided into frames in a similar way the tables are
organized: into rows and columns.
* To use frames on a page we use <frameset> tag instead of <body>
tag. The <frameset> tag defines, how to divide the window into
frames.
* The rows attribute of <frameset> tag defines horizontal frames and
cols attribute defines vertical frames.
<noframes>
<body>Your browser does not support frames.</body>
</noframes>
</frameset>
</html>
Frames
* border This attribute specifies the width of the border of each frame
in pixels. For example, border = "5". A value of zero means no border.
* frameborder This attribute specifies whether a three-dimensional
border should be displayed between frames. This attribute takes
value either 1 (yes) or O (no). For example frameborder = "0" specifies
no border.
* framespacing This attribute specifies the amount of space between
frames in a frameset. This can take any integer value. For example
framespacing = "10" means there should be 10 pixels spacing
between each frames.
Frames
* src This attribute is used to give the file name that should be loaded
in the frame. Its value can be any URL. For example, src =
"/html/top_frame.htm" will load an HTML file available in html
directory.
* name This attribute allows you to give a name to a frame. It is used to
indicate which frame a document should be loaded into.
* frameborder This attribute specifies whether or not the borders of
that frame are shown; it overrides the value given in the frameborder
attribute on the <frameset> tag if one is given, and this can take
values either 1 (yes) or 0 (no).
* marginwidth This attribute allows you to specify the width of the
space between the left and right of the frame's borders and the
frame's content. The value is given in pixels. For example marginwidth
= "19"
Frames
» marginheight This attribute allows you to specify the height of the
space between the top and bottom of the frame's borders and its
contents. The value is given in pixels. For example marginheight =
"10",
noresize By default, you can resize any frame by clicking and dragging
on the borders of a frame. The noresize attribute prevents a user
from being able to resize the frame. For example noresize =
"noresize".
scrolling This attribute controls the appearance of the scrollbars that
on
appear on the frame. This takes values either "yes", "no" or "auto".
For example scrolling = "no" means it should not have scroll bars.
* longdesc This attribute allows you to provide a link to another page
containing a long description of the contents of the frame. For
example longdesc = "framedescription.htm"
Form
* The HTML <form> tag is used for creating a form for user input. A
form can contain textfields, checkboxes, radio-buttons and more.
Forms are used to pass user-data to a specified URL.
Value
accept MIME_type Specifies a comma-separated list of content types that the server accepts.
accept-charset charset list Specifies a list of character encodings that the server accepts. The default
value is "unknown".
action URL Specifies a URI/URL of the back-end script that will process the form
autocomplete on/off Specifies whether form should have autocomplete on or off
enctype mimetypes The mime type used to encode the content of the form.
method get/post/request Specifies the HTTP method to use when the form is submitted.
name form name Defines a unique name for the form.
target _blank/_self Target to open the given URL.
_parent/_top
HTML input Tag
* In HTML, the input field can be specified using where a user can enter
data. The input tag is used within <form> element to declare input
controls that allow users to input data.
+ An input field can be of various types depending upon the attribute
type. The Input tag is an empty element which only contains
attributes.
+ Text field
+ Example: <input type=“text” name=“inputname”/> éhaval ]
+ Example:
<input type="checkbox" name="Roll1"> Roll No 1 <br/> ee
<input type="checkbox" name="Roll2"> Roll No 2 <br/> Roll No2
Roll No 3
<input type="checkbox" name="Roll3"> Roll No 3 <br/>
HTML input Tag
* Dropdown list
+ <select> tag is used to create a drop-down list in HTML.
* <option> tags inside the <select> tag define the available options in the list.
+ Example:
<select>
<option value=“1”>Rajkot</option> ES
<option value="2">Ahemdabad</option> Ahemdabad
Qn, gi Surat
<option value="3">Surat</option>
</select>
* Text area
7 AT GMIT Institute of -
+ <textarea> tag defines a multi-line text Engineering & Technology is a
A leading institute offering
input control. lundergraduate, graduate and
|postgraduate programs in
+ Example: engineering. GMIT is
ah a Located in peaceful and E
<textarea rows="8” cols="30”> sylvan surroundings, about 19 /
GMIT Institute of Engineering & Technology is a leading institute ....
</textarea>
+ Submit Button
* Submit button is used to submit the data
to the form action url.
Add City
+ Example:
<input type=“submit” value=“Add City”>
Media
+ HTMLS introduced 5 most popular media element tags i.e. <audio>,
<video>, <source>, <embed>, <track>. This media element tags changed
the entire development using HTML.
* An input field can be of various types depending upon the attribute type.
The Input tag is an empty element which only contains attributes.
* <audio>: It is an inline element that is used to embed sound files into a
web page.
+ <video>: It is used to embed video files into a web page.
+ <source>: It is used to attach multimedia files like audio, video, and
pictures.
+ <embed>: It is used for embedding external applications which are
generally multimedia content like audio or video into an HTML document.
+ <track>: It specifies text tracks for media components audio and video.
HTMLS - Input Validation
* HTML input validation is done automatically by the browser based on
special attributes on the input element. It could partially or
completely replace JavaScript input validation.
* The validation only occurs when attempting to submit the form, so all
restricted inputs must be inside a form in order for validation to
occur.
* Required
+ Use the required attribute to indicate that a field must be completed
in order to pass validation.
<input required>
HTMLS - Input Validation
* Minimum / Maximum Length
+ Use the minimum and maximum Length attributes to indicate length
requirements. Most browsers will prevent the user from typing more
than max characters into the box, preventing them from making their
entry invalid even before they attempt submission.
<input minlength="3" maxlength="15">
* Accept File Type
* For input fields of type file it is possible to accept only certain types of
files, such as videos, images, audios, specific file extensions, or certain
media types.
* For more control, use the pattern attribute to specify any regular
expression that must be matched in order to pass validation. You can
also specify a title which is included in the validation message if the
field doesn't pass.
EB Please match the format
requested.
Numbers only, please
HTMLS - SEO
* A semantic element clearly describe its meaning to both the browser
and the developer. Various elements that HTML5 offers are
represented by following figure.
Html Structure HtmI5 Structure
div id = “header” header
E” Es
= Me)
HTML5 — Header
+ The <header> tag in HTML is used to define the header for a
document or a section as it contains the information related to the
title and heading of the related content.
* There can be several <header> elements in one document. This tag
cannot be placed within a <footer>, <address> or another <header>
element.
* The <footer> tag in HTML is used to define a footer of HTML
document. This section contains the footer information (author
information, copyright information, carriers, etc).
* The footer tag is used within the body tag.
<!DOCTYPE html>
<html>
<body>
<footer>
<p>Some rights reserved</p>
</footer>
</body>
</html>
HTML5 — Heading Groups
+ The <hgroup> tag defines the heading of an HTML document. It is used to
group the <h1>-<h6> headings.
* Sometimes multiple headers need to be specified. For that purpose the
heading groups can be used.
+ article - This tag represents an independent piece of content of a document, such
as a blog entry or newspaper article.
+ section - This tag represents a generic document or application section. It can be
used together with h1-h6 to indicate the document structure.
<!DOCTYPE htm!>
<html>
<head>
<title>...</title>
</head>
<body>
<article>
<section>
<p>Once article can have multiple sections</p>
</section>
</article>
</body>
</html>
HTMLS - Figure and Figures Caption
* The <figure> element can be used to group the image and figure caption.
The figure caption gives the information about the image.
* The <aside> element can be used to identify content that is related to the
primary content of the webpage, but does not constitute the primary
content of the page.
<!DOCTYPE html>
<html>
<head>
<title>...</title>
</head>
<body>
<aside>
<h1>This is heading text in aside Tag</h1>
<p>This is paragraph text in aside Tag</p>
</aside>
</body>
</html>
Introduction of CSS
* CSS is used to control the style of a web document in a simple and
easy way.
* CSS is the acronym for "Cascading Style Sheet". This tutorial covers
both the versions CSS1,CSS2 and CSS3, and gives a complete
understanding of CSS, starting from its basics to advanced concepts.
* Why to Learn 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 is a MUST for students and working professionals to become a
great Software Engineer specially when they are working in Web
Development Domain.
Introduction of CSS
* Create Stunning Web site - CSS handles the look and feel part of a
web page. Using CSS, you can control the color of the text, the style of
fonts, the spacing between paragraphs, how columns are sized and
laid out, what background images or colors are used, layout designs,
variations in display for different devices and screen sizes as well as a
variety of other effects.
* Become a web designer - If you want to start a carrer as a
professional web designer, HTML and CSS designing is a must skill.
+ Control web - CSS is easy to learn and understand but it provides
powerful control over the presentation of an HTML document. Most
commonly, CSS is combined with the markup languages HTML or
XHTML.
Introduction 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
Basic Syntax of CSS
+A CSS rule has two main parts: a selector, and one or more
declarations
<p> Hello Friends </p>
<p id="para1”> How are you? </p>
</body>
</html>
Hello Friends
Output
How are you?
External Style Sheet
* 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.
CSS - Simple selector
* The simple selector form is a single element to which the property
and value is applied.
* We can also apply property and value to group of elements.
HTML css
<h1> h1,h2{
Hello Friends color: red;
</h1> }
<h2> Output
How are you Hello Friends
</h2> How are you
CSS - “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
an
in css.
HTML css
<h1 class="myClass”> h1. myclass{
Hello Friends color: red;
</h1> }
<h1>
How are you
</h1> Y Output
<h1 class="myClass”> Hello Friends
How are you How are you
</h1> How are you
CSS - “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 css
<h1 id="para1”> #paral{
Hello Friends color: red;
</h1> }
<h1> Output
How are you Hello Friends
</h1> How are you
CSS - “Universal” selector
* This selector is denoted by * (asterisk).
* This selector can be applied to all the elements in the document.
* The style rule below will be applied to the element with id=“para1”.
HTML css
<h1> et
Hello Friends color: red;
</h1> }
<h2> Output
Höwiare you Hello Friends
</h2> How are you
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>
* The background-position property sets the starting position of a
background image.
« Example
test.css
body
{ : si
background-image : url(‘pathTolmage.jpg’); : S
background-repeat : no-repeat; : a
background-position: 20px 10px; 8
background-position: 30%30%;
background-position: top center;
Font Property
* CSS font properties define the font family, boldness, size, and the
style of a text.
Property Name
* Font Color (color)
* Font Family (font-family)
* Font Size (font-size)
* Font Style (font-style)
+ Font Weight (font-weight)
* Font Variant (font-variant)
Font Property
* 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;
nat
color : red;
}
hat
font-family : sans-serif:
}
nat
* 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.
hat
font-style: italic ;
}
hat
font-weight : 300;
font-weight : bolder;
font-weight : lighter;
}
hat
font-variant: small-caps;
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.
Property Name
* Text Decoration (text-decoration)
* Text Indent (text-indent)
+ Text Align (text-align)
* Text Transform (text-transform)
* White Space (white-space)
* Word Spacing (word-spacing)
* Letter Spacing (letter-spacing)
* Line Height (line-height)
Text Property
* 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.
* 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.
hat
text-transform : capitalize;
text-transform : uppercase;
text-transform : lowercase;
hat
white-space : nowrap;
white-space: pre;
}
hat
word-spacing : 10px;
Text Property
* 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.
hat
letter-spacing : 3px;
hat
line-height : 10px;
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.
The Box Model
* The image below illustrates the box model:
Margin
Padding
Content
The Box Model
margin-left
padding-left
margin-top
padding-top
padding-bottom
margin-bottom
au8u-Buipped
qysu-ulBew
Border Property
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.
hat
between the element border and the element ' padding : 10px;
content.
+ The top, right, bottom, and left padding hat
can be changed independently using separate padding-top : 10px;
| padding-right : 20px;
properties.
padding-bottom : 30 px;
+ Ashorthand padding property can also be used padding-left : 40 px;
to change all padding at once.
hat
padding : 10px 20px 30px 40px;
Margin Property
* The CSS margin properties define the space hat
around elements. i margin’: 10px;
+ The top, right, bottom, and left margin
can be changed independently using separate
hat
properties. lc 100%
+ Ashorthand margin property can also be used margin-bottom : 30 px;
to change all padding at once. ; margin-left : 40 px;
hat
margin : 10px 20px 30px 40px;
List Property
The CSS list properties allow you to:
+ Set different list item markers for
ordered & unordered lists.
* Set an image as the list item marker.
* Set the position of the marker.
. it a aclinkf
The four links states are: SH O0:
1. a:link - a normal, unvisited link /*unvisited link*/
2. a:visited - a link the user has visited po
3. a:hover - a link when the user mouse over it | *“#itedl a
text-decoration : none;
4. a:active - a link the moment it is clicked /*visited link*/
}
a:hover{
color:#00FF00;
/*mouse over link*/
}
azactive(
color:#OODOFF;
selected link*/
Positioning Property
+ Absolute Positioning
* With absolute positioning, you define the hat .
exact pixel value where the specified HTML position :jabsolute;
element will appear. left : SOpx;
top : 100px;
* The point of origin is the top-left of the } SP TOP
browser's viewable area, so be sure you are
measuring from that point.
+ Relative Positioning bat 7 .
E pa = position : relative;
* Relative positioning changes the position of left : 50px;
the HTML element relative to where it top : 100px;
normally appears. }
+ Fixed Positioning hit
* The element is positioned relative to the position : fixed;
browser window, in fixed position, element top : SOpx;
will be in the same place even we scroll the left : 100px;
screen. }
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.
* Cascading e Sheet Level 2 (CSS2) is the second version of cascading
style sheets
eveloped by W3C.
+ It's a declarative language used to enhance the hyper-extensive text
markup language.
* CSS2 is a subset of Cascading Style Sheet Level 1 and has enhanced
capabilities like:
1
2,
3.
4.
5:
6.
d
8.
9,
1
o.
Media types concept
Aural style sheets
Features for internationalization
Extended font selection
Automatic numbering and generated content
Cursor
Dynamic outline
Capabilities to control content overflow, clipping
Absolute, fixed and relative positioning
Extended selectors mechanism
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.
CSS2 v/s CSS3
Many features of CSS2 are not compatible CSS3 provide backward compatibility with
with CSS3 CSS2°
Media queries are not supported in CSS2 CSS3 supports Media queries for responsive
designs.
Not all the browser can support CSS2 code Allthe modern browser support CSS3.
CSS2 node can not be split into various CSS3 code can be split into various modules.
modules
CSS2 supports standard old colors (RGB) CSS3 supports RGB, HSL and gradient colors.
only.
In CSS2 animation is possible vis JQuery and In CSS3 animation is supported by
Javascript translation, scaling, rotation and
transformation.
CSS3
* Some of the most important CSS3 modules are:
CSS Animations and Transitions
Advanced Selectors
Generated Content and Counters
Gradients
Webfonts
Box Sizing
Style Images
Media Queries
Multiple Backgrounds
CSS Columns
Pseudo Class , Pseudo elements
Flex Box
Animations
* CSS allows animation of HTML elements without using JavaScript or
i. row (default): left to right in Itr; right to left in rtl
li.row-reverse: right to left in Itr; left to right in rtl
iii.column: same as row but top to bottom
iv.column-reverse: same as row-reverse but bottom to top
* Media queries allow you to customize the presentation of your web
pages for a specific range of device like mobile phone, tablets,
desktop etc. without any change in markup.
1. Height and width of devices
2. Height and width of viewports
3. Mode of operation (landscape or portrait mode)
4. Resolution
+ Syntax:
@media not|only mediatype and (expression) {
CSS — code;
Media Queries
* The result of the query is true if the specified media type matches the
type of device the document is being display on and all expression in
the media query are true.
+ When a media query is true, the corresponding style sheet or style
rules are applied.
Value Description
all Used for all media type devices
print Used for printers
screen Used for computer screens, tablets, smart-phones etc.
speech Used for screenreaders that "reads" the page out loud
Media Queries - Examples
* The following example changes the background-color to lightgreen if the
viewport is 480 pixels wide or wider (if the viewport is less than 480 pixels,
the background-color will be pink):
@media screen and (min-width: 480px ) {
body {
background-color: lightgreen; }
+ The following example shows a menu that will float to the left of the page
if the viewport is 480 pixels wide or wider (if the viewport is less than 480
pixels, the menu will be on top of the content):
* The wild card selector are represented by various symbols such as *,4 or $.
* These selector are used to select multiple elements simultaneously for
applying styles.
1. The attribute * selector : The [attribute*="val”] selector is used to select
the elements whose attribute value contains the string “val”.
2. The attribute * selector : The [attribute*=“val”] selector is used to select
the elements whose attribute value begin with a specific value val.
3. The attribute $ selector : The [attributeS=“val”] selector is used to select
the elements whose attribute value end with a specific value val.
* By the CSS3 gradient effect allows the developer to display the
transition between two or more colors.
* There are two way by the gradient effect can be specified in CSS3
1. Linear Gradients (goes down/up/left/right/diagonally)
2. Radial Gradients (defined by their center)
- To create a linear gradient you must define at least two color stops.
* You can also set a starting point and a direction (or an angle) along
with the gradient effect.
* Using the pseudo classes we can give special effects on the selectors.
There some pseudo classes which are more commonly used and
other are -
* Focus (Style an element when it gets focus)
+ Hover (Style an element when a user mouses over it)
* Hyperlink (Style visited and unvisited links differently)
* A CSS pseudo-element is a keyword added to a selector that lets you
style a specific part of the selected element. For example, ::first-line
can be change the font of the first line of a paragraph.
+ Syntax :
Selector :: pseudo-element
{
property: value;
}
Pseudo-elements - Example
* The following example formats the first line of the text in all <p>
elements:
p::first-line
{
color: #ff0000;
font-variant: small-caps;
}
* Pseudo-elements can be combined with CSS classes:
p.Intro :: first-letter
1
color: #ff0000;
font-size: 200%;
}
Pseudo-elements - Example
* The ::before pseudo-element can be used to insert some content
before the content of an element.
* The following example inserts an image before the content of each
<h1> element:
h1 :: before
{ @ This is a heading
content: url(smiley.gif);
}
Pseudo-elements
* All CSS Pseudo Elements
Selector | Example Example description
Insert something after the content of each <p>
after p::after Aka
Insert something before the content of each <p>
before p::before element
ufirst-letter p:first-letter Selects the first letter of each <p> element
ufirst-line p::first-line Selects the first line of each <p> element
Selects the portion of an element that is selected
29 i ::selection
selection p: by a user
Media Queries
* Another key component of responsive web design is media queries. Media
ueries is for different style rules for different size device such as mobile,
lesktop and so on.
* It uses the @media rule to include a block of CSS properties only if a
certain condition is true.
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
background-color: lightgreen;
}
@media only screen and (min-width: 481px) and (max-width: 768px)