Skip to main content
UNIT II- UI DESIGN
 Markup Language (HTML): Introduction to HTML and HTML5 -
Formatting and Fonts –Commenting Code – Anchors – Backgrounds
– Images – Hyperlinks – Lists – Tables – Frames - HTML Forms.
Cascading Style Sheet (CSS): The need for CSS, Introduction to CSS –
Basic syntax and structure -Inline Styles – Embedding Style Sheets -
Linking External Style Sheets – Backgrounds – Manipulating text -
Margins and Padding - Positioning using CSS.
Markup Language (HTML):
Introduction to HTML and HTML5
 Books  written  English
 Web page  written  HTML.
HyperText Markup Language
 Web pages are text files.
 The key to hypertext is the use of
hyperlinks, which allow you to jump from
one topic to another.
What is HTML
 HTML describes the content
content and format
format
of web pages using tags.
Ex. Title Tag: <title>A title </title>
 It’s the job of the web browser to interpret
tags and display the content accordingly.
HTML Syntax
 An HTML file contains both formatting
formatting
tags
tags and content
content
 Document content is what we see on the
webpage.
 Tags are the HTML codes that control the
appearance of the document content.
HTML Syntax
 HTML syntax:
two-sided tag:
<tag attributes>document content</tag>
Starting
tag
Properties of the
tag.
Optional!
Actual content appears in
webpage. It could be empty
Closing
tag
Examples: <p> CGS 2100 </p>
<body bgcolor = “yellow”> UCF </body>
HTML Syntax
 HTML syntax:
one-sided tag:
<tag />
e.g. Breaking line tag: <br/>
Horizontal line tag: <hr/>
Structure of the web page
 Starting with the tag <html>...</html>
<html>
.......
</html>
Everything about
the web page
should be
enclosed here
Structure of the web page
 Inside the <html></html> tag
 Each web page has a head
head part described in
<head></head> tag:
<html>
<head>
<title> CGS 2100 </title>
</head>
</html>
The title of the
web page
should be put
here
Structure of the web page
 Inside the <html></html> tag
 Each web page has a body
body part described in <body></body>
tag:
<html>
<head>
<title> CGS 2100 </title>
</head>
<body>
This is a sample HTML file.
</body>
</html>
The content of
the whole web
page should be
put here
Title
Body
Create a basic HTML file
 Open your text editor (notepad
notepad).
 Type the following lines of code into the document:
<html>
<head>
<title> CGS2100 lab section</title>
</head>
<body>
This is a sample HTML file.
</body>
</html>
Create a basic HTML file (cont)
 Save the file as sample.htm
sample.html
Formatting and Fonts in HTML
Introduction to some common tags
 Paragraph tag
 List tag
 Hyperlink tags
Paragraph tags <p>...</p>
 <html>
 <head>
 <title> CGS 2100 </title>
 </head>
 <body>
 <p> Here is the first paragraph. </p>
 <p> Here is the second paragraph. </p>
 </body>
 </html>
result
First paragraph
Second paragraph
Space between
paragraphs
List tags
Ordered list: used to display information in a numeric
order. The syntax for creating an ordered list is:
<ol > e.g. <ol >
<li>item1 </li> <li> Name: Your name </li>
<li>item2 </li> <li> Section: ### </li>
… <li> Instructor: Yuping </li>
</ol> </ol>
 Result:
List tags
Unordered list: list items are not listed in
a particular order. The syntax is:
<ul > e.g. <ul>
<li>item1 </li> <li> Name: Your name </li>
<li>item2 </li> <li> Section: ### </li>
… <li> Instructor: Yuping </li>
</ul> </ul>
 Result
Hyperlink(anchors)
 Link to another location or file
 Syntax:
<a href= “http://www.ucf.edu”> Link to UCF </a>
Starting
Starting
Tag
Tag
Attribute of the tag: the address of
Attribute of the tag: the address of
the hyperlink
the hyperlink
Content displayed on
Content displayed on
the page
the page
Ending tag
Ending tag
Result:
Link
 Link to web site
 <a href= “http://www.ucf.edu”> Link to UCF </a>
 Link to document
<a href=“http://www.eecs.ucf.edu/images/building.jpg”>Link</a>
 Email link
<a href= “mailto:name@domain.com”> Link to email </a>
Include a Picture
 <img src=“FILENAME” />
 <img src=“FILENAME” alt=“text” />
 E.g.
 <img src=“logo.gif” alt=“Google logo” />
 <img src=“logo.gif” />
