(First announcement)
Layout Considerations
• Navigation element: horizontal, vertical, something else?
• Where does it go with respect to the header?
AIST 2220
Main Content
Header
AmenitiesRooms Reservations Business
Main Content
Header
Amenities
Rooms
Reservations
Business
Header
AmenitiesRooms Reservations Business
Layout Considerations
• How is the content organized?
• Columns, sidebars, grid of images?
AIST 2220
Heading
Lorem ipsum dolor sit amet,
consectetur adipiscing elit.
Duis elementum tincidunt
rhoncus. Morbi facilisis felis
sem, a dapibus lorem
eleifend at.
Heading
Etiam condimentum nisl
massa, quis faucibus lectus
hendrerit et. Phasellus eu
augue congue tellus
ullamcorper bibendum et ac
libero.
Header
Navigation Heading
Lorem ipsum dolor sit amet,
consectetur adipiscing elit. Duis
elementum tincidunt rhoncus.
Heading
Morbi facilisis felis sem, a dapibus
lorem eleifend at. Phasellus eu augue
congue tellus ullamcorper bibendum
et ac libero.
Header
Sidebar
Etiam condimentum
nisl massa, quis
faucibus lectus
hendrerit et.
Navigation
Text Line Width
• In each page element, how wide will a line of text be?
• Lines longer than 75 characters are hard to read
• On large screens, paragraphs may expand wider than you think
AIST 2220
Heading
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean
dictum imperdiet nisl, eu imperdiet metus dignissim vel. Fusce ante
neque, viverra ac diam facilisis, maximus mollis ex. Phasellus
porttitor turpis nec quam mattis tincidunt. Proin egestas egestas
lectus eget luctus.
Heading
Maecenas pellentesque porttitor lorem, vel luctus nulla sollicitudin
quis. Mauris eleifend lacus ut accumsan feugiat. Maecenas posuere
pellentesque lacus, eu vehicula arcu condimentum eu.
Heading
Lorem ipsum dolor sit amet,
consectetur adipiscing elit.
Aenean dictum imperdiet nisl, eu
imperdiet metus dignissim vel.
Fusce ante neque, viverra ac diam
facilisis, maximus mollis ex.
Phasellus porttitor turpis nec
quam mattis tincidunt.
Heading
Maecenas pellentesque porttitor
lorem, vel luctus nulla sollicitudin
quis. Mauris eleifend lacus ut
accumsan feugiat. Maecenas
posuere pellentesque lacus, eu
vehicula arcu condimentum eu.
Proin egestas egestas lectus eget
luctus.
Worse: Better:
Text Block Size
• How will you break your text content into sections, paragraphs?
• Avoid the dreaded “wall of text”
AIST 2220
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean
dictum imperdiet nisl, eu imperdiet metus dignissim vel. Fusce ante
neque, viverra ac diam facilisis, maximus mollis ex. Phasellus porttitor
turpis nec quam mattis tincidunt. Proin egestas egestas lectus eget
luctus. Maecenas pellentesque porttitor lorem, vel luctus nulla
sollicitudin quis. Mauris eleifend lacus ut accumsan feugiat. Maecenas
posuere pellentesque lacus, eu vehicula arcu condimentum eu.
Vivamus at augue eget leo vehicula porttitor ut in neque.
Pellentesque ex turpis, accumsan eget ligula nec, semper venenatis
elit. Vestibulum sodales orci ac tortor convallis.
Header
Navigation
Heading
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean
dictum imperdiet nisl, eu imperdiet metus dignissim vel.
Fusce ante neque, viverra ac diam facilisis, maximus mollis ex.
Phasellus porttitor turpis nec quam mattis tincidunt.
• Proin egestas egestas lectus eget luctus
• Maecenas pellentesque porttitor lorem
• Vel luctus nulla sollicitudin quis
• Mauris eleifend lacus ut accumsan feugiat
Header
Navigation
Better:
Layouts and Screen Size
• Wide range of screen sizes (phones, tablets, laptops, desktops)
• How wide do you expect your page to be? What if the screen is
wider or narrower than that? How will that affect your layout?
AIST 2220
Option 1: Multiple Layouts
• Redesign your layout for each screen size
• Can use fixed-size layout at each size
AIST 2220
Header
Amenities
Rooms
Reservations
Business
Header
AmenitiesRooms Reservations BusinessHeading
Lorem ipsum dolor sit
amet, consectetur
adipiscing elit. Duis
elementum tincidunt
rhoncus. Morbi facilisis
felis sem, a dapibus lorem
eleifend at.
Heading
Etiam condimentum nisl
massa, quis faucibus lectus
hendrerit et. Phasellus eu
augue congue tellus
ullamcorper bibendum et
ac libero.
Heading
Lorem ipsum dolor sit amet, consectetur adipiscing
elit. Duis elementum tincidunt rhoncus.
Heading
Morbi facilisis felis sem, a dapibus lorem eleifend at.
Phasellus eu augue congue tellus ullamcorper
bibendum et ac libero.
Header
Amenities
Rooms
Reservations
Business
Heading
Lorem ipsum dolor sit
amet, consectetur
adipiscing elit.
Wide Narrow Phone
Option 2: Fluid Layout
• Design layout with elements that can stretch and shrink
• Remember that long lines of text are hard to read
AIST 2220
Header
Amenities
Rooms Reservations
Business
Heading
Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Duis elementum tincidunt
rhoncus. Morbi facilisis felis sem, a
dapibus lorem eleifend at. Fusce ante
neque, viverra ac diam facilisis, maximus
mollis ex.
Header
AmenitiesRooms Reservations Business
Heading
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis elementum
tincidunt rhoncus. Morbi facilisis felis sem, a dapibus lorem eleifend at.
Fusce ante neque, viverra ac diam facilisis, maximus mollis ex. Phasellus
porttitor turpis nec quam mattis tincidunt.
Heading
Etiam condimentum nisl massa, quis faucibus lectus hendrerit et. Phasellus
eu augue congue tellus ullamcorper bibendum et ac libero.
Maybe add a
second column
as it gets wider
Outline
• Visual Design Principles
• Organization and Navigation
• Page Layout
• Colors and Fonts
AIST 2220
Color Schemes
AIST 2220
• Repetition: Don’t use too
many colors
• Color Scheme: A set of colors
with design roles
o Primary
o Secondary
o Accent
o Highlight
Using a Color Scheme
AIST 2220
• Primary color: major page elements (e.g. )
• Secondary color: toolbars, buttons, etc.
• Accents: Should contrast with primary/secondary, use for text-
shadow and borders on those elements
• Highlight: Use sparingly to make something stand out
Picking a Color Scheme
AIST 2220
• Colors in scheme should have
relationships to each other
• Analogous: Next to each
other on the color wheel
• Complementary: Opposite
each other
• Triadic: Three colors
equidistant on the wheel
Main color
Analogous
Analogous
Complementary
Triadic
Triadic
Color Scheme Resources
• https://color.adobe.com/create/color-wheel
• https://www.canva.com/colors/color-wheel/
• https://htmlcolorcodes.com/color-picker/
• These let you pick a main color, then show you analogous,
complementary, triadic, tetradic colors around it
• Also show you the hex codes for those colors, for your CSS
AIST 2220
https://color.adobe.com/create/color-wheel
https://www.canva.com/colors/color-wheel/
https://htmlcolorcodes.com/color-picker/
Color Choice Considerations
AIST 2220
• Primary color should match
logo or banner image
• Text should be readable –
text colors contrast with
background colors
Fonts
AIST 2220
• Same principle as colors:
Don’t use too many
• Pick a “Font Scheme”
o Heading font
o Body font
o Maybe a special font for the
site title/logo
Heading font
Body font
Heading font
Body font
Font Categories
AIST 2220
• Serif: Has decorative strokes
(“tails”) on ends of letters
o Elegant, traditional, readable
• Sans-serif: No decorations on
ends of letters
o Clean, modern, easier to
display at small sizes
Font Choice Considerations
• Body font: Must be readable in large quantities
• Heading font: Should stand out, can be more decorative
AIST 2220
Which would you rather read?
Harrington Calibri
Calibri
Cambria
Fonts on the Web
• Major restriction: Browser can only display a font that is
installed on the user’s computer
• font-face: Futura; only works if the person visiting your
website has the Futura font installed
AIST 2220
Body font set to Perpetua Same website, computer without Perpetua
Fonts on the Web
• Very few fonts are likely to be installed on all computers
• If you want your font selection to “work” most of the time, you
only have 6 choices:
o Arial
o Times New Roman
o Courier New
o Georgia
o Tahoma
o Verdana
AIST 2220
The Web Fonts Solution
• CSS @font-face block: Tell browser to download
a font before displaying your web page
o Now the font is definitely installed
• Complications:
o You must host the font on your server (in WOFF and EOT file format)
o Font must be licensed for free use, not proprietary
AIST 2220
@font-face {
font-family: "myFont";
src: url("myFont.woff");
}
Web Fonts
• To learn more: https://developer.mozilla.org/en-
US/docs/Learn/CSS/Styling_text/Web_fonts
• Google Fonts makes it easy: Google hosts the fonts and the CSS
@font-face block, you just link to Google’s stylesheet
o Go to fonts.google.com, pick your font
o Google shows you the link to a stylesheet that provides that font
o Copy it into your
AIST 2220
https://developer.mozilla.org/en-US/docs/Learn/CSS/Styling_text/Web_fonts
Summary
• Visual design principles: Repetition, contrast, proximity,
alignment
• Site organization: Hierarchy, navigation, depth considerations
• Page layout: Element sizes and shapes, adapting to different
screen sizes
• Color schemes, color harmonies
• Font schemes and web fonts
AIST 2220
AIST2220 05 Images
AIST 2220, Web Design
Images
Slides mainly provided by Dr. Paul York
Adopted and Edited by Dr. Reza Rahaeimehr
ONE
Learning Outcomes
✓ Describe the nature of electronic images
✓ Compare and contrast the main types of images used on the Web
✓ Embed images into web pages using the HTML image element
✓ Configure images as hyperlinks
✓ Use CSS to add images to the background of HTML elements
✓ Use CSS to use images in unordered lists
✓ Add a favorites icon to a web page
ONE
What is an Electronic Image?
• A computer screen is composed of
millions of individual pixels
• An image is little more than a
rectangular block of pixels
• A row image file is a set of meta-
data and data for setting the colors
of each individual pixel in that block
• This is known as a “Bitmap” file
...
48455A
5C576E
7A788C
...
ONE
Bitmaps are Big
• Bitmap Files can get quite large
• For example, take a 1000x1000 pixel image
• 1 Million Pixels (1 “Megapixel”)
• Each pixel is 3 “bytes”, so 3 “megabytes” total
• Even by today’s standards, that’s pretty big
• Web pages may have many 10’s of images
• Web sites may have many 1000’s
• Each must be stored on the server…
• …transferred over the internet…
• …loaded into memory in browsers.
ONE
Image “Compression” is Vital
• Image files must be made smaller to be useful on the web
• Files are “Compressed”
• How? MATH!!
• Two basic types of compression
• “Lossy”
• Relatively higher compression = smaller files
• Cannot exactly recreate source bitmap = sacrifice image quality
• “Lossless”
• Significantly lower compression = larger files
• Can recreate the source bitmap exactly = perfect image quality
ONE
Color Depth
• The human eye can see many millions of different colors
• Thus, “photo-realistic” images contain many millions of individual colors
• Another way of reducing image size is to reduce “color depth”
• How many unique color possibilities that can be allowed per pixel
• 8-bit: 256 unique colors per image
• Perfect for cartoons, logos, line art, etc.
• 24-bit: 16.7 million unique colors per image
• “True color” – perfect for photos
• Most screens can only display 24-bit images
• 30/36/48-bit: billions of unique colors per image
• “Deep color” or “High Dynamic Range” (HDR) – most realistic
8-bit
24-bit
ONE
Non-Rectangular Images – Transparency
• ALL electronic images are rectangular
• BUT, not all images are rectangular
• Images are made to appear irregularly shaped by
making some pixels transparent
• Not all image formats support transparency
• Some image formats support “translucent” pixels
• A color value – PLUS –
• An “alpha” value representing how “opaque” the color is
• Transparent images can be layered over other images
ONE
Image Formats for the Web
• In practice today, there are three common image formats in use on
the web
• All support compression
• Each uses different compression “algorithms” with different
characteristics
• CODEC = enCOde / DECode
ONE
GIF
• “Graphics Interchange Format”
• Created by CompuServe in 1987
• First cross-platform image standard
• 8-bit : 256 unique colors per image
• Lossless compression
• Supports Transparency
• But NOT translucency – a pixel is either a solid color or it is transparent
• Most useful for logos, clip-art, cartoons, etc.
• Supports primitive animation
ONE
JPEG
• “Joint Photographic Experts Group”
• First standard for digital photographs
• Usually 24-bit : 16.7 million colors per image
• Lossy compression
• Can control the amount of “loss”, i.e., the “quality” of the image
• Can achieve file sizes 20% down to 2% of original, depending on quality
• Does NOT support transparency
• Only rectangular images
• Does NOT support animation
• Still today the most common format for photographs
High Quality
Low Quality
ONE
PNG
• “Portable Network Graphic”
• Designed specifically for the web
• Usually 24-bit : 16.7 million colors per image
• Lossless compression
• Can achieve file sizes 10% to 70% of original, depending on type of image
• Supports transparent AND translucent pixels
• Does NOT support animation
• Great “compromise” format
• Especially good for irregular shaped photos or photos with text or lines
ONE
Image “Optimization”
• The key is to have a “just right” image
• Image SIZE is the #1 determinant of image FILE size
• Use an image editor to make the image EXACTLY as big as it needs to be to
display properly in your design
• Too big = wasted disk space, memory and bandwidth
• Too small = must scale up…can look AWFUL
• Choose the most appropriate image format
• GIF : smallest, but low color depth (not recommended anymore)
• JPEG : small, good color depth, but no transparency
• PNG : larger than JPEG, good color depth, supports transparency
ONE
File Names for Images
• As with all file names on the web:
• Avoid mixed case – typically all lowercase letters
• Avoid spaces – typically use an underscore (“_”) between words
• Choose a descriptive (but not too long) file name
• Each image type must use the appropriate extension
• GIF ➔ my_kitty.gif
• JPEG ➔ my_kitty – OR – my_kitty
• PNG ➔ my_kitty
ONE
The HTML Image Element (1)
• Used to insert an image directly into an HTML document
• “Void” element, like ; “inline” element like
• Can be placed anywhere in the
• Required Attributes:
• src attribute is the URL to the image file
• Like the href attribute for element; can be absolute or relative URL
• alt attribute simply provides a description of the image for accessibility
• Can be anything, but be descriptive
• Also used by search engines when categorizing images on a page
• The text will show to users if for any reason the image can not be loaded
300
385
=
𝟏𝟒𝟒
185
ONE
Images as Hyperlinks
• No Magic!!
• An element around ANY element(s) makes it/them hyperlinks
• So, just add an around the . E.g.:
• Some older browsers can add an ugly blue border around an image
• Remove it with a simple CSS block
a img {
border-style: none;
}
What’s this again???
A descendant selector:
“Select elements inside of elements”
ONE
CSS Background Images (1)
• Used to place an image in the background of an HTML element
• Content of the element (and child elements) appears on top of the
background image
header {
background-image: url(silly_cat );
}
index.html mystyles.css
Cats Rule
(dogs drool)
NO SPACE!!!
OPEN AND
CLOSE PARENS!!
CSS url “data type”
* Image URL between parens
* URL is relative or absolute
* Relative to CSS file location
* OPTIONAL double-quotes
ONE
CSS Background Images (2)
• By default, a background-images is “tiled”
• i.e., it repeats itself both horizontally and vertically
• The background-image is only as tall as the HTML element
• By default, HTML elements are only as tall as their content
• SO, a background-image on an empty element is INVISIBLE
• By default, a background image is “clipped” to the size of the element
• BUT, CSS is very flexible
• All of these “default” behaviors can be changed
• We’ll learn about changing the width and height of block elements in a later
lesson
ONE
CSS background-repeat Property
• As noted, background images are “tiled” by default
• Can use the background-repeat property to change this
• Values are: repeat (default), no-repeat, repeat-x & repeat-y
background-repeat: no-repeat;background-repeat: repeat; background-repeat: repeat-x; background-repeat: repeat-y;
ONE
Other CSS Background Image Properties (1)
• background-position Property
• By default, a single background image (no-repeat) is positioned at the left-top
hand corner of the HTML element
• Change with background-position: [horizontal] [vertical];
• background-attachment Property
• Can create a background that does not scroll with the
rest of the content (mostly used for a whole-page image)
[horizontal] [vertical]
left top
center middle
right bottom
X% (pct. from left) Y% (pct. from top)
Xpx (pixels from left) Ypx (pixels from top)
header {
background-image: url(cat_logo.gif);
background-repeat: no-repeat;
background-position: right top;
}
body {
background-image: url(kitty_litter );
background-attachment: fixed;
}
Space!!
scroll or fixed
ONE
Other CSS Background Image Properties (2)
• background-size Property
• As with the element, you can scale a background image
• Change with background-size: [width] [height];
• [width] and [height] can be one of:
• auto (default : maintains original width or height)
• #px (where # is the number of pixels for width or height)
• #% (where # is the percent of the original width or height)
• cover (image will resize to fully cover the element; may clip image)
• contain (image will resize as large as possible while remaining fully visible)
• E.g.: background-size: 300px 150px;
background-size: 75% 75%;
background-size: cover;
ONE
Home
• cover tells the browser to make
sure the image always covers the
entire container, even if it has to
stretch the image or cut a little
bit off one of the edges. contain
, on the other hand, says to
always show the whole image,
even if that leaves a little space
to the sides or bottom
ONE
Custom List Markers (i.e., “bullets”)
• For an unordered list, you can use an image in place of a bullet
• Use the list-style-image CSS property
• Cannot resize the image in CSS
• Must create a “tiny” image by resizing it in an image editor
Sylvester
Garfield
Felix
Heathcliff
Puss in Boots
.pawlist {
list-style-image: url(paw );
}
index.html mystyles.css
Sylvester
Garfield
Felix
Heathcliff
Puss in Boots
ONE
Favorites Icon
• Image that commonly displays in the along-side the name of the page
in a browser tab
• Also commonly displayed in a list of favorites or in the browser history
• Often a special image format (ICO)
• Find icon generators online (e.g., https://www.favicon-generator.org/)
• Can also use a GIF or PNG directly
• Add another element to your
element
• E.g.:
or
https://www.favicon-generator.org/
ONE
Summary
Things we learned:
✓ All about electronic images
✓ The main types of images used on the Web
✓ The HTML element
✓ How to make an image into a hyperlink
✓ How to add images to the background of HTML elements
✓ How to use images in place of bullets in a list
✓ How to add a favorites icon to a page
Slide 1: AIST 2220, Web Design
Slide 2: Learning Outcomes
Slide 3: What is an Electronic Image?
Slide 4: Bitmaps are Big
Slide 5: Image “Compression” is Vital
Slide 6: Color Depth
Slide 7: Non-Rectangular Images – Transparency
Slide 8: Image Formats for the Web
Slide 9: GIF
Slide 10: JPEG
Slide 11: PNG
Slide 12: Image “Optimization”
Slide 13: File Names for Images
Slide 14: The HTML Image Element (1)
Slide 15: The HTML Image Element (2)
Slide 16: Images as Hyperlinks
Slide 17: CSS Background Images (1)
Slide 18: CSS Background Images (2)
Slide 19: CSS background-repeat Property
Slide 20: Other CSS Background Image Properties (1)
Slide 21: Other CSS Background Image Properties (2)
Slide 22: https://css-tricks.com/
Slide 23: Custom List Markers (i.e., “bullets”)
Slide 24: Favorites Icon
Slide 25: Summary
AIST2220 06 More CSS
AIST 2220, Web Design
Adding Depth and Breadth to your CSS Knowledgebase
Slides mainly provided by Dr. Paul York
Adopted and Edited by Dr. Reza Rahaeimehr
ONE
Learning Outcomes
Choose and style text fonts using CSS
Configure paragraph styles using CSS
Describe the CSS Box Model
Configure border, padding, margin, width and height with CSS
Center content (or the entire page) with CSS
Add box and text shadows with CSS
Configure rounded corners with CSS
Add gradients and translucency to elements using CSS
ONE
Length Units
• Absolut
• they are not relative to anything else and are generally considered always to
be the same size.
• Relative
• Relative length units are relative to something else. The benefit of using
relative units is that with some careful planning, you can make it so the size of
text or other elements scales relative to everything else on the page.
ONE
Common absolute length units
Unit Name Equivalent to
cm Centimeters 1cm = 37.8px = 25.2/64in
mm Millimeters 1mm = 1/10th of 1cm
in Inches 1in = 2.54cm = 96px
pt Points 1pt = 1/72nd of 1in
px Pixels 1px = 1/96th of 1in
Table reference: https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units
ONE
Common relative length units
Table reference: https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units
% It is often used to define a size as relative to an element's parent object.
em
Font size of the parent, in the case of typographical properties like font-size, and
font size of the element itself, in the case of other properties like width.
rem Font size of the root element.
lh Line height of the element.
vw 1% of the viewport's width.
vh 1% of the viewport's height.
ONE
All in the font-family
• Each font has a font-family name
• A Generic Font Name is a set of font-family’s
that follow the same standard
• Some generic font names:
• serif, e.g.:
Times New Roman, Georgia, Garamond
• sans-serif, e.g.:
Arial, Calibri, Century Gothic, Helvetica
• monospace, e.g.:
Consolas, Courier New, Lucida Console
• also: cursive, Math, system-ui, …
• Comma-separated values specify a sequence
of “fallback” options
• Attempts to find and set font from left to right
• The last fallback should be a generic name
• Values with spaces must be surrounded by
double-quotes
body {
font-family: Arial, Helvetica, sans-serif;
}
.code-sample {
font-family: "Courier New", monospace;
}
ONE
The font-size Property
• Configure the size of the text in an element
• Value can be a named value or numeric with units
• Named is relative to default font size
• em and percent units are relative to the parent’s font size
Named Value em Units % units pt Units px Units
xx-small 0.5em 50% 6pt 8px
x-small 0.6em 60% 8pt 11px
small 0.75em 75% 10pt 13px
medium 1em 100% 12pt 16px
large 1.15em 115% 13.5pt 18px
x-large 1.5em 150% 18pt 24px
xx-large 2em 200% 24pt 30px
body {
font-family: Arial, sans-serif;
font-size: 11pt;
}
.code-sample {
font-family: Consolas, monospace;
font-size: 0.9em;
}
ONE
Some other properties
• font-weight
• normal or bold (absolute)
• lighter or bolder (relative)
• 100 to 900
• The greater number, the bolder
• 400 Normal font size
• font-style
• normal, italic, or oblique
• text-decoration
• none, wavy, underline, overline, or
strikethrough
• multiple values separated by space
• letter-spacing
• Spacing between letters
• normal, #px, #pt, #em or #% (width)
• Negative width to “condense” text
• font-variant
• normal or small-caps
• text-transform
• Alter capitalization
• none, capitalize, uppercase,
lowercase
ONE
Paragraph Style Properties
• Adjusts the text within any block element, not just
• text-align
• Alignment for a text-block
• left, center, right or justify
• text-indent
• Amount to indent the first line of a text-block
• Numeric amount (px, pt, etc.) or percent
• line-height
• Specifies the height of each line
• normal, numeric amount (px, pt, etc.) or percent
• Also a plain number as multiplier…e.g., 2 would mean “double-spaced”
.standard-paragraph {
text-align: justify;
text-indent: 30px;
line-height: 1.25;
}
This is a standard paragraph on my
web page. I’ve applied the “standard-
paragraph” class to this element.
ONE
• Every block element in HTML has:
• Content
The text, images, other elements, etc. that are
inside of that block element.
• Border
A “line” surrounding the block (invisible by default because it has no width)
• Padding
Space between the Content and Border
• Margin
Space between this block and other blocks on the page (zero size default for
most elements)
The CSS Box Model
margin
border
padding
content
ONE
Borders (1)
• Borders in CSS have:
• border-width
• A numeric value (usually in px) specifying the size of the border
• border-style
• One of: none, hidden, dotted, dashed, solid, double,
groove, ridge, inset or outset
• Not all will display as expected in all browsers
• border-color
• Any of the standard CSS color values (hex, rgb, etc.)
• Can specify all three in a single line:
• border: [width] [style] [color];
.standout-div {
border-width: 3px;
border-style: solid;
border-color: #337272;
}
.standout-div {
border: 3px solid #337272;
}
ONE
Borders (2)
• Borders have four potentially independent sides
• border-top, border-right, border-bottom, border-left
• Each can have completely different characteristics
• So really 12 possible values (border-top-width, border-top-style, etc.)
• Typically we’ll use the shortcut method
nav a {
text-decoration: none;
border-top: 1px dashed black;
border-bottom: 1px dashed black;
}
ONE
Padding
• The area between the content and the border
• Typically specified as a size (px, em, etc)
• Has four potentially independent values
• padding-top, padding-right, padding-bottom and padding-left
• However, can also leverage a shortcut method
• padding: [value]; (single value for all four sides)
• padding: [top] [right] [bottom] [left];
• padding: [top&bottom] [right&left];
• padding: [top] [right&left] [bottom];
margin
border
padding
content
ONE
Margin
• The area between block elements and
• Other block elements, or
• The outside of the browser window
• Like padding, has four potentially independent values
• margin-top, margin-right, margin-bottom and margin-left
• And like padding, can also leverage the shortcut method
• margin: [value]; (single value for all four sides)
• margin: [top] [right] [bottom] [left];
• margin: [top&bottom] [right&left];
• margin: [top] [right&left] [bottom];
margin
border
padding
content
ONE
Width and Height
• Recall that block elements are by default
• As wide as their container
• As tall as their content (automatic height)
• Often useful to control the width and/or the height of an element
• Can configure
• width: Can be % of container (100% default) or numeric width (px, em, etc.)
• height: Can be auto (default) or numeric height; can be percent only if its parent has a
specific height
• min-width & min-height: insures size is at least the specified value(s)
• max-width & max-height: insures size is no larger than the specified value(s)
• By default: Sets size of content area only
• not including padding or border
• When we add box-sizing: border-box; to a CSS rule, the browser instead
calculates the size of the element based on the content inside the element,
including any padding and borders
margin
border
padding
contentheight
width
ONE
Centering an Element
• Centering the content of a block element: text-align: center;
• Does NOT center the element itself
• If the element has width < 100% it will
be left-aligned by default
• Can move the element left using
margin-left, but how much??
• Setting both to “auto” will make both
equal, effectively centering the element
Centered Heading Text
Text within a block element that has
its width set to 50%.
Text within a block element that has
its width set to 50% and margin-left
set to a fixed amount.
Text within a block element that has
its width set to 50% and margin-left
and margin-right both set to “auto”.
margin-left ?? margin-right ??
margin-left: auto margin-right: auto
.centered-element {
width: 50%;
margin-left: auto;
margin-right: auto;
}
ONE
Tip: Centering All Page Content
• Centering every element on a page would be tedious
• Instead, use “wrap and center” strategy
• Create a “container” or “wrapper”
• Place ALL content inside of the
• Select that
in CSS and center it
• All content stays at 100% width
• 100% of the
, not 100% of the browser
#wrapper {
width: 1000px;
margin: auto;
}
Possible Shortcut
* Sets ALL margins to auto
* For top & bottom, auto = 0
My Awesome Web Site
New and improved with centered content
Linky 1 Linky 2 Linky 3
Bogus Heading Text
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit
esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat
non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Another Bogus Heading
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium
doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo
inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.
Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit,
sed quia consequuntur magni dolores eos qui ratione voluptatem sequi
nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet,
consectetur, adipisci velit, sed quia non numquam eius modi tempora
...
EVERYTHING ELSE
...
ONE
Rounded Corners
• The corners of a visible block element are squared off by default
• Visible = either background-color or border
• CSS allows for one or more corners to be rounded
• border-radius: radius of “virtual” circle in the corner
• Value is the size (px, em, etc.)
• Really border-top-left-radius, border-top-right-radius, etc.
• But … shortcuts
• border-radius: [value];
• border-radius: [top-left] [top-right] [bottom-right] [bottom-left];
ONE
Box and Text Shadows
• Can add shadows to an element (appears outside of border)
• box-shadow: [x-offset] [y-offset] [blur-radius] [color];
• x-offset & y-offset: +/- value (px) how far down or right the shadow extends
• blur-radius: value (px) how quickly shadow blends into background
• color: the color of the shadow itself
• Can also add shadows to the text of an element
• Use the text-shadow CSS property
• Same exact values as box-shadow
Element with box-shadow
Element with text-shadow
.shady { box-shadow: 5px 5px 4px #333333; }
ONE
Fun With Color – Opacity
• Can make an element that is layered over another “translucent”
• Transparent Translucent Opaque
• opacity property determines how “opaque” something is
• Value from 0 (transparent) to 1 (opaque)
• Makes ENTIRE element translucent
• Including the content (text, pictures, etc.)
.translucent-block {
opacity: 0.5;
}
ONE
Fun With Color – RGBA / Translucency
• Sometime you only want the background to be translucent
• Can set the background color to a translucent color, instead
• Use an RGBA color
• rgba([red],[green],[blue],[alpha]);
• “A” is for alpha
• Essentially the same as opacity
• Value from 0 (transparent) to 1 (opaque)
• But JUST for the color
Bummer!! I’m pretty visible
now, aren’t I? NOT so scary. :(
.translucent-block {
background-color: rgba(255,255,255,0.5);
}
ONE
Fun With Color – Gradients
• A gradient is a colored background that blends smoothly from one
color to another
• Some examples:
• background: linear-gradient(to bottom, red, yellow);
• background: linear-gradient(to right, blue, green);
• background: radial-gradient(green, yellow);
• There are a LOT of options, though:
• https://www.w3schools.com/css/css3_gradients.asp
https://www.w3schools.com/css/css3_gradients.asp
ONE
Summary
Things we learned:
A LOT about text formatting, including fonts and other text styles
The CSS Box Model, including how to alter the border, padding,
margin, width and height of any block element
How to center things with “auto” margins
How to add box and text shadows to elements
How to round one or more corners of a block element
How to add unique color effects to elements, including translucency
and gradients
ONE
Practice 1
ONE
Practice 1
Horizontally Centered
2
0
0
p
x
AIST2220 07 CSS for Page Layout1
AIST 2220, Web Design
Making the Layout of your Pages a Bit Less “Normal”
Slides mainly provided by Dr. Paul York
Adopted and Edited by Dr. Reza Rahaeimehr
ONE
Learning Outcomes
✓Describe normal flow
✓Be able to “float” content out of normal flow
✓Describe and apply the clear and overflow CSS properties
✓Leverage floating elements as one means of constructing a multi-
column layout
✓Describe and apply absolute and relative positioning
ONE
Normal Flow
• Normally (i.e., by default), browsers display elements in the order in
which they are coded
• Blocks are layered top-to-bottom
• Words within blocks flow left-to-right
• Text wraps at the edge of the content area
• Normally, browsers also display child
element(s) nested inside of a parent
element
• These default behaviors are called
“Normal Flow”
This is a block element. Or really this is the text within a block element. It
flows left to right and wraps at the boundary of the element. Specifically at
the edge of the “content” area.
Additional block elements are
stacked below and do so in the
order in which they appear in
the HTML source.
Even if the block COULD fit
beside a prior block, it will not
unless we “break” normal flow.
This is a parent element.
This is a child element. It is nested inside of the parent element. By
default it will be as wide as the parent element (less any padding).
ONE
Breaking Out of Normal Flow
• To achieve an appealing web design, you
will likely need to override these defaults
• We will cover the following ways of doing
this:
• “Floating” Elements
• Absolute and Fixed Positioning
• Relative Positioning
• We will point to the following:
• CSS Flexbox layout
• CSS Grid layout
• Sticky positioning
ONE
The CSS float Property
• “Floating” an element:
• Removes it from normal flow
• Reinserts it to the left or right of its
prior position
• Reflows (rewraps) the remainder
of the document around the
floated element
• Can be
• float: left;
• float: right;
SECOND ELEMENT
Just a regular element. Might be long. Might be short. Doesn’t matter. Just a regular element.
Might be long. Might be short. Doesn’t matter. Just a regular element. Might be long. Might be
short. Doesn’t matter. Just a regular element. Might be long. Might be short. Doesn’t matter.
Just a regular element. Might be long. Might be short. Doesn’t matter. Just a regular element.
Might be long. Might be short. Doesn’t matter. Just a regular element. Might be long. Might be
short. Doesn’t matter.
FIRST ELEMENT
Must have a width < 100% to
see it actually “float”.
SECOND ELEMENT
Just a regular element. Might be long. Might be short. Doesn’t
matter. Just a regular element. Might be long. Might be short.
Doesn’t matter. Just a regular element. Might be long. Might
be short. Doesn’t matter. Just a regular element. Might be
long. Might be short. Doesn’t matter. Just a regular element. Might be long. Might be short.
Doesn’t matter. Just a regular element. Might be long. Might be short. Doesn’t matter. Just a
regular element. Might be long. Might be short. Doesn’t matter.
FIRST ELEMENT
Must have a width < 100% to
see it actually “float”.
Float is often used to float images within a long container like this. Images are
generally “inline” elements (well, actually “inline-block”). Floating them makes
them behave as the same way as a true floating block element, though. Float is
often used to float images within a long container like this. Images are
generally “inline” elements (well, actually “inline-block”). Floating them makes
them behave as the same way as a true floating block
element, though. Float is often used to float images
within a long container like this. Images are generally “inline” elements
(well, actually “inline-block”). Floating them makes them behave as the
same way as a true floating block element, though. Float is often used
to float images within a long container like this. Images are generally
“inline” elements (well, actually “inline-block”). Floating them makes
them behave as the same way as a true floating block element, though.
ONE
Floating Hazards – The clear Property
• CSS clear property insures that a block of text will be guaranteed to
start below a floating image
• Can be:
• clear: left;
• clear: right;
• clear: both;
GHOSTS
Sometimes you have text that belongs with the floating element. And the text
following it belongs below the image. Floating causes ALL text to flow up. Even
subsequent block elements.
BALLOONS
Presumably this section (including the heading) is
supposed to be about balloons. Having it sit next to a
picture of ghost is just downright confusing. This is about balloons for
crying out loud! It should NOT be next to ghosts. I mean. What kind of
crazy junk is that? Ghosts and balloons seriously do NOT get along and
certainly don’t belong together. Duh!! I sure wish HTML were smarter.
It should just know what I want it to do and do it.
GHOSTS
Sometimes you have text that belongs with the floating element. And the text
following it belongs below the image. Floating causes ALL text to flow up. Even
subsequent block elements.
BALLOONS
Presumably this section (including the heading) is supposed to be about
balloons. Having it sit next to a picture of ghost is just downright confusing.
This is about balloons for crying out loud! It should NOT be next to ghosts.
I mean. What kind of crazy junk is that? Ghosts and balloons seriously do
NOT get along and certainly don’t belong together. Duh!! I sure wish HTML
were smarter. It should just know what I want it to do and do it.
ONE
Floating Hazards – The overflow Property
• Element height is determined by the height of its content, but ONLY
content that is in normal flow (i.e., NOT floating elements)
• If a floating element is taller than the content of the element it is
inside of, you end up with an the image “overflowing” the container
• You can “hack” the CSS overflow property to fix this
• Add rule to container element
• overflow: auto;
• Causes browser to include floating
content when calculating the
height of an element
GHOSTS
By default, the height of an element is dictated by the total height of all content
that is in normal flow, NOT including floating content. This can cause unexpected
results. Adding “overflow: auto;” to the element can fix the problem.
GHOSTS
By default, the height of an element is dictated by the total height of all content
that is in normal flow, NOT including floating content. This can cause unexpected
results. Adding “overflow: auto;” to the element can fix the problem.
ONE
More About the overflow Property
• That use for overflow truly is a “hack”
• Overflow is REALLY intended to designate how to handle content that
is too large for an element with a specified height
• Actually has two values: overflow-x and overflow-y
• Usually set both with overflow
• Can be:
• overflow: visible; (default)
• overflow: hidden;
• overflow: scroll;
• overflow: auto;
GHOSTS
Here the content of this element can scroll
independent of the rest of the page. It is a very
common way of making elements of a web page
behave in ways more commonly associated with
desktop applications.
Of course the assumption here is that this text is very long. So this
paragraph would just keep going, and going, and going, and going,
Ghosts
Balloons
Not Whales
ONE
The Multi-Column “Hack” (1)
• Can add columns to your page
using the float property
• For example, you may want to
have left-hand navigation
• Can set width of nav element
• Can float nav element to the left
• Unfortunately this doesn’t quite
achieve the desired effect
My Awesome Web Site
New and improved with centered content
Linky 1 Linky 2 Linky 3
Bogus Heading Text
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit
esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat
My Awesome Web Site
New and improved with centered content
Bogus Heading Text
Lorem ipsum dolor sit amet, consectetur adipiscing
lit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua. Ut enim ad minim veniam, quis
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Linky 1
Linky 2
Linky 3
ONE
The Multi-Column “Hack” (2)
• Set left margin on “main”
• Closer, but can’t set height of nav
• So, set background of “wrapper”
div to match color of nav
My Awesome Web Site
New and improved with centered content
My Awesome Web Site
New and improved with centered content
Linky 1
Linky 2
Linky 3
Bogus Heading Text
Lorem ipsum dolor sit amet, consectetur adipiscing
lit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua. Ut enim ad minim veniam, quis
nostrud exercitation ullamco laboris nisi ut aliquip ex
ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur. Excepteur sint occaecat
Linky 1
Linky 2
Linky 3
Bogus Heading Text
Lorem ipsum dolor sit amet, consectetur adipiscing
lit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua. Ut enim ad minim veniam, quis
nostrud exercitation ullamco laboris nisi ut aliquip ex
ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur. Excepteur sint occaecat
#wrapper {
width: 1000px;
background-color: orange;
}
nav {
width: 200px;
float: left;
background-color: orange;
}
main {
margin-left: 200px;
}
ONE
The CSS box-sizing Property
• WARNING (reminder)
• The width & height of an element are actually the
width & height of the content area
• Border and padding are NOT included by default
• This can be quite confusing when setting up complex layouts
• Use box-sizing property to override this default behavior
• Can be:
• box-sizing: content-box; (default)
• box-sizing: border-box;
margin
border
padding
contentheight
width
* {
box-sizing: border-box;
}
Universal Selector
* Apply to ALL elements
ONE
Advanced Layout: Absolute Positioning
• position: absolute
• Removes element from normal flow
• Use top, left, bottom and/or right to
place an element at an exact position
• The position is based on the nearest
positioned ancestor of the element.
• The ancestor whose position attribute
is not static
• If none, then the BROWSER will be the
base
My Awesome Web Site
New and improved with centered content
Linky 1 Linky 2 Linky 3
Bogus Heading Text
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit
esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat
GHOSTLY AWESOMENESS
.ghost-image {
position: absolute;
top: 20px;
left: 20px;
}
top: 0px; left: 0px;
bottom: 0px; right: 0px;
ONE
Advanced Layout: Absolute-ly Useful
• For example, IF a parent element has
position: relative
• (even if you don’t actually move that
element using top, left, etc.)
• THEN an absolutely positioned child
element will be:
• Positioned based on the relatively positioned
parent element
My Awesome Web Site
New and improved with centered content
Linky 1 Linky 2 Linky 3
GHOSTLY AWESOMENESS
Bogus Heading Text
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
main h3 {
text-align: right;
}
.ghost-image {
position: absolute;
top: 0px; left: 10px;
}
ONE
Advanced Layout: Fixed Positioning
• position: fixed;
• The element is positioned relative to the viewport
• It always stays in the same place even if the page is scrolled. The top, right,
bottom, and left properties are used to position the element.
ONE
Advanced Layout: Sicky Positioning
• position: sticky;
• The element is positioned based on the user's scroll position.
• A sticky element toggles between relative and fixed, depending on the
scroll position.
• It is positioned relative until a given offset position is met in the viewport -
then it "sticks" in place (like position:fixed).
ONE
Advanced Layout: z-index Property
• Elements that are children of parent elements are drawn as “layers”
• (This is apparent when child elements are stacked on top of parent elements)
• Layering also occurs as elements are drawn from top to bottom
• (NOT apparent because typically these elements don’t overlap)
• If you pull an element out of normal flow, it can “slide” under or over
other stacked elements unexpectedly
• Use the z-index property to adjust an
element’s position in the stack
• z-index: 1; (or higher) – “Bring to Front”
• z-index: -1; (or lower) – “Send to Back”
GHOSTLY AWESOMENESS
Bogus Heading Text
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit
esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat
z-index: 1;
ONE
(almost) Final Thoughts on Positioning
• In general, use positioning sparingly and deliberately
• This is a web page, not a PowerPoint slide
• Avoid the temptation to just “place” elements on the page
• Try to embrace the “flow” of a document
ONE
Bleeding Edge Layout: CSS Flexbox
• Flexbox is a one-dimensional layout system
used to align and distribute space among
items in a container.
• Draft CSS Specification
• Supported in latest versions of all
modern browsers
• Very flexible way of defining how
items flow within a container
• Similar to “floating” items in a
container, but far more configurable
• https://drafts.csswg.org/css-flexbox-1/
• https://css-tricks.com/snippets/css/a-guide-
to-flexbox/
CSS Flexbox Layout Guide
CSS Flexbox Layout Guide
CSS Flexbox Layout Guide
ONE
Flex Layout Common Properties
• flex-direction
• flex-direction: column;
• flex-wrap
• flex-wrap: wrap;
• justify-content
• justify-content: space-around;
• align-items
• align-items: center;
• align-content
• align-content: space-between;
• The align-content property is used to align the flex lines (effective when we have
more than one line)
The align-content property is used to align the flex lines.
ONE
Bleeding Edge Layout: CSS Grid
• CSS Grid Layout is a two-dimensional layout system used to create complex
grid-based layouts
• Draft CSS Specification
• Supported in latest versions of most
modern browsers
• Incredibly useful way of laying out
multiple columns on a page using
fixed-width columns and variable-
height rows (NO HACKS!!)
• https://drafts.csswg.org/css-grid/
• https://css-tricks.com/snippets/css/complete-guide-grid/
https://drafts.csswg.org/css-grid/
CSS Grid Layout Guide
ONE
Grid Layout example
• Set the display property to gird
to change the content area of
elements to a grid
• Using the grid-template-columns
you can define the number and
the size of your grid columns
• The gap property is used to
define the gap between columns
and rows
.gridExample{
display: grid;
grid-template-columns: auto auto auto;
gap:10px;
}
ONE
Summary
Things we learned:
✓What “normal flow” is
✓How to “float” content out of normal flow
✓How to use the clear and overflow properties to fix layout issues
introduced by floating elements
✓A “hackey” way to implement a multi-column layout
✓How to use absolute and relative positioning
Slide 1: AIST 2220, Web Design
Slide 2: Learning Outcomes
Slide 3: Normal Flow
Slide 4: Breaking Out of Normal Flow
Slide 6: The CSS float Property
Slide 7: Floating Hazards – The clear Property
Slide 8: Floating Hazards – The overflow Property
Slide 9: More About the overflow Property
Slide 10: The Multi-Column “Hack” (1)
Slide 11: The Multi-Column “Hack” (2)
Slide 12: The CSS box-sizing Property
Slide 13: Advanced Layout: Absolute Positioning
Slide 14: Advanced Layout: Absolute-ly Useful
Slide 15: Advanced Layout: Fixed Positioning
Slide 16: Advanced Layout: Sicky Positioning
Slide 17: Advanced Layout: z-index Property
Slide 18: (almost) Final Thoughts on Positioning
Slide 19: Bleeding Edge Layout: CSS Flexbox
Slide 20: Flex Layout Common Properties
Slide 21: Bleeding Edge Layout: CSS Grid
Slide 22: Grid Layout example
Slide 23: Summary
AIST2220 08 More on Links and Layout
AIST 2220, Web Design
A Deeper Dive into the Design and Operation of Navigational Elements
Slides mainly provided by Dr. Paul York
Adopted and Edited by Dr. Reza Rahaeimehr
ONE
Learning Outcomes
✓ Structure navigation as an unordered list
✓ Use CSS to create horizontal, vertical and fixed navigation
✓ Describe and use pseudo-selectors and pseudo-elements
✓ Create a basic drop-down menu using CSS
✓ Use “fragment identifiers” to navigate within a document
✓ Group images and captions using figure and figcaption
✓ Employ thumbnail image links
✓ Structure a “flowing” image gallery
ONE
The CSS display Property
• Block elements
• Start and end with a new line
• Default to 100% width & auto height
• CAN have explicit width and height
• Inline (aka “Phrase”) elements
• Typically “words” within a block
• Width & height are determined
automatically by the content
• With CSS display property, you can “magically” transform block elements into
inline elements and vice-versa
• display: none;
Hide an element and remove it from the document layout
• display: block;
Change an inline element (e.g., ) to display as a block element
• display: inline;
Change a block element (e.g.,
) to display as an inline element
• display: inline-block;
Elements are displayed as though they are inline elements, but they can have explicit width
and height
ONE
Home Experience Education Contact MeHome Experience Education Contact Me
CSS Pseudo-Classes – :hover & :active
• Append a Pseudo-Class to a selector to select based on conditions, e.g.:
• State (mouse/touch events, focused, enabled, disabled, etc.)
• Relative position on page / within element (more on this later)
• :hover selects an element when a mouse pointer is hovering over it
• :active selects an element when it is being clicked or pressed
• :focus selects an element that has the keyboard focus
• Tons More: https://css-tricks.com/pseudo-class-selectors/
nav a:hover {
border-top: 1px dashed black;
border-bottom: 1px dashed black;
}
nav a:active {
background-color: white;
}
Home Experience Education Contact Me
[…click…]
Meet the Pseudo Class Selectors
ONE
CSS Pseudo-Elements – ::before & ::after
• Append a Pseudo-Element to a selector to add content to an element
• ::before allows you to insert content before (in front of) an element
• ::after allows you to append content after (following) an element
• Should set the content property inside of the selector
• Can do some REALLY cool things
• https://css-tricks.com/pseudo-element-roundup/
nav a::before {
content: "♫";
}
nav a::after {
content: "♪";
}
♫Home♪ ♫Experience♪ ♫Education♪ ♫Contact Me♪
What the What?!?
Just a special character…copy & paste.
Use “Character Map” app in Windows, or the
“Edit / Special Characters” menu on a Mac.
A Whole Bunch of Amazing Stuff Pseudo Elements Can Do
ONE
Some more CSS selector
Child selector (>)
• Parent > Child { … }
nav > ul{
background-color:red;
}
Only the first ul is selected
because it is the child of
the nav tag
Even though the ul tag is
in the nav, it is not
selected.
ONE
Some more CSS selector
Adjacent sibling selector (+)
• Sibling + Sibling { … }
Test
paragraph 1
paragraph 1
paragraph 1
paragraph 1
h1 + p {
background-color: red;
}
Only the first p is selected
because it is the sibling of
an h1 tag
ONE
Navigating the
• The navigation area of a site often consists of a list of links
• Semantically speaking, should use an unordered list element
•
with each link wrapped in an
• Will (by default) create a bulleted list of links
• BUT, CSS will allow us to take full control the layout of the navigation area
• Home
• Experience
• Education
• Contact Me
ONE
Navigating the
– Vertical Navigation
• The
is already “vertical”, but has bullets
• Can use CSS to:
• Remove the bullets
• Remove the default