SlideShare a Scribd company logo
Introduction to Web
Technologies
Lecture 2
Julie Iskander,
MSc. Communication and Electronics
HTML Forms
Forms
 Used to send data back to the server to be processed.

 <form></form>
 Contains:
 control elements that get data from the user
 label elements
 Attributes:

 action  url of page where data is sent
 method  GET/POST http request method
Controls
 Controls must have name and value attributes to be
submitted.
 Controls can be disabled using disabled attribute.

 Each control has an initial value and a current value.
 Initial values are set by value attribute.
 Current value when first rendered is set to initial
value.
Control Types
 Buttons:
 To submit form:
 <input type=“submit” />, <button
type=“submit”></button>

 To reset form:
 <input type=“reset” />, <button type=“reset”></button>

 Just a button with no default behavior
 <input type=“button” />
 <button type=“button”></button>

 Offers richer rendering capabilities then <input
type=“text” />
Control Types
 Checkboxes:





On/off switches.
Must have name to be submitted .
if no value is set, off is the value
Checked attribute is set to make initial value
“on”
 <input type=“checkbox”/>
Control Types
 TextBox:
 Single line text input
 <input type=“text”/>

 Password:
 Similar to TextBox, but input text is rendered as
a series of asterisks or similar characters
 But submitted as plain clear text
 <input type=“password” />
Control Types
 Radiobuttons:
 On/off switches but are mutually exclusive.
 More than one share the same name to create a
mutually exclusive group.
 Checked attribute is set to make initial value
“on” only one of the group at a time.
 <input type=“radio”/>
Control Types
 DropDown Lists/Menus:
 To choose one/more from multiple options.
 Uses
 <select name=“……”></select>

 To select multiple options use multiple attribute
 <select name=“……” multiple></select>

 To define items use
 <option></option>

 Option can have name, value and selected
attributes
Control Types
Control Types
 DropDown Lists/Menus:
 To logically group options use optgroup
 <optgroup label=“…..”></optgroup>

 label attribute is the value that appears in the list.
Control Types
Control Types
 File select:
 Allow users to select files to be submitted to a
form.
 <input type=“file” />
Control Types
 Hidden controls:
 Not rendered visually.
 Values are submitted with the other form data,
can help overcome stateless nature of HTTP.
 <input type=“hidden”
name=“….” value=“….” />
Control Types
 Textarea controls:
 Multiline text input.
 Value is the content nested in the control.
 <textarea>Content </textarea>

 Has rows and cols attributes to set size of textarea.
label
 Specify a label for controls that don‟t have an
implicit label.
 for attribute MUST match ID value of the control
attached to it.
 Useful for speech synthesizers readers,
 <label for=“fname”>First Name :</label>
 <input type=“text” id=“fname”/>
Structuring form
 Use <fieldset> and <legend> to group related
controls and labels.
 Makes forms more accessible especially when
rendered visually.
Example
Example
Cascade Style Sheets
(CSS)
Cascade Style Sheets (CSS)
 “A language for describing the rendering of structured
document as HTML and XHTML” from w3.org
 Provides formatting and layout of html documents.
 Controls presentation, assign styling information to elements.

 Not a markup language
 “cascade”  means multiple stylesheets can be blended
together to affect a page. If conflict occurs the last applied or
the most specific rule is applied.
CSS Rules Syntax
Selector
{
property1: value1;
property2: value2;
property3: value3;

}

Example
body
{

}
p
{
}

background-color:blue;
color:white;
font-size:24pt;

color:yellow;
Where to add CSS?
 Inline style attribute

 Applied to a single element
<p style=“color : pink ; font-size : 30pt ;”

 In <head>

 Applied to an entire single page
<head>
<style>
body{
font-family : arial ;
background-color : black ;
color : white ;
}
p { color : pink ; }
</style>
</head>
Where to add CSS?
• In external sheet (.css)
•

Applied to any html file linked to it

page.html