HTML – Tables
Why tables are important:
• to maintain the elements of your website
• to be creative with the design of pages
• to separate & organize different formatting styles
• map out your table(s) on paper first (pg. 144)
• figure out how many rows and columns
• determine the width (600 pixels is standard)
• keeping your table simple at first helps
• look for ideas on the internet (sample), save
the page, and then view it in Dreamweaver.
Creating Tables:
<table> to begin table
<tr> defines beginning of first row
<td> defines beginning of the cell
</td> to complete cell
</tr> to complete row
</table> to end table
Basic Table tags:
Table Code: in Notepad
These attributes all rest inside the first table tag:
<table
border=0 (invisible border – very common)
border=10 (by default takes up 2 pixels of space)
bordercolor=“red”
bgcolor=“yellow”
width=320 (there is a height tag but not often used)
align=center (left or right) (allows text to wrap)
<br clear=left or right or all> (to stop wrap)
valign=top (top, middle, bottom or baseline)
hspace=20 vspace=20 (border around picture)
colspan=2 (cell spanning more then one column)
rowspan=2 (cell spanning more then one row)
>
Table Code: Exploring Different Attributes
cellspacing=0 determines the number of pixels
between each cell
(default is 2 pixels)
cellpadding=0 determines the number of pixels
between the contents and the cell
wall
(default is 1 pixel)
Setting cells to =0 is common in layout design
<!--browsers can be finicky so make sure to set
border=0 to ensure there is no space between any
web page elements (if desired)-->
Table Code: cellspacing and cellpadding (pg. 155)
HTML – Lists (11% of test)
(pg. 135)
Why lists are important:
• they are widely used on links pages
• they help in the organization of data
• they are quick and easy to create
Creating Lists:
• first determine the style of list
• then determine the content
(sometimes writing this out first helps)
• there are two main types of lists:
• ordered lists: perfect for giving step-by-step
instructions to a visitor
(numbers, roman numerals or letters)
• unordered lists: mostly used to simply list items
on a web page such as links
(discs, round or square bullets)
<ol> to begin ordered list
<li> list item </li>
</ol> to end ordered list
<ul> to begin unordered list
<li> list item </li>
</ul> to end unordered list
Basic List tags:
List Code: in Notepad
These all rest inside the first list tag:
<ol
type=I or i (for large or small roman numerals)
type=A or a (for capital or small letters)
type=1 (for numbers, which is the default)
>
<ul
type=disc (the default for first level lists)
type=round (the default for second level lists)
type=square (the default for third level lists)
>
List Code: Exploring Different Attributes
Nested Lists are useful for creating website
site maps , and are simply just lists inside of lists:
<ol>
<li> Introduction </li>
<ol> <!-- indenting helps organize code -->
<li> Are lists fun? </li>
<li> Are lists not fun? </li>
</ol>
<li> Conclusion </li>
<ol>
<li> Lists are fun  </li>
<li> Lists are not fun  </li>
</ol>
</ol>
List Code: Nested Lists (pg.141)
HTML – Links (9% of test)
(pg. 117)
Why links are important:
• to let visitors easily browse your webpages
• to execute or download files (ie. movies, pdf’s, etc.)
• to create the ability to browse via a text or image
• to let users easily move to & from a particular spot
Links have three parts: destination, label & target
• destination: determines where link will go
(another page, a movie or an anchor)
• label: determines what visitors see and click on
(text, image or combination)
• target: determines where destination is seen
(in new window or frame, etc.) (pg. 122)
Creating Links:
• Absolute: shows entire path to file “elephant.jpg”
(http://www.site.com/web/images/elephant.jpg)
• Relative: seen when on website (zoo.html)
(“images/elephant.jpg”)
Another type of link is:
• Local: an anchor to and from a particular spot
(not on test)
(<a href=“#bottom”>Go to Bottom</a>)
(<a name=“bottom”></a>)
Two types of Links: Absolute & Relative
Relative: as if going to page on your site
<a href=“welcome.html”>Welcome</a>
Absolute: as if going to another site
<a href=
“http://www.ibm.com/web/home.html”>
IBM Home</a>
Basic Link tags:
Link Code: in Notepad
Changing the color of links:
Must reside in the <body tag:
link= changes color of link not used yet
vlink= changes color of link already visited
alink= changes color of link when clicked
> example: (<body link=“black”>)
<!-- used to coordinate colors on pages.
If a clients website is black & red, you may not want to
have the standard blue links.
Viewers still need to know it’s a link-->
Link Code: Exploring Different Attributes
Link Pages to Make a Website:
aboutus.htm l services.htm l contactus.htm l
m arketing.htm l
hom e.htm l
index.htm l
Write out an organization chart for the
pages your website will contain.
* most browsers only
look for index.html
(contain meta tags)
Link Pages to Make a Website:
• create a new folder on your desktop
(site name?) (remember to use lowercase)
• in notepad create index.html (in folder)
• in notepad create the home, aboutus,
services and contactus pages
• create folder in website called marketing
and create a page called marketing.html
• link all the pages
Frames
 use one or more
frameset elements
rather than one body
element
43
Forms
 radio button vs.
checkbox
 entity reference
44
Cascading Style Sheets (CSS)
The need for CSS..
 HTML markup can be used to represent
 Semantics: h1 means that an element is a top-level heading
 Presentation: h1 elements look a certain way
 It’s advisable to separate semantics from presentation
because:
 It’s easier to present documents on multiple platforms
(browser, cell phone, spoken, …)
 It’s easier to generate documents with consistent look
 Semantic and presentation changes can be made
independently of one another (division of labor)
 User control of presentation is facilitated
Style Sheet Languages
 Cascading Style Sheets (CSS)
Applies to (X)HTML as well as XML documents
in general
Focus of this chapter
 Extensible Stylesheet Language (XSL)
Often used to transform one XML document to
another form, but can also add style
XSL Transformations covered in later chapter
CSS Introduction
 A styled HTML document
produced by the style sheet style1.css:
CSS Introduction
link element associates style sheet with doc.
CSS Introduction
type attribute specifies style language used
CSS Introduction
href attribute provides style sheet URL
CSS Introduction
title attribute provides style sheet name
CSS Introduction
Alternative, user selectable style sheets
can be specified
CSS Introduction
CSS Introduction
 A styled HTML document
produced by the style sheet style2.css:
CSS Introduction
Note that alternate, user selectable style is
not widely supported: firefox 3 and IE 8 do,
but IE 6, IE 7 and Chrome don’t.
CSS Introduction
 Single document can be displayed on multiple
media platforms by tailoring style sheets:
This document will be printed differently than
it is displayed.
BASIC SYNTAX AND STRUCTURE…
 Parts of a style rule (or statement)
CSS Syntax:
Selector Strings
 Single element type:
 Multiple element types:
 All element types:
 Specific elements by id:
CSS Syntax:
Selector Strings
CSS Syntax:
Selector Strings
 Elements belonging to a style class:
Referencing a style class in HTML:
 Elements of a certain type and class:
class selector: begins with a period .
CSS Syntax:
Selector Strings
 Elements belonging to a style class:
Referencing a style class in HTML:
 Elements of a certain type and class:
this span belongs to three style classes
CSS Syntax:
Selector Strings
 Elements belonging to a style class:
Referencing a style class in HTML:
 Elements of a certain type and class:
this rule applies only to span’s belonging to class special
CSS Syntax:
Selector Strings
 Source anchor elements:
 Element types that are descendents:
pseudo-classes
CSS Syntax:
Selector Strings
 Source anchor elements:
 Element types that are descendants:
rule applies to li element that is
CSS Syntax:
Selector Strings
 Source anchor elements:
 Element types that are descendants:
rule applies to li element that is
part of the content of an ol element
CSS Syntax:
Selector Strings
 Source anchor elements:
 Element types that are descendants:
rule applies to li element that is
part of the content of an ol element
that is part of the content of a ul element
CSS Syntax
 Style rules covered thus far follow ruleset
syntax
 At-rule is a second type of rule
Reads style rules from specified URL
Must appear at beginning of style sheet
URL relative to style sheet URL
Style Sheets and HTML
 Style sheets referenced by link HTML element
are called external style sheets
 Style sheets can be embedded directly in HTML
document using style element
 Most HTML elements have style attribute (value
is list of style declarations)
Style sheet & HTML
 If any XML special characters, such as
less-than (<) or ampersand (&), appears in
style rules then the character must be
replaced by appropriate entity or character
reference.
 Such reference should not be use in
external stylesheet.
Style Sheets & HTML
 HTML 4.01 suggests enclosing the content of style
element within an SGML comment. For example.
<style type=“text/css”>
<!—
H1,h2{background-color:aqua}

</style>
Media attributes
<link rel=“stylesheet” type=“Text/css”
media=“screen, tv, projection”/>
<link rel=“stylesheet” type=“Text/css”
media=“handheld,print”/>
CSS Rule Cascade
 What if more than one style declaration
applies to a property of an element?
 The CSS rule cascade determines which
style rule’s declaration applies
CSS Rule Cascade
To find the value for an element/property
combination, user agents must apply the
following sorting order:
1- Find all declarations that apply to the
element and property in question, for the
target media type. Declarations apply if the
associated selector matches the element in
question.
CSS Rule Cascade
2- The primary sort of the declarations is
by weight and origin: for normal
declarations, author style sheets
override user style sheets which
override the default style sheet. For "!
important" declarations, user style
sheets override author style sheets
which override the default style sheet. "!
important" declaration override normal
declarations. An imported style sheet
has the same origin as the style sheet
that imported it.
Five origin/weight levels:
1. user/important
2. author/important
3. author/normal
4. user/normal
5. user agent/normal
CSS Rule Cascade
3- The secondary sort is by specificity of selector: more
specific selectors will override more general ones.
Pseudo-elements and pseudo-classes are counted as
normal elements and classes, respectively.
Specificity:
1. style attribute
2. rule with selector:
1. ID
2. class/pseudo-class
3. descendant/element type
4. universal
3. HTML attribute
CSS Rule Cascade
4- Finally, sort by order specified: if two rules have the
same weight, origin and specificity, the latter specified
wins. Rules in imported style sheets are considered to
be before any rules in the style sheet itself.
Conceptually, create one
long style sheet. Later
style rules have higher
priority than earlier rules.
CSS Inheritance
 What if no style declaration applies to a
property of an element?
 Generally, the property value is inherited from
the nearest ancestor element that has a value
for the property
 If no ancestor has a value (or the property
does not inherit) then CSS defines an initial
value that is used
CSS Inheritance
CSS Inheritance
 Property values:
Specified: value contained in declaration
 Absolute: value can be determined without reference to
context (e.g., 2cm)
 Relative: value depends on context (e.g., larger)
Computed: absolute representation of relative
value (e.g., larger might be 1.2 x parent font
size)
Actual: value actually used by browser (e.g.,
computed value might be rounded)
CSS Inheritance
 Most properties inherit computed value
Exception discussed later: line-height
 A little thought can usually tell you whether
a property inherits or not
Example: height does not inherit
 Inline Styles – Embedding Style Sheets -
Linking External Style Sheets – Backgrounds
– Manipulating text - Margins and Padding -
Positioning using CSS.
CSS Font Properties
Glyph (visual representation)
character cell
(content area)
 A font is a mapping from code points to glyphs
CSS Font Properties
 A font is a mapping from code points to glyphs
glyphs do not necessary stay inside cells!
CSS Font Properties
 A font family is a collection of related fonts
(typically differ in size, weight, etc.)
 font-family property can accept a list of
families, including generic font families
first choice font
CSS Font Properties
 A font family is a collection of related fonts
(typically differ in size, weight, etc.)
 font-family property can accept a list of
families, including generic font families
second choice font
CSS Font Properties
 A font family is a collection of related fonts
(typically differ in size, weight, etc.)
 font-family property can accept a list of
families, including generic font families
generic
CSS Font Properties
generic
fonts are
system-
specific
CSS Font Properties
 Note that most generic font can be easily
set on Firefox and Chrome, but such
option doesn’t seem to be available on IE
7 and 8. IE will still default to something
although maybe not what you had hoped
for!
CSS Font Properties
 Many properties, such as font-size, have a value that
is a CSS length
 All CSS length values except 0 need units
CSS Font Properties
Computed value
of font-size
property
CSS Font Properties
 Reference font defines em and ex units
Normally, reference font is the font of the
element being styled
Exception: Using em/ex to specify value for
font-size
parent element’s font is
reference font
CSS Font Properties
 Other ways to specify value for
font-size:
Percentage (of parent font-size)
Absolute size keyword: xx-small, x-small,
small, medium (initial value), large,
x-large, xx-large
 User agent specific; should differ by ~ 20%
Relative size keyword: smaller, larger
 Relative to parent element’s font
CSS Font Properties
CSS Font Properties
 Text is rendered using line boxes
 Height of line box given by line-height
 Initial value: normal (i.e., cell height; relationship with
em height is font-specific)
 Other values (following are equivalent):
CSS Font Properties
 When line-height is greater than cell height:
 Inheritance of line-height:
Specified value if normal or unit-less number
Computed value otherwise
CSS Font Properties
 font shortcut property:
CSS Font Properties
 font shortcut property:
Initial values used if no value specified in font
property list (that is, potentially reset)
CSS Font Properties
 font shortcut property:
specifying line-height (here, twice cell height)
any order size and family required,
order-dependent
CSS Text Formatting