Assignment Specification: Personal Portfolio Website
Assignment Specification: Personal Portfolio Website
1. Assignment Overview
Create a multi-page personal website that showcases your personality and hobbies. You must use HTML5
for structure and CSS3 for styling.
Constraints:
- NO JavaScript
- NO CSS Frameworks
- NO CSS Grid (Use Flexbox/Block model)
3. Page Requirements
Page 1/1
What is CSS?
• Every web page is composed of HTML (Hypertext Markup Language)
code that describes the content
• Example:
<p>An<strong>important</strong><font
color=“#FFFF00”>paragraph</font>.</p>
• Displays:
• An important paragraph.
• Repetitive and hard to maintain.
What is CSS?
• Layers of a web page:
• Content:
• Text, images, animation, video, etc.
• Presentation:
• How the content will appear to a human through a web browser, text reader, etc.
• Behavior:
• Real-time user interaction with the page: validation, sorting, drag-n-drop etc.
Style Sheet Languages
• Style sheet languages are used to describe the presentation of
structured documents, like HTML, XML and other markup languages.
What is CSS?
• Cascading Style Sheets
• Contains the rules for the presentation of HTML
=
+
• They were established by the World Wide Web Consortium (W3C). CSS rules
control the look (Style) of web pages or XML files by providing central locations
(Sheets) where HTML or XML tags are interpreted by the browser.
• Cons
• Different browsers may interpret Style Sheets in different ways
• Some styles may not be seen at all on some browsers
General Syntax
• Style Definition:
Selector {
property: value;
}
• Example: body { font-family: Verdana; font-size: 9px; }
[Link]
Source of Styles
> Author (Developer) Style Sheets
• External Styles
• Another way to associate a stylesheet file to an HTML page is
through the <style> tag and an inline style rule called @import.
[Link]
[Link]
• Find every span in the document and if it’s the first child of its
parent element go ahead and give it the styling.
CSS Selectors
> Structural PC Selectors
• first-of-type
• Find every h2 in the document and if it’s the first h2 child of its
parent element go ahead and give it the styling.
• only-child
• Whenever you find a paragraph, and that paragraph is the only child
inside of a parent go ahead and give that styling.
CSS Selectors
> Structural PC Selectors
• First-child
• last-child
• First-of-type
• last-of-type
• Only-child
• only-of-type
CSS Selectors
> Structural PC Selectors
• Of all the structural pseudo-class selectors :nth-child() pseudo-class
selector is the most complex of them all.
• nth-child selectors allow us to target elements based on patterns that
describes which elements within a parent you should target.
• We have four flavors of nth-child selectors.
• nth-child()
• nth-of-type()
• nth-last-child()
• nth-last-of-type()
CSS Selectors
> Structural PC Selectors
• nth-child(2)
CSS Selectors
> Structural PC Selectors
• nth-child(2n)
• n is a grouping element
• On the above element, target every second element
CSS Selectors
> Structural PC Selectors
• nth-child(odd)
• Instead of grouping, one can use keywords
• even is also another keyword
CSS Selectors
> Structural PC Selectors
• nth-child(2n+1)
• The 1 is called offset (beginning with this one)
CSS Selectors
> Structural PC Selectors
• nth-child(-2n+8)
nth-child(5n-1)
CSS Selectors
> Pseudo-elements
• Pseudo-elements are similar to pseudo-classes in many ways as they
allow you to access content beyond the normal capabilities of the
DOM.
• For Example: Using pseudo-element selectors you could target the first line or
first letter of an element.
• Pseudo-element selectors also allow us to create what is know as
generated content.
• That is actually place content on the page that is not contained in the
structure of the document.
CSS Selectors
> Pseudo-elements
• p::first-line (written like p:first-line in CSS 2)
CSS Selectors
> Pseudo-elements
• p::first-letter
CSS Selectors
> Pseudo-elements
• Generated content allows us to place content on the page.
• :before and :after
• Doesn’t show up on the DOM tree
• In order to work with :before and :after, we use content attribute.
• Content can be: string (Text content), u, counters(chapters), open-quote and
close-quote, and attr(x).
CSS Selectors
> Pseudo-elements
CONFLICT IN CSS
1. The Cascade
2. Inheritance
3. Specificity
Conflict in CSS
• Unless every page you create only holds a single paragraph, you’re
eventually going to have to deal with styles that conflict with one
another.
• Anytime you have multiple rules that target the same element you
have conflicting styles.
Conflict in CSS
• It is not always easy to catch conflicting styles.
Conflict in CSS
• When the properties conflict the properties of one rule will replace
the other.
• If they don’t conflict with one another, the properties are added and
the rules are cumulative leaving you with a mixture of the two rules.
• What determines which properties are used in the event of a
conflict? That is driven by three principles.
• The Cascade
• Inheritance
• Specificity
The Cascade
Example:-
H1{
Color:red
}
Specificity
• classes: Classes, Attributes, and Pseudo-classes
• elements: Element Types and Pseudo-elements
Specificity
> Example
• We have 101 and 1, the
101 always wins
Specificity
> Example
• Programmers go crazy about this one.
• This is not working because there is a selector elsewhere with a
higher degree of specificity than the one you are trying to use.
• .green has a specificity of 10 and #mainContent p has a specificity of 101.
Specificity
> Example
• In this case, we know .green has a specificity of 10, which shouldn’t
override #mainContent p that has a specificity of 101.
• Specificity works just fine until inheritance is involved.
• The strong element is nested inside the section and a paragraph. We
know from inheritance that those properties like color will inherit.
But, if a child element has a style that differs or conflicts with the
parent styles, the child styles always wins. In this case we are seeing
inheritance and not specificity.
Specificity
> Example
• .green has a specificity of 10
• strong has a specificity of 1
• .green wins.
Specificity
> Example
• .green has a specificity of 10
• [Link] has a specificity of 11
• [Link] wins.
Specificity
• Remember
• You always have to keep track how specific a rule is to know if you need
something a little bit more specific to override something.
• You want to try to keep the specificity of your rules as low as possible. They
are easier to parse that way, and they are also a lot easier to override later
on.
• And semantic naming matters. (a class named green, but it sets its color to
purple)
• Please go ahead and visit the following link and play with specificity
• [Link]
Important
• In addition to the cascade, inheritance and specificity there is one
more CSS technique that can be used to resolve conflicts and that is
the important declaration.
• It doesn’t matter what else is going on in your styles, in the event of a
conflict, the important declaration wins.
• The only thing that can override an important declaration is another more
specific important declaration or some kind of user controlled stylesheet.
• Don’t use important declaration unless it is absolutely necessary.
• Example: color: blue !important;
Important
> Example
• In the following case regardless of the cascade, specificity or inline
style the important declaration wins.
Resolving Conflicts Through Planning
> General Guidelines
• Avoid using local styles when possible.
• They add unwarranted extra layer of complexity to a site.
• Updating or modifying styles can become a chore.
• Local styles are easy to miss, especially in a team environment.
• Do not use inline styles except for very specific circumstances.
• They are almost impossible to detect and maintain.
Resolving Conflicts Through Planning
> Develop a Strategy for Specificity
• Don’t mix class and ID selectors without having a plan that guides
when they are to be used.
• Sections of ID selectors can be hard to override later if not accounted
for.
• Rule of Thumb: If you find yourself writing descendent selectors with
three or more selectors, consider revising your strategy.
Resolving Conflicts Through Planning
> Use Inheritance to your Advantage
• If you are familiar with your page structure, you should be able to
identify global formatting across your site.
• Those formatting needs can then be written as global styles on parent
elements, and inherited by the rest of the site.
• This results in fewer rules to write and easier styles to maintain.
Resolving Conflicts Through Planning
> Think about How Styles Relate to One Another
• New designers often make the mistake of styling each element
individually, as it’s encountered.
• This can lead to bloated style sheets and hard to maintain styles.
• Thinking of styles as related formatting allows you to plan and write
organized style sheets.
Example of Good Planning
Example of Good Planning. Separate .css file for different font
family,animations…
DIMENSIONS
• Height
• Width
• Max-width
CSS Dimension Properties
• The CSS dimension properties allow you to control the height and
width of an element.
• We can use the height and width properties.
section {
width: 500px;
height: 100px;
border: 3px solid #73AD21;
}
width and max-width
• A block-level element always takes up the full
width available (stretches out to the left and
right as far as it can)
• Setting the width of a block-level element will
prevent it from stretching out to the edges of its
container.
• Note: The problem with giving a width to an
element is when the browser window is smaller
than the width of the element. The browser
then adds a horizontal scrollbar to the page.
• The solution is using max-width property
• It will improve the browser's handling of small
windows. This is important when making a site
usable on small devices.
CSS UNITS
• Relative
• Absolute
CSS Units
• CSS has several different units for expressing a length.
• Many CSS properties take "length" values, such as width, margin,
padding, font-size, border-width, etc.
• Length is a number followed by a length unit, such as 10px, 2em, etc.
• A whitespace cannot appear between the number and the unit.
However, if the value is 0, the unit can be omitted.
• For some CSS properties, negative lengths are allowed.
• There are two types of length units:
• Relative
• Absolute
CSS Units…
• Absolute Values: The absolute length units are fixed and a length
expressed in any of these will appear as exactly that size.
• in (inches), cm (centimeters), mm (millimeters), pt (points), pc (picas), px
(pixels),
• Not good for small screen devices
• Relative Values: Relative length units specify a length relative to
another length property. Relative length units scales better between
different rendering mediums.
• em (ems), ex (exes), gd (grids), rem (root ems), vw (viewport width), vh
(viewport height), vm (viewport minimum), ch (character)
• Well suited for devices like screens
CSS Units
• Pixels
• You don’t have to pass all three of them. You can simply pass bold for
font-weight, or small-caps for font-variant or italic for font-style.
Typography Properties
> Shorthand Notations
• Shorthand notations also take some special keywords.
• You can use a set of optional keywords which instructs the user agent to use
the font formatting used by those system fonts. This is especially useful when
creating applications or UI widgets. Example: status-bar, small-caption,
message-box, menu, icon, caption
Typography Properties
> text-align
• To control text alignment with CSS we use the text-align property.
• For the most part, text alignment is pretty straightforward. You set
alignment through the text-align property, which accepts the left,
right, center, justify, or inherit values.
Typography Properties
> text-align
Typography Properties
> letter-spacing and word-spacing
• CSS gives you control over word and letter spacing through the word-
spacing and letter-spacing properties.
• -ve value is also possible
Typography Properties
> text-indent
• CSS allows you to control the indenting of text through the text-
indent property. This will indent the first line of text in any element
that it is applied to. You can also apply negative values to the property
as well.
• Negative values can often help you create what is known as hanging
punctuation.
Typography Properties
> text-indent
• Margin
• Padding
• Border
• Content
The Box Model
> Styling Container Elements
• The box model is a term used to describe
the rules and properties surrounding the
physical properties of all HTML elements
on the page.
• All elements on your webpage are considered
to be a rectangular box. The properties of this
box, its width, height, padding and margin
define not only the size of the element but
how it relates to the elements around it.
Without these properties we wouldn’t be
able to control layout at all.
The Box-Model
> Border
• Three different ways you can apply borders in terms of
syntax.
• Border Syntax:
• /* Verbose */ 12 times
• border-top-width: width;
• border-top-color: color;
• border-top-style: style;
• /* Directional Shorthand Notation */ 4 times
• border-top: width style color;
• /* Uniform Shorthand Notation */ 1 time
• border: width style color;
The Box-Model
> Border
• Example:
• border-top-width: 1px;
• border-top-color: #000;
• border-top-style: solid;
• border-top-left-radius: value;
• border-radius: horizontalradius/verticalradius;
The Box-Model
> rounded-corners
The Box Model
> margin (element-spacing)
• Margins help us control the spacing between elements and can be
specified individually for the top, right, bottom and left sides of an
element.
• Syntax:
• margin-top: value;
• Auto margins example:
• .four p { width: 80%; margin-right: auto; margin-left: auto; }
• Centers the paragraph horizontally
• Auto: it takes whatever is left over from the width of an element and go
ahead and apply the margin to that.
The Box-Model
> Padding
• The space inside an element is controlled through three properties.
• Width
• Height
• Padding
• Padding is the space between an element content and the inside
edge of its border.
• Primarily used to keep content away from its edge.
• Example:
• padding-left: 50px;
• Padding has a cumulative effect on the total height and width of an
element.
The Box-Model
> Short Hand (Margins and Padding)
• Short Hand Syntax: (works for both margin or padding)
• margin: top right bottom left;
• padding: top leftandright bottom;
• margin: topbottom leftright;
• padding: allsides;
• Example:
• margin: 10px 15px 20px 30px;
• padding: 10px 20px 15px;
• margin: 10px 30px;
• padding: 30px;
The Box-Model
> Element Sizing
• Width of an element is the summation (cumulative) of the width,
padding and margin values.
• The width property is a content width.
• If no height is defined, the height of the elements will be calculated
based on borders, padding, and content. Margins are used in
calculating overall width and height, but are not actually considered
part of the container width and height and are the first to be
sacrificed if the element's width and height no longer fits within the
parent.
• Account all properties when designing a box to fit.
Use Padding to position Div content
What's the full width and height of the ff Div
Div
{
Width:100px;
Height:200px;
Padding:10px;
Margin:10px;
Border:10px solid red;
}
IMAGES, LISTS, TABLES &
FORMS
Images
• CSS plays a good role to control image display. You can set the following
image
properties using CSS.
The border property is used to set the width of an image border.
The height property is used to set the height of an image.
The width property is used to set the width of an image.
• img {
max-width: 100%;
height: auto;
}
• Note:-You can create a responsive image by using max-width property
Images(Rounded Images)
• Use the Border-radius property to create rounded images.
• img {
• border-radius: 50%;
•}
Image Opacity / Transparency
list-style-type: katakana;
• Width and height of a table is defined by the width and height properties.
• The example below sets the width of the table to 100%, and the height of
the th elements to 50px:
table
{
width:100%;
}
th
{
height:50px;
}
created by zelalem Abera-HilCoe-Web - Technology 24
Table Text Alignment
• To control the space between the border and content in a table, use
the padding property on td and th elements:
• td
{
padding:15px;
}
• The example below specifies the color of the borders, and the text
and background color of th elements:
table, td, th
{
border:1px solid green;
}
th
{
background-color:green;
color:white;
}
tr:nth-child(even){background-color: #f2f2f2}
27
Table Collapse
table {
border-collapse: collapse;
}
}
28
Responsive Table
• Add a container element (like <div>) with overflow-x:auto around
the <table> element to make it responsive:
• <div style="overflow-x:auto;">
Forms
Styling Input Fields
• input {
width: 100%;
}
• If you only want to style a specific input type, you can use attribute
selectors:-
• input[type=text] {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
box-sizing: border-box; border: 2px solid red;
border-radius: 4px; background-color: #3CBC8D;
}
CSS LAYOUT
• Display
• Width max-width
• Position
• Overflow
• Float and clear
• Inline-block
• Horizontal and vertical align
Display
• A block-level element always starts on a new line and takes up the full
width available (stretches out to the left and right as far as it can).
<div> <h1> - <h6> <p> <form><header> <footer> <section>
• An inline element does not start on a new line and only takes up as
much width as necessary. <span><a><img>
CSS Display and Visibility
HIDING AN ELEMENT
DISPLAY:NONE OR VISIBILITY:HIDDEN
[Link] { [Link] {
33
Position
• The position property specifies the type of positioning method used for an
element (static, absolute, relative or fixed)
• Static is the default value.
• IE7 and IE8 support the fixed value only if a !DOCTYPE is specified.
• Syntax
• position: static|absolute|fixed|relative|initial|inherit;
• static The default position in the page flow
• relative Relative to its normal position in the flow
• absolute Relative to its containing block (the first ancestor that is not
static)
• fixed Relative to the browser windows (regardless of scrolling)
Position
Position
• Boxes are positioned in three dimensions
• To change the stack level, use z-index (default value is 0)
Use Relative & absolute position
Overflow
• The overflow property specifies what happens if content
overflows an element's box
• The default value is visible
overflow: visible|hidden|scroll|auto|initial|inherit;
Floating
• A floated element is one whose float
property has the value right or left (the
default is none)
• The float property, in its simplest use,
can be used to wrap text around
images.
• Floating an element converts it to a
block.
• A floated box is shifted to the left or
right as far as possible.
• A floated box must have an explicit
width. Otherwise, the results can be
unpredictable.
Use float
Clear
• The clear property is used to control the behavior of floating
elements.
• Elements after a floating element will flow around it. To avoid this,
use the clear property.
• The clear property specifies on which sides of an element floating
elements are not allowed to float;
• Syntax:
• clear: left|right|both;
• Reading Assignment (Clear and Float with page layout)
• [Link]
The inline-block Value
• It has been possible for a long time to create a grid of boxes that fills the browser
width and wraps nicely (when the browser is resized), by using the float property.
• we also need to specify a clear property for the element after the floating boxes.
• However, the inline-block value of the display property makes this even easier.
.floating-box {
display: inline-block;
width: 150px;
height: 75px;
margin: 10px;
border: 3px solid #73AD21; }
Align
.center {
margin: auto;
• Center Align - Using margin width: 60%;
border: 3px solid
• No effect if width property is not set (or set to 100%).
#73AD21;
padding: 10px;
• Left and Right Align - Using position }
.right {
float: right;
width: 300px;
background-color: #b0e0e6;
}
WORKING WITH COLORS
Working with Colors
> Keywords
• Color Keywords: To declare basic color values, you can use one of
over 140 reserved color keywords.
• Example: black, gray, maroon, olive, fuchsia, saddlebrown, slategray
• You may learn more about them at [Link]
Working with Colors
> Hexadecimal
• You can only define the opacity of an entire element. It is sort of all or
nothing type.
Transparency of an element
> Opacity syntax and RGBA and HSLA syntax
• RGBA and HSLA: This technique involves passing an alpha value
through a regular RGB or HSL color definition.
• Flexible (Border, text, and background color)
• You can then define the transparency either the foreground color, background
color or border color.
• This method only allows to set alpha values to colors but not to background
images.
• Example:
• background: rgba(102, 0, 0, .2);
• background: hsla(65, 80%, 50%, .6)
> Drop Shadows
• In CSS for drop shadows, you have two options.
• Box Shadows are going to be applied to the containing box of an element.
• Text Shadows should be limited to be used on text.
• Box Shadow Example:
• box-shadow: vertical length, horizontal length, blur radius (how blur do you
want this), spread (how far do you want it to fade out), color
• box-shadow: 10px 10px 5px 5px rgba(0, 0, 0, .7);
• Text Shadow Example:
• text-shadow: vertical length, horizontal length, blur radius, color
• text-shadow: 10px 10px 5px rgba(0, 0, 0 .7);
Reading Assignment
• CSS3 2D Transforms
• CSS3 3D Transforms
• CSS3 Animations
Flexbox
CSS3 Flexbox
Flex Container
Main Axis
CSS3 Flexbox - Concepts Cross Axis
Flex Container
Main Axis
Why do we need
this?
CSS3 Flexbox - Code
CSS:
CSS3 Flexbox - Code
HTML:
CSS3 Flexbox - Code
Result:
CSS3 Flexbox - Code
Result:
CSS3 Flexbox - Flex Direction
Example:
(Row-reverse)
CSS3 Flexbox - Flex Direction
Example:
CSS3 Flexbox - Flex Direction
Example:
(Column)
CSS3 Flexbox - Flex Direction
Example:
CSS3 Flexbox - Flex Direction
Example:
(Column-
reverse)
CSS3 Flexbox - Flex Direction
Example:
justify-content Property
Example:
(Flex-end)
justify-content Property
Example
(Flex-end):
justify-content Property
Example:
(center)
justify-content Property
Example:
(center)
justify-content Property
Example:
(space-
between)
justify-content Property
Example:
(space-
between)
align-items Property
Example:
(Stretch)
align-items Property
Example:
(Stretch)
align-items Property
Example:
(Flex-start)
align-items Property
Example:
(Flex-start)
align-items Property
Example:
(Flex-end)
align-items Property
Example:
(Flex-end)
align-items Property
Example:
(Center)
align-items Property
Example:
(Center)
align-items Property
Example:
(Baseline)
align-items Property
Example:
(Baseline)
flex-wrap Property
Example:
(Nowrap)
flex-wrap Property
Example:
(Nowrap)
flex-wrap Property
Example:
(Wrap)
flex-wrap Property
Example:
(wrap)
align-content Property
The align-content property modifies the behavior of the
flex-wrap property. It is similar to align-items, but instead of
aligning flex items, it aligns flex lines
The possible values are as follows:
stretch - Default value. Lines stretch to take up the
remaining space
flex-start - Lines are packed toward the start of the
flex container
flex-end - Lines are packed toward the end of the flex
container
align-content Property
The align-content property modifies the behavior of the
flex-wrap property. It is similar to align-items, but instead of
aligning flex items, it aligns flex lines
The possible values are as follows:
center - Lines are packed toward the center of the flex
container
space-between - Lines are evenly distributed in the
flex container
space-around - Lines are evenly distributed in the flex
container, with half-size spaces on either end
align-content Property
Example:
(Center)
align-content Property
Example:
(Center)
align-content Property
Example:
(Flex-end)
align-content Property
Example:
(Flex-end)
Flex Item Properties - Ordering
Example:
(Ordering)
Item Properties - Ordering
Example:
(Ordering)
Flex Item Properties - Margin
Example:
(Margin)
Flex Item Properties - Margin
Example:
(Margin)
Flex Item Properties - Perfect Centering
Example:
(Margin)
Flex Item Properties - Margin
Example:
(Margin)
Flex Item Properties - Align Self
Example:
(Align self)
Flex Item Properties - Flex
Example:
(Flex)
Flex Item Properties - Flex
Example:
(Flex)
CSS3 Flexbox Properties
Property Description
display Specifies the type of box used for an HTML element
flex-direction Specifies the direction of the flexible items inside a flex container
justify-content Horizontally aligns the flex items when the items do not use all available space on the
main-axis
align-items Vertically aligns the flex items when the items do not use all available space on the
cross-axis
flex-wrap Specifies whether the flex items should wrap or not, if there is not enough room for
them on one flex line
align-content Modifies the behavior of the flex-wrap property. It is similar to align-items, but instead
of aligning flex items, it aligns flex lines
flex-flow A shorthand property for flex-direction and flex-wrap
order Specifies the order of a flexible item relative to the rest of the flex items inside the
same container
align-self Used on flex items. Overrides the container's align-items property
flex Specifies the length of a flex item, relative to the rest of the flex items inside the same
container
Sources
[Link]
Copyrights
Presentation prepared by and copyright of John Ramsey,
East Tennessee State University, Department of
Computing . (ramseyjw@[Link])
●Microsoft, Windows, Excel, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation.
●IBM, DB2, DB2 Universal Database, System i, System i5, System p, System p5, System x, System z, System z10, System z9, z10, z9, iSeries, pSeries, xSeries, zSeries, eServer, z/VM,
z/OS, i5/OS, S/390, OS/390, OS/400, AS/400, S/390 Parallel Enterprise Server, PowerVM, Power Architecture, POWER6+, POWER6, POWER5+, POWER5, POWER, OpenPower,
PowerPC, BatchPipes, BladeCenter, System Storage, GPFS, HACMP, RETAIN, DB2 Connect, RACF, Redbooks, OS/2, Parallel Sysplex, MVS/ESA, AIX, Intelligent Miner, WebSphere,
Netfinity, Tivoli and Informix are trademarks or registered trademarks of IBM Corporation.
●Linux is the registered trademark of Linus Torvalds in the U.S. and other countries.
●Oracle is a registered trademark of Oracle Corporation.
●HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C®, World Wide Web Consortium, Massachusetts Institute of Technology.
●Java is a registered trademark of Sun Microsystems, Inc.
●JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape.
●SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP Business ByDesign, and other SAP products and services mentioned herein as well as their respective logos are
trademarks or registered trademarks of SAP AG in Germany and other countries.
●Business Objects and the Business Objects logo, BusinessObjects, Crystal Reports, Crystal Decisions, Web Intelligence, Xcelsius, and other Business Objects products and services
mentioned herein as well as their respective logos are trademarks or registered trademarks of Business Objects S.A. in the United States and in other countries. Business Objects is
an SAP company.
●ERPsim is a registered copyright of ERPsim Labs, HEC Montreal.
●Other products mentioned in this presentation are trademarks of their respective owners.