style.css

<head>
……………………..
<link rel=“stylesheet”
type=“text/css” href=“style.css” />
</head>
url to css file

(no markup only css rules)
body{
font-family : arial ;
background-color : black
color : white ;
}
p { color : pink ; }
CSS Selectors
 Types of Selectors:
 Simple Selectors
 type, class, ID, attribute, pseudo-class
 Group Selectors
 coma-separated list of selectors
Type Selector
 Select by name of element (h1, p, div, span, …..etc.
 Example:
p
{
font-size:20pt;

}
Attribute Selector
 Select an element by the attributes defined in it.

 Example:
[href] /*select any element with attribute named href*/
{
font-size : 20pt ;
}
h1[title] /*select any h1 element with title attribute defined */
{
color : red ; }
a[href=“http://www.google.com”]
/*select any a element with href exactly equal
http://www.google.com */
{
color : blue ; }
Class Selector
 Select an element by the class attributes defined in it.

 Class is an attribute of most html elements, specifies one or
more class names (space-separated list)
 Example:
.maincontent /*select any element with class=“maincontent” */
{
font-size : 20pt;
}
H1.headerTitle /*select the all h1 with class=“headerTitle” */
{
color : red; }
ID Selector
 Select an element by the ID attributes defined in it.

 ID is an attribute of all html elements, it must be unique
throughout a certain html page
 Example:
#maincontent /*select the element with id=“maincontent” */
{
font-size : 20pt;
}
h1#headerTitle /*select the only h1 with id=“headerTitle” */
{
color : red; }
PseudoClass Selector
 Selection based on special effects, Identified by „:‟

 Link:
 :link, :visited, :target

 User actions:
 :hover, :active, :focus

 UI elements states:
 :enabled, :disabled, :checked

 Structural :
 :first-child, :last-child, :nth-child(), :empty, :not()
PseudoClass Selector
(Cont‟d)
 Example:
a:hover /*applied when mouse hover over any link */
{
font-size:20pt; }
a.red:hover /*applied when mouse hover over link with
class=“red” */
{
font-size:20pt; }
Input[type=“text”]:disabled /*applied to any textbox which is
disabled */
{
color:red; }
PseudoElement Selector
 Selection based on parts of elements, Identified by „::‟





::first-letter
::before
::after
::first-line

 Examples:
p::after
{
content:”this content is added after the p”
color:red;
}
Combinators
 Combine selectors specified by relation between elements





Descendant
Direct Childof (>)
Adjacent Sibling (+)
General Sibling(~)

 Examples:
h1 em {……..} /*em descendant of h1*/
div ol > li p{…….} /*p descendant of li which is a direct child
of ol which is a descandent of div*/
span+p{……..} /*p that is a direct adjacent sibling to a span*/
a~p{………} /*p that is sibling of a it may be adjacent or not*/
Example
body{
background-color : black;
color : green ;
}
[href] {
color:pink; }
a[name="next”]{
text-decoration: underline;
}
p.boldp{ font-weight: bold; }
p#pid::first-letter{
font-size: 30px;
}
p::before {
content: "Red text before p”;
color:red;
}
p::after{
content: "Yellow text after p”;
color:yellow;
}

<body>

Trying Style Sheets
<p>This is a paragraph tag <span>a span
nested</span> in it</p>
<p class="boldp">A new paragraph with
more text to be shown describing</p>

<a href="#next">NEXT</a>
<br><br><br>
<a name="next">Here is NEXT</a>
&nbsp;&nbsp;
<p id="pid">Next is more data to
continue desribing the text</p>
</body>
Example
Colors
 Colors can be set using:





Keywords
#-hexadecimal
rgb() and rgba()
hsl() and hsla()

 To get full list of color keywords:
https://developer.mozilla.org/enUS/docs/CSS/color_value
Units in css
 pixel (px) absolute value
 em: ratio of context size
 percentage: percentage of context size
CSS Text Formatting
color : name|#hex|rgb()|rgba()|hsl()|hsla(); /*foreground
color*/

letter-spacing : normal|length (px,%,em);
line-height: normal|number|length|percentage;
text-align: left|right|center|justify;
text-decoration: none|underline|overline|line-through|blink;
text-indent: length|percentage;
text-transform: capitalize|uppercase|lowercase|none;

*text-shadow: rightpx bottompx blurpx color;
direction: ltr | rtl;
*word-wrap: normal|break-word;
CSS Font
font-family: list of font-names to chose from in order if not
supported by browser
font-size: smaller|larger|xx-small|x-small|small|medium|
larger|x-large|xx-large|length|percentage;
font-weight: normal|bold|bolder|lighter|100-900|
font-style: normal|italic|oblique
font-variant: normal|small-caps
font: font-family font-size font-weight font-style font-variant;
Background formatting
 background-attachment : scroll | fixed;

 background-color : color;
 background-image : none | url(path);
 background-position: percent|length|(top left right
bottom center) /*w.r.t to top left*/
 background-repeat: repeat | repeat-x|repeat-y|no-repeat

 *background-size: length|percentage|cover|contain;
 background: background-attachment background-color
background-image background-position background-repeat
Block vs. Inline Elements
Inline
 No newlines before or after it
 Page flow is not broken

 Has no width and height
 Takes as much width of the
page as the content
 Can contain only inline
elements
 Examples:<span>, <a>,
<img>, <b>, <em>,<input>

Block
 Newlines appears before
and after it.
 Can have a width and
height
 Takes the whole page
width
 Can contain inline or block
elements
 Examples:<p>, <div>
References
 http://www.w3.org/TR/html401/
 http://www.w3.org/TR/CSS21/
 http://www.w3.org/TR/CSS2/
 https://developer.mozilla.org/en-US/docs/CSS
 http://www.daaq.net/old/css/index.php?page=us
ing+css
 http://alistapart.com/articles/howtosizetextincss

More Related Content

What's hot (20)

PDF
2. HTML forms
Pavle Đorđević
 
PPTX
Entering User Data from a Web Page HTML Forms
sathish sak
 
PPTX
Forms with html5 (1)
Anada Kale
 
PPTX
Html forms
nobel mujuji
 
PDF
Html css
John Felix
 
PPTX
New Form Element in HTML5
Zahra Rezwana
 
PPTX
Web engineering - HTML Form
Nosheen Qamar
 
PDF
Html forms
eShikshak
 
PPTX
FYBSC IT Web Programming Unit III Document Object
Arti Parab Academics
 
PPSX
HTML5 - Forms
tina1357
 
PPTX
HTML Forms
Ravinder Kamboj
 
PPTX
HTML5 Web Forms
Estelle Weyl
 
PPTX
html 5 new form attribute
Priyanka Rasal
 
DOCX
Html 5 tags
Eagle Eyes
 
PDF
Html tag list
A. K. M. Obydur Hussain
 
PPTX
Form using html and java script validation
Maitree Patel
 
PPT
A quick guide to Css and java script
AVINASH KUMAR
 
PPTX
Forms in html5
hrisi87
 
PDF
Html5 appunti.0
orestJump
 
PDF
Web Development Course: PHP lecture 2
Gheyath M. Othman
 
2. HTML forms
Pavle Đorđević
 
Entering User Data from a Web Page HTML Forms
sathish sak
 
Forms with html5 (1)
Anada Kale
 
Html forms
nobel mujuji
 
Html css
John Felix
 
New Form Element in HTML5
Zahra Rezwana
 
Web engineering - HTML Form
Nosheen Qamar
 
Html forms
eShikshak
 
FYBSC IT Web Programming Unit III Document Object
Arti Parab Academics
 
HTML5 - Forms
tina1357
 
HTML Forms
Ravinder Kamboj
 
HTML5 Web Forms
Estelle Weyl
 
html 5 new form attribute
Priyanka Rasal
 
Html 5 tags
Eagle Eyes
 
Form using html and java script validation
Maitree Patel
 
A quick guide to Css and java script
AVINASH KUMAR
 
Forms in html5
hrisi87
 
Html5 appunti.0
orestJump
 
Web Development Course: PHP lecture 2
Gheyath M. Othman
 

Similar to HTML and CSS part 2 (20)

PPT
Html class-04
Md Ali Hossain
 
DOCX
Html forms
Abhishek Kesharwani
 
PPTX
Introduction to Html5, css, Javascript and Jquery
valuebound
 
PPT
Web forms and html lecture Number 4
Mudasir Syed
 
ODP
Cascading Style Sheets - Part 01
Hatem Mahmoud
 
PPT
331592291-HTML-and-Cascading style sheet
stephen972973
 
PPTX
HTML - hypertext markup language
Basmaa Mostafa
 
PPT
20 html-forms
Kumar
 
PPTX
HTML Forms: The HTML element represents a document section containing interac...
BINJAD1
 
PPTX
Html advance
PumoTechnovation
 
PPTX
HTML-Advance.pptx
Pandiya Rajan
 
PDF
WEB DESIGN AND INTERNET PROGRAMMING LAB MANUAL.pdf
mmgg1621
 
PPT
Intodcution to Html
Taha Malampatti
 
PDF
CSS_Forms.pdf
gunjansingh599205
 
PPT
Chapter 4a cascade style sheet css
Tesfaye Yenealem
 
DOCX
Computer application html
PrashantChahal3
 
PDF
HTML-Forms
Ahmed Saihood
 
DOCX
Structured Graphics in dhtml and active controls.docx
Ramakrishna Reddy Bijjam
 
Html class-04
Md Ali Hossain
 
Introduction to Html5, css, Javascript and Jquery
valuebound
 
Web forms and html lecture Number 4
Mudasir Syed
 
Cascading Style Sheets - Part 01
Hatem Mahmoud
 
331592291-HTML-and-Cascading style sheet
stephen972973
 
HTML - hypertext markup language
Basmaa Mostafa
 
20 html-forms
Kumar
 
HTML Forms: The HTML element represents a document section containing interac...
BINJAD1
 
Html advance
PumoTechnovation
 
HTML-Advance.pptx
Pandiya Rajan
 
WEB DESIGN AND INTERNET PROGRAMMING LAB MANUAL.pdf
mmgg1621
 
Intodcution to Html
Taha Malampatti
 
CSS_Forms.pdf
gunjansingh599205
 
Chapter 4a cascade style sheet css
Tesfaye Yenealem
 
Computer application html
PrashantChahal3
 
HTML-Forms
Ahmed Saihood
 
Structured Graphics in dhtml and active controls.docx
Ramakrishna Reddy Bijjam
 
Ad

More from Julie Iskander (20)

PPTX
HTML 5
Julie Iskander
 
PPTX
Data structures and algorithms
Julie Iskander
 
PPTX
C for Engineers
Julie Iskander
 
PPTX
Design Pattern lecture 3
Julie Iskander
 
PPTX
Scriptaculous
Julie Iskander
 
PPTX
Prototype Framework
Julie Iskander
 
PPTX
Design Pattern lecture 4
Julie Iskander
 
PPTX
Design Pattern lecture 2
Julie Iskander
 
PPTX
Design Pattern lecture 1
Julie Iskander
 
PPTX
Ajax and ASP.NET AJAX
Julie Iskander
 
PPTX
jQuery
Julie Iskander
 
PPTX
ASP.NET Lecture 5
Julie Iskander
 
PPTX
ASP.NET lecture 8
Julie Iskander
 
PPTX
ASP.NET Lecture 7
Julie Iskander
 
PPTX
ASP.NET Lecture 6
Julie Iskander
 
PPTX
ASP.NET Lecture 4
Julie Iskander
 
PPTX
ASP.NET Lecture 3
Julie Iskander
 
PPTX
ASP.NET Lecture 2
Julie Iskander
 
PPTX
ASP.NET Lecture 1
Julie Iskander
 
PPTX
AJAX and JSON
Julie Iskander
 
Data structures and algorithms
Julie Iskander
 
C for Engineers
Julie Iskander
 
Design Pattern lecture 3
Julie Iskander
 
Scriptaculous
Julie Iskander
 
Prototype Framework
Julie Iskander
 
Design Pattern lecture 4
Julie Iskander
 
Design Pattern lecture 2
Julie Iskander
 
Design Pattern lecture 1
Julie Iskander
 
Ajax and ASP.NET AJAX
Julie Iskander
 
ASP.NET Lecture 5
Julie Iskander
 
ASP.NET lecture 8
Julie Iskander
 
ASP.NET Lecture 7
Julie Iskander
 
ASP.NET Lecture 6
Julie Iskander
 
ASP.NET Lecture 4
Julie Iskander
 
ASP.NET Lecture 3
Julie Iskander
 
ASP.NET Lecture 2
Julie Iskander
 
ASP.NET Lecture 1
Julie Iskander
 
AJAX and JSON
Julie Iskander
 
Ad

Recently uploaded (20)

PDF
Proactive Server and System Monitoring with FME: Using HTTP and System Caller...
Safe Software
 
PDF
“Scaling i.MX Applications Processors’ Native Edge AI with Discrete AI Accele...
Edge AI and Vision Alliance
 
PDF
GDG Cloud Southlake #44: Eyal Bukchin: Tightening the Kubernetes Feedback Loo...
James Anderson
 
PPTX
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Poster...
Michele Kryston
 
PDF
Optimizing the trajectory of a wheel loader working in short loading cycles
Reno Filla
 
PDF
Understanding AI Optimization AIO, LLMO, and GEO
CoDigital
 
PDF
Java 25 and Beyond - A Roadmap of Innovations
Ana-Maria Mihalceanu
 
PDF
Bitkom eIDAS Summit | European Business Wallet: Use Cases, Macroeconomics, an...
Carsten Stoecker
 
PDF
Quantum Threats Are Closer Than You Think – Act Now to Stay Secure
WSO2
 
PPTX
CapCut Pro PC Crack Latest Version Free Free
josanj305
 
PDF
Enhancing Environmental Monitoring with Real-Time Data Integration: Leveragin...
Safe Software
 
PDF
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
PDF
Darley - FIRST Copenhagen Lightning Talk (2025-06-26) Epochalypse 2038 - Time...
treyka
 
PDF
DoS Attack vs DDoS Attack_ The Silent Wars of the Internet.pdf
CyberPro Magazine
 
PDF
Simplify Your FME Flow Setup: Fault-Tolerant Deployment Made Easy with Packer...
Safe Software
 
PDF
“A Re-imagination of Embedded Vision System Design,” a Presentation from Imag...
Edge AI and Vision Alliance
 
PPTX
Paycifi - Programmable Trust_Breakfast_PPTXT
FinTech Belgium
 
PDF
99 Bottles of Trust on the Wall — Operational Principles for Trust in Cyber C...
treyka
 
PPSX
Usergroup - OutSystems Architecture.ppsx
Kurt Vandevelde
 
PDF
Why aren't you using FME Flow's CPU Time?
Safe Software
 
Proactive Server and System Monitoring with FME: Using HTTP and System Caller...
Safe Software
 
“Scaling i.MX Applications Processors’ Native Edge AI with Discrete AI Accele...
Edge AI and Vision Alliance
 
GDG Cloud Southlake #44: Eyal Bukchin: Tightening the Kubernetes Feedback Loo...
James Anderson
 
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Poster...
Michele Kryston
 
Optimizing the trajectory of a wheel loader working in short loading cycles
Reno Filla
 
Understanding AI Optimization AIO, LLMO, and GEO
CoDigital
 
Java 25 and Beyond - A Roadmap of Innovations
Ana-Maria Mihalceanu
 
Bitkom eIDAS Summit | European Business Wallet: Use Cases, Macroeconomics, an...
Carsten Stoecker
 
Quantum Threats Are Closer Than You Think – Act Now to Stay Secure
WSO2
 
CapCut Pro PC Crack Latest Version Free Free
josanj305
 
Enhancing Environmental Monitoring with Real-Time Data Integration: Leveragin...
Safe Software
 
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
Darley - FIRST Copenhagen Lightning Talk (2025-06-26) Epochalypse 2038 - Time...
treyka
 
DoS Attack vs DDoS Attack_ The Silent Wars of the Internet.pdf
CyberPro Magazine
 
Simplify Your FME Flow Setup: Fault-Tolerant Deployment Made Easy with Packer...
Safe Software
 
“A Re-imagination of Embedded Vision System Design,” a Presentation from Imag...
Edge AI and Vision Alliance
 
Paycifi - Programmable Trust_Breakfast_PPTXT
FinTech Belgium
 
99 Bottles of Trust on the Wall — Operational Principles for Trust in Cyber C...
treyka
 
Usergroup - OutSystems Architecture.ppsx
Kurt Vandevelde
 
Why aren't you using FME Flow's CPU Time?
Safe Software
 

HTML and CSS part 2

  • 1. Introduction to Web Technologies Lecture 2 Julie Iskander, MSc. Communication and Electronics
  • 3. Forms  Used to send data back to the server to be processed.  <form></form>  Contains:  control elements that get data from the user  label elements  Attributes:  action  url of page where data is sent  method  GET/POST http request method
  • 4. Controls  Controls must have name and value attributes to be submitted.  Controls can be disabled using disabled attribute.  Each control has an initial value and a current value.  Initial values are set by value attribute.  Current value when first rendered is set to initial value.
  • 5. Control Types  Buttons:  To submit form:  <input type=“submit” />, <button type=“submit”></button>  To reset form:  <input type=“reset” />, <button type=“reset”></button>  Just a button with no default behavior  <input type=“button” />  <button type=“button”></button>  Offers richer rendering capabilities then <input type=“text” />
  • 6. Control Types  Checkboxes:     On/off switches. Must have name to be submitted . if no value is set, off is the value Checked attribute is set to make initial value “on”  <input type=“checkbox”/>
  • 7. Control Types  TextBox:  Single line text input  <input type=“text”/>  Password:  Similar to TextBox, but input text is rendered as a series of asterisks or similar characters  But submitted as plain clear text  <input type=“password” />
  • 8. Control Types  Radiobuttons:  On/off switches but are mutually exclusive.  More than one share the same name to create a mutually exclusive group.  Checked attribute is set to make initial value “on” only one of the group at a time.  <input type=“radio”/>
  • 9. Control Types  DropDown Lists/Menus:  To choose one/more from multiple options.  Uses  <select name=“……”></select>  To select multiple options use multiple attribute  <select name=“……” multiple></select>  To define items use  <option></option>  Option can have name, value and selected attributes
  • 11. Control Types  DropDown Lists/Menus:  To logically group options use optgroup  <optgroup label=“…..”></optgroup>  label attribute is the value that appears in the list.
  • 13. Control Types  File select:  Allow users to select files to be submitted to a form.  <input type=“file” />
  • 14. Control Types  Hidden controls:  Not rendered visually.  Values are submitted with the other form data, can help overcome stateless nature of HTTP.  <input type=“hidden” name=“….” value=“….” />
  • 15. Control Types  Textarea controls:  Multiline text input.  Value is the content nested in the control.  <textarea>Content </textarea>  Has rows and cols attributes to set size of textarea.
  • 16. label  Specify a label for controls that don‟t have an implicit label.  for attribute MUST match ID value of the control attached to it.  Useful for speech synthesizers readers,  <label for=“fname”>First Name :</label>  <input type=“text” id=“fname”/>
  • 17. Structuring form  Use <fieldset> and <legend> to group related controls and labels.  Makes forms more accessible especially when rendered visually.
  • 21. Cascade Style Sheets (CSS)  “A language for describing the rendering of structured document as HTML and XHTML” from w3.org  Provides formatting and layout of html documents.  Controls presentation, assign styling information to elements.  Not a markup language  “cascade”  means multiple stylesheets can be blended together to affect a page. If conflict occurs the last applied or the most specific rule is applied.
  • 22. CSS Rules Syntax Selector { property1: value1; property2: value2; property3: value3; } Example body { } p { } background-color:blue; color:white; font-size:24pt; color:yellow;
  • 23. Where to add CSS?  Inline style attribute  Applied to a single element <p style=“color : pink ; font-size : 30pt ;”  In <head>  Applied to an entire single page <head> <style> body{ font-family : arial ; background-color : black ; color : white ; } p { color : pink ; } </style> </head>
  • 24. Where to add CSS? • In external sheet (.css) • Applied to any html file linked to it page.html style.css <head> …………………….. <link rel=“stylesheet” type=“text/css” href=“style.css” /> </head> url to css file (no markup only css rules) body{ font-family : arial ; background-color : black color : white ; } p { color : pink ; }
  • 25. CSS Selectors  Types of Selectors:  Simple Selectors  type, class, ID, attribute, pseudo-class  Group Selectors  coma-separated list of selectors
  • 26. Type Selector  Select by name of element (h1, p, div, span, …..etc.  Example: p { font-size:20pt; }
  • 27. Attribute Selector  Select an element by the attributes defined in it.  Example: [href] /*select any element with attribute named href*/ { font-size : 20pt ; } h1[title] /*select any h1 element with title attribute defined */ { color : red ; } a[href=“http://www.google.com”] /*select any a element with href exactly equal http://www.google.com */ { color : blue ; }
  • 28. Class Selector  Select an element by the class attributes defined in it.  Class is an attribute of most html elements, specifies one or more class names (space-separated list)  Example: .maincontent /*select any element with class=“maincontent” */ { font-size : 20pt; } H1.headerTitle /*select the all h1 with class=“headerTitle” */ { color : red; }
  • 29. ID Selector  Select an element by the ID attributes defined in it.  ID is an attribute of all html elements, it must be unique throughout a certain html page  Example: #maincontent /*select the element with id=“maincontent” */ { font-size : 20pt; } h1#headerTitle /*select the only h1 with id=“headerTitle” */ { color : red; }
  • 30. PseudoClass Selector  Selection based on special effects, Identified by „:‟  Link:  :link, :visited, :target  User actions:  :hover, :active, :focus  UI elements states:  :enabled, :disabled, :checked  Structural :  :first-child, :last-child, :nth-child(), :empty, :not()
  • 31. PseudoClass Selector (Cont‟d)  Example: a:hover /*applied when mouse hover over any link */ { font-size:20pt; } a.red:hover /*applied when mouse hover over link with class=“red” */ { font-size:20pt; } Input[type=“text”]:disabled /*applied to any textbox which is disabled */ { color:red; }
  • 32. PseudoElement Selector  Selection based on parts of elements, Identified by „::‟     ::first-letter ::before ::after ::first-line  Examples: p::after { content:”this content is added after the p” color:red; }
  • 33. Combinators  Combine selectors specified by relation between elements     Descendant Direct Childof (>) Adjacent Sibling (+) General Sibling(~)  Examples: h1 em {……..} /*em descendant of h1*/ div ol > li p{…….} /*p descendant of li which is a direct child of ol which is a descandent of div*/ span+p{……..} /*p that is a direct adjacent sibling to a span*/ a~p{………} /*p that is sibling of a it may be adjacent or not*/
  • 34. Example body{ background-color : black; color : green ; } [href] { color:pink; } a[name="next”]{ text-decoration: underline; } p.boldp{ font-weight: bold; } p#pid::first-letter{ font-size: 30px; } p::before { content: "Red text before p”; color:red; } p::after{ content: "Yellow text after p”; color:yellow; } <body> Trying Style Sheets <p>This is a paragraph tag <span>a span nested</span> in it</p> <p class="boldp">A new paragraph with more text to be shown describing</p> <a href="#next">NEXT</a> <br><br><br> <a name="next">Here is NEXT</a> &nbsp;&nbsp; <p id="pid">Next is more data to continue desribing the text</p> </body>
  • 36. Colors  Colors can be set using:     Keywords #-hexadecimal rgb() and rgba() hsl() and hsla()  To get full list of color keywords: https://developer.mozilla.org/enUS/docs/CSS/color_value
  • 37. Units in css  pixel (px) absolute value  em: ratio of context size  percentage: percentage of context size
  • 38. CSS Text Formatting color : name|#hex|rgb()|rgba()|hsl()|hsla(); /*foreground color*/ letter-spacing : normal|length (px,%,em); line-height: normal|number|length|percentage; text-align: left|right|center|justify; text-decoration: none|underline|overline|line-through|blink; text-indent: length|percentage; text-transform: capitalize|uppercase|lowercase|none; *text-shadow: rightpx bottompx blurpx color; direction: ltr | rtl; *word-wrap: normal|break-word;
  • 39. CSS Font font-family: list of font-names to chose from in order if not supported by browser font-size: smaller|larger|xx-small|x-small|small|medium| larger|x-large|xx-large|length|percentage; font-weight: normal|bold|bolder|lighter|100-900| font-style: normal|italic|oblique font-variant: normal|small-caps font: font-family font-size font-weight font-style font-variant;
  • 40. Background formatting  background-attachment : scroll | fixed;  background-color : color;  background-image : none | url(path);  background-position: percent|length|(top left right bottom center) /*w.r.t to top left*/  background-repeat: repeat | repeat-x|repeat-y|no-repeat  *background-size: length|percentage|cover|contain;  background: background-attachment background-color background-image background-position background-repeat
  • 41. Block vs. Inline Elements Inline  No newlines before or after it  Page flow is not broken  Has no width and height  Takes as much width of the page as the content  Can contain only inline elements  Examples:<span>, <a>, <img>, <b>, <em>,<input> Block  Newlines appears before and after it.  Can have a width and height  Takes the whole page width  Can contain inline or block elements  Examples:<p>, <div>
  • 42. References  http://www.w3.org/TR/html401/  http://www.w3.org/TR/CSS21/  http://www.w3.org/TR/CSS2/  https://developer.mozilla.org/en-US/docs/CSS  http://www.daaq.net/old/css/index.php?page=us ing+css  http://alistapart.com/articles/howtosizetextincss

Editor's Notes

  • #4: Get for idempotent forms that has no side effects, ex. Search forms, name=value pair appended to url after ‘?’Post for forms that will cause side effect like database modifications. name=value pairs are send in request body.
  • #9: Mutually exclusive  only one is “on” at ant time.
  • #11: Example of multi-select menu
  • #13: Example select with options groups
  • #31: There are more in each category, refer to w3.org for full lists
  • #33: There are more in each category, refer to w3.org for full lists
  • #39: In html 5text-shadow: if right is –ve, then acts as left, if bottomis –ve, then acts as top
  • #40: Default font-size is 16pxRecommended use by w3.org body{ font-size:100%;} All other elements {font-size: ….em}
  • #41: Background-size in CSS3 can be 100px 100px (length of width then height) 20% 30% (percentage of width then height)
  • #42: Block boxes laid vertically, starting at the top, Inline boxes laid horizontally, starting at the top, vertical margins are ignored, width and height can’t be specified.