SlideShare a Scribd company logo
1 of 28
Download to read offline
If you have not already done so,
                   please download Aptana:
                       http://aptana.com




       GDI Cincinnati
Intro to HTML/CSS: Class 3
      Erin M. Kidwell / @erinmkidwell/ erin@girldevelopit.com
  John David Back / @johndavidback / johndavidback@gmail.com
Agenda
Brief Review of Terms
        HTML: Tags, Elements, Attributes
        CSS: Selectors, Properties, Values
        Pseudo-classes
        CSS Box Model
HTML Tables for Page Layout
      One way to control a page's layout is to use an HTML table.
      We will walk through the HTML of a sample web page to
      see how a table is used to lay out the page.
CSS for Page Layout
Another, arguably better way to lay out a page is with CSS.
There are a number of CSS properties that you can leverage to have
more control over your web page's layout.
        The properties we will learn are:
                Position
                Float
                Clear
Review
• Presentation from Class 2:
  http://www.slideshare.net/emkidwell/gdi-
  intro-to-html-css-class-2-final

• Code from Class 2:
  https://gist.github.com/3147562
Brief review of terms: HTML
Tag
Tags are used to denote the start of an element or the end of an element
     A tag is either a start tag or an end tag. (i.e. </p>).
     Examples of tags: <strong>, <html>, </p>, </body>

Element
An element is the start tag + its content + the end tag:
     <p>This is some paragraph text</p>

Attribute
Attributes provide additional information about HTML elements. Attributes are
formatted like this: attr="value"
     The attribute always goes in the opening tag, never in the closing tag.
     In <a href="http://www.google.com">go to google</a>,
     href is the attribute.
class and id are both kinds of attributes that we have used extensively in previous
weeks.
     <div class="cupcakes"></div>
     <div id="username></div>
Reference: http://www.squidoo.com/HTML-Tutorial
Brief Review of Terms: HTML
Selector
A selector is what you call the CSS that gets matched up with an HTML element or attribute.

It's the thing that comes before the curly braces {} in your CSS class or inline styles in your HTML.

We have used three kinds of selectors in previous weeks:

1.    element-type selectors (a, body, html)
2.    class selectors
           • these are denoted by a "."
           • For example: .cupcakes, .menu, .header
           • styles you define in class selector (say, .cupcakes) will be applied to any HTML
              element with an attribute of class="cupcake"
3.     id selectors
           • these are denoted by a "#"
           • For example: #username, #password
           • styles you define in id selector (say, #pass) will be applied to the one (id tags should
              always be unique on a given web page) HTML element with an attribute of
              id="pass"
CSS Class Selectors: Example
Class Selectors being matched to HTML elements
Brief Review of Terms: CSS Properties
Properties
CSS properties are the actual styles you give to your HTML elements.
Examples: font-family, text-decoration, margin, color, background-color.




For a comprehensive listing of CSS properties, see:
http://htmldog.com/reference/cssproperties/
http://htmlhelp.com/reference/css/properties.html
Pseudo-classes: more CSS for links
Have you ever seen links on the web that change their format
when you hover your mouse over them?

For example:
    Links that do not have underlines, but become underlined
    once you hover your mouse over them?
    Links whose background colors change when you hover over
    them?

How is this accomplished?
Pseudo-classes: more CSS for links
Changing the format of a link when you hover over it is
accomplished by using pseudo-classes.

CSS pseudo-classes are used to add special effects to some
selectors.


  Syntax:                            Example:
  selector:pseudo-class              a:link
  {                                  {
    property:value;                    text-decoration: none;
  }                                  }
Pseudo-classes: more CSS for links

       a:link {color:#FF0000;} /* unvisited link */
       a:visited {color:#00FF00;} /* visited link */
       a:hover {color:#FF00FF;} /* mouse over link */
       a:active {color:#0000FF;} /* selected link */



Note: a:hover MUST come after a:link and a:visited in the CSS
definition in order to be effective!

Note: a:active MUST come after a:hover in the CSS definition in order
to be effective!
The CSS Box Model
The CSS box model is essentially a box that wraps around
HTML elements, and it consists of: margins, borders, padding,
and the actual content.

The box model allows us to place a border around elements
and space elements in relation to other elements. The image
below illustrates the box model:




Read more at: http://w3schools.com/CSS/css_boxmodel.asp
The CSS Box Model: Border
You can define your margins like this:border: [size]
[border type] [border color];


example: border: 10px solid black;

You can also define only one side with a border:
      border-top: 10px dashed blue;
      border-right: 10px dotted green;
      border-bottom: 10px solid #FFF;
      border-left: 10px solid orange;
The CSS Box Model: Margin Shortcuts
You can define your margins like this:
      margin-top: 10px;
      margin-right: 10px;
      margin-bottom: 10px;
      margin-left: 10px;
But they’re all 10px... isn’t there a faster way to
type this out? YES!

margin: 10px;
The CSS Box Model: Margin Shortcuts
Long way:
     margin-top: 10px;
     margin-right: 10px;
     margin-bottom: 10px;
     margin-left: 10px;
Shortcut ways:
     margin: [all];
     margin: [top] [right] [bottom] [left];
     margin: [top & bottom] [left & right];
The CSS Box Model: Paddling Shortcuts
Long way:
     padding-top: 10px;
     padding-right: 10px;
     padding-bottom: 10px;
     padding-left: 10px;
Shortcut ways:
     padding: [all];
     padding: [top] [right] [bottom] [left];
     padding: [top & bottom] [left & right];
HTML tables for Page Layouts
There is more than one way to structurally layout a web
page.

Let's say we wanted to build a page with 3 main
columns, a header, and a footer. There are a few
approaches we could take:
• Lay out the columns, header and footer using an
  html table
• Lay out the columns, header and footer using CSS
  properties: position, float, margin, padding and
  clear

First, let's try the first approach, using a table. We will
still use some CSS to style the font, the links, colors, etc.
HTML tables for Page Layouts:
Adding more CSS Styling
We can do everything we just did with tables using CSS properties
instead of these html tables.


Whether you use tables to lay out your page, or CSS, is really a matter
of personal preference.


It's become more popular/more accepted to use CSS positioning
instead of tables, but if you like tables, you should use them.


Our goal is to teach you multiple ways to reach a single goal.
Exercise: page layout w/ HTML table
See handout:
Creating a layout
with HTML tables

Follow
screenshot for
live code
CSS Properties for Page Layouts

 We are going to use the following CSS properties to
 make a more flexible layout:
         Position
               o Static
               o Fixed
               o Relative
               o Absolute
         Float
         Clear
 Before we put it into practice, we are going to
 review what each of these properties does and how
 they work.
CSS Position: Static & Fixed
Static Positioning
HTML elements are positioned static by default; there is no need to set them to
static. Static positioned elements are positioned according to the normal flow of a
page. They ignore anything specified by top, bottom, right or left properties.


Fixed Positioning
An element with fixed position is positioned relative to the browser window.
It will not move even if the window is scrolled--it will always stay in the same, fixed
location on the screen.


See this in action:
    http://www.w3schools.com/Css/tryit.asp?filename=trycss_position_fixed
    The file fixedPosExample.html included in the class3.zip file


References: http://www.barelyfitz.com/screencast/html-training/css/positioning/
CSS Position: Relative
Relative Positioning
A relative positioned element is positioned relative to its
normal position. You use the properties top, right,
bottom and left to position an element.

For example, position:relative; left:-20px; will set an
element 20 pixels to the left of its normal position; it
subtracts 20 pixels from its normal left position.

Reference: http://www.w3schools.com/Css/tryit.asp?filename=
trycss_position_relative
CSS Position: Absolute
Absolute Positioning
The position of an absolutely positioned element is determined by its
offset values in the properties: top, right, bottom and left.

But, unlike relative positioning, where the offsets are measured
relative to its normal position, an absolutely positioned element is
offset from its "container block."

   “Container block"? It's the first parent element that has a position other
   than static. If no such element is found, the containing block is <html>.

Absolutely positioned elements can overlap other elements. Unlike a
Fixed element, an absolute element will move as you scroll away from
it.
CSS Float
CSS float: an element can be pushed to the left or right, allowing other
elements to wrap around it. When an element is set to float, text and
other content will flow around the floated element.

The float property specifies whether or not an element should float. It
also specifies which direction it should float (left, right).
Example:
            .alignLeft
            {
               float: left;
            }
This is most commonly used with images, in order to align them left or
right so text flows around an image. It is also useful when working with
layouts.

Source: http://www.w3schools.com/Css/css_float.asp
CSS Float
If you want to read more after class, here are some great
tutorials on using floats to create a layout:

  http://css.maxdesign.com.au/floatutorial/tutorial0916.htm

  http://www.w3schools.com/css/tryit.asp?filename=trycss_flo
  at6

  http://articles.techrepublic.com.com/5100-10878_11-
  5160911.html
CSS Clear
The clear property specifies which sides of an
element where other floating elements are not
allowed.

Source:
http://www.w3schools.com/cssref/pr_class_clear.a
sp
Refresher: the div tag
The <div> tag defines a division or a section in an
HTML document. It is often used to group elements
to format them with styles. It's a really handy way
to add a certain style to a whole group of elements.


Reference: http://w3schools.com/tags/tag_div.asp
Exercise: page layout w/ CSS absolute
positioning
See handout:
Creating a layout
with CSS:
Absolute
Positioning

Follow
screenshot for
live code
Further Reading
General Web Development Tutorials:
http://www.webmonkey.com/tutorials/
http://www.webmonkey.com/cheat-sheets/
http://www.webmonkey.com/2010/02/color_charts/
http://htmldog.com/guides/


Positioning with CSS:
The Official CSS Guide: http://www.w3schools.com/Css/css_positioning.asp
CSS Positioning in 10 Steps: http://www.barelyfitz.com/screencast/html-
training/css/positioning/
http://www.brainjar.com/css/positioning/

More Related Content

Viewers also liked

infecções de pele e anexos
infecções de pele e anexos infecções de pele e anexos
infecções de pele e anexos Anna de Melo
 
Strategic sourcing change 2010
Strategic sourcing change 2010Strategic sourcing change 2010
Strategic sourcing change 2010derupert
 
Class 3 Intro to HTML/ CSS Gdi cincinnati create a table layout with html (...
Class 3 Intro to HTML/ CSS Gdi cincinnati   create a table layout with html (...Class 3 Intro to HTML/ CSS Gdi cincinnati   create a table layout with html (...
Class 3 Intro to HTML/ CSS Gdi cincinnati create a table layout with html (...Erin M. Kidwell
 
SNS와 Privacy
SNS와 PrivacySNS와 Privacy
SNS와 Privacy우섭 이
 
증강현실과 가상현실
증강현실과 가상현실증강현실과 가상현실
증강현실과 가상현실우섭 이
 
Class 1 handout (2) html exercises
Class 1 handout (2) html exercisesClass 1 handout (2) html exercises
Class 1 handout (2) html exercisesErin M. Kidwell
 
Class 2 handout (1) adding a css stylesheet
Class 2 handout (1) adding a css stylesheetClass 2 handout (1) adding a css stylesheet
Class 2 handout (1) adding a css stylesheetErin M. Kidwell
 
Realize mais com HTML 5 e CSS 3 - 16 EDTED - RJ
Realize mais com HTML 5 e CSS 3 - 16 EDTED - RJRealize mais com HTML 5 e CSS 3 - 16 EDTED - RJ
Realize mais com HTML 5 e CSS 3 - 16 EDTED - RJLeonardo Balter
 
Rangka kursus pembangunan aplikasi android kuiscell khirulnizam
Rangka kursus pembangunan aplikasi android kuiscell   khirulnizamRangka kursus pembangunan aplikasi android kuiscell   khirulnizam
Rangka kursus pembangunan aplikasi android kuiscell khirulnizamKhirulnizam Abd Rahman
 
Write quicker HTML5 and CSS 3; productivity hacks with emmet
Write quicker HTML5 and CSS 3; productivity hacks with emmetWrite quicker HTML5 and CSS 3; productivity hacks with emmet
Write quicker HTML5 and CSS 3; productivity hacks with emmetayman diab
 
CSS 3
CSS 3CSS 3
CSS 3Keyup
 

Viewers also liked (16)

infecções de pele e anexos
infecções de pele e anexos infecções de pele e anexos
infecções de pele e anexos
 
Strategic sourcing change 2010
Strategic sourcing change 2010Strategic sourcing change 2010
Strategic sourcing change 2010
 
Class 3 Intro to HTML/ CSS Gdi cincinnati create a table layout with html (...
Class 3 Intro to HTML/ CSS Gdi cincinnati   create a table layout with html (...Class 3 Intro to HTML/ CSS Gdi cincinnati   create a table layout with html (...
Class 3 Intro to HTML/ CSS Gdi cincinnati create a table layout with html (...
 
Cloud
CloudCloud
Cloud
 
SNS와 Privacy
SNS와 PrivacySNS와 Privacy
SNS와 Privacy
 
증강현실과 가상현실
증강현실과 가상현실증강현실과 가상현실
증강현실과 가상현실
 
Class 1 handout (2) html exercises
Class 1 handout (2) html exercisesClass 1 handout (2) html exercises
Class 1 handout (2) html exercises
 
Class 2 handout (1) adding a css stylesheet
Class 2 handout (1) adding a css stylesheetClass 2 handout (1) adding a css stylesheet
Class 2 handout (1) adding a css stylesheet
 
Realize mais com HTML 5 e CSS 3 - 16 EDTED - RJ
Realize mais com HTML 5 e CSS 3 - 16 EDTED - RJRealize mais com HTML 5 e CSS 3 - 16 EDTED - RJ
Realize mais com HTML 5 e CSS 3 - 16 EDTED - RJ
 
Css 3
Css 3Css 3
Css 3
 
Lecture2 CSS 3
Lecture2   CSS 3Lecture2   CSS 3
Lecture2 CSS 3
 
Rangka kursus pembangunan aplikasi android kuiscell khirulnizam
Rangka kursus pembangunan aplikasi android kuiscell   khirulnizamRangka kursus pembangunan aplikasi android kuiscell   khirulnizam
Rangka kursus pembangunan aplikasi android kuiscell khirulnizam
 
The beginners guide to web hosting
The beginners guide to web hostingThe beginners guide to web hosting
The beginners guide to web hosting
 
Write quicker HTML5 and CSS 3; productivity hacks with emmet
Write quicker HTML5 and CSS 3; productivity hacks with emmetWrite quicker HTML5 and CSS 3; productivity hacks with emmet
Write quicker HTML5 and CSS 3; productivity hacks with emmet
 
CSS 3
CSS 3CSS 3
CSS 3
 
Css 3 cheat sheet
Css 3 cheat sheetCss 3 cheat sheet
Css 3 cheat sheet
 

Recently uploaded

Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 

Recently uploaded (20)

Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 

Girl Develop It Cincinnati: Intro to HTML/CSS Class 3

  • 1. If you have not already done so, please download Aptana: http://aptana.com GDI Cincinnati Intro to HTML/CSS: Class 3 Erin M. Kidwell / @erinmkidwell/ erin@girldevelopit.com John David Back / @johndavidback / johndavidback@gmail.com
  • 2. Agenda Brief Review of Terms HTML: Tags, Elements, Attributes CSS: Selectors, Properties, Values Pseudo-classes CSS Box Model HTML Tables for Page Layout One way to control a page's layout is to use an HTML table. We will walk through the HTML of a sample web page to see how a table is used to lay out the page. CSS for Page Layout Another, arguably better way to lay out a page is with CSS. There are a number of CSS properties that you can leverage to have more control over your web page's layout. The properties we will learn are: Position Float Clear
  • 3. Review • Presentation from Class 2: http://www.slideshare.net/emkidwell/gdi- intro-to-html-css-class-2-final • Code from Class 2: https://gist.github.com/3147562
  • 4. Brief review of terms: HTML Tag Tags are used to denote the start of an element or the end of an element A tag is either a start tag or an end tag. (i.e. </p>). Examples of tags: <strong>, <html>, </p>, </body> Element An element is the start tag + its content + the end tag: <p>This is some paragraph text</p> Attribute Attributes provide additional information about HTML elements. Attributes are formatted like this: attr="value" The attribute always goes in the opening tag, never in the closing tag. In <a href="http://www.google.com">go to google</a>, href is the attribute. class and id are both kinds of attributes that we have used extensively in previous weeks. <div class="cupcakes"></div> <div id="username></div> Reference: http://www.squidoo.com/HTML-Tutorial
  • 5. Brief Review of Terms: HTML Selector A selector is what you call the CSS that gets matched up with an HTML element or attribute. It's the thing that comes before the curly braces {} in your CSS class or inline styles in your HTML. We have used three kinds of selectors in previous weeks: 1. element-type selectors (a, body, html) 2. class selectors • these are denoted by a "." • For example: .cupcakes, .menu, .header • styles you define in class selector (say, .cupcakes) will be applied to any HTML element with an attribute of class="cupcake" 3. id selectors • these are denoted by a "#" • For example: #username, #password • styles you define in id selector (say, #pass) will be applied to the one (id tags should always be unique on a given web page) HTML element with an attribute of id="pass"
  • 6. CSS Class Selectors: Example Class Selectors being matched to HTML elements
  • 7. Brief Review of Terms: CSS Properties Properties CSS properties are the actual styles you give to your HTML elements. Examples: font-family, text-decoration, margin, color, background-color. For a comprehensive listing of CSS properties, see: http://htmldog.com/reference/cssproperties/ http://htmlhelp.com/reference/css/properties.html
  • 8. Pseudo-classes: more CSS for links Have you ever seen links on the web that change their format when you hover your mouse over them? For example: Links that do not have underlines, but become underlined once you hover your mouse over them? Links whose background colors change when you hover over them? How is this accomplished?
  • 9. Pseudo-classes: more CSS for links Changing the format of a link when you hover over it is accomplished by using pseudo-classes. CSS pseudo-classes are used to add special effects to some selectors. Syntax: Example: selector:pseudo-class a:link { { property:value; text-decoration: none; } }
  • 10. Pseudo-classes: more CSS for links a:link {color:#FF0000;} /* unvisited link */ a:visited {color:#00FF00;} /* visited link */ a:hover {color:#FF00FF;} /* mouse over link */ a:active {color:#0000FF;} /* selected link */ Note: a:hover MUST come after a:link and a:visited in the CSS definition in order to be effective! Note: a:active MUST come after a:hover in the CSS definition in order to be effective!
  • 11. The CSS Box Model The CSS box model is essentially a box that wraps around HTML elements, and it consists of: margins, borders, padding, and the actual content. The box model allows us to place a border around elements and space elements in relation to other elements. The image below illustrates the box model: Read more at: http://w3schools.com/CSS/css_boxmodel.asp
  • 12. The CSS Box Model: Border You can define your margins like this:border: [size] [border type] [border color]; example: border: 10px solid black; You can also define only one side with a border: border-top: 10px dashed blue; border-right: 10px dotted green; border-bottom: 10px solid #FFF; border-left: 10px solid orange;
  • 13. The CSS Box Model: Margin Shortcuts You can define your margins like this: margin-top: 10px; margin-right: 10px; margin-bottom: 10px; margin-left: 10px; But they’re all 10px... isn’t there a faster way to type this out? YES! margin: 10px;
  • 14. The CSS Box Model: Margin Shortcuts Long way: margin-top: 10px; margin-right: 10px; margin-bottom: 10px; margin-left: 10px; Shortcut ways: margin: [all]; margin: [top] [right] [bottom] [left]; margin: [top & bottom] [left & right];
  • 15. The CSS Box Model: Paddling Shortcuts Long way: padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; Shortcut ways: padding: [all]; padding: [top] [right] [bottom] [left]; padding: [top & bottom] [left & right];
  • 16. HTML tables for Page Layouts There is more than one way to structurally layout a web page. Let's say we wanted to build a page with 3 main columns, a header, and a footer. There are a few approaches we could take: • Lay out the columns, header and footer using an html table • Lay out the columns, header and footer using CSS properties: position, float, margin, padding and clear First, let's try the first approach, using a table. We will still use some CSS to style the font, the links, colors, etc.
  • 17. HTML tables for Page Layouts: Adding more CSS Styling We can do everything we just did with tables using CSS properties instead of these html tables. Whether you use tables to lay out your page, or CSS, is really a matter of personal preference. It's become more popular/more accepted to use CSS positioning instead of tables, but if you like tables, you should use them. Our goal is to teach you multiple ways to reach a single goal.
  • 18. Exercise: page layout w/ HTML table See handout: Creating a layout with HTML tables Follow screenshot for live code
  • 19. CSS Properties for Page Layouts We are going to use the following CSS properties to make a more flexible layout: Position o Static o Fixed o Relative o Absolute Float Clear Before we put it into practice, we are going to review what each of these properties does and how they work.
  • 20. CSS Position: Static & Fixed Static Positioning HTML elements are positioned static by default; there is no need to set them to static. Static positioned elements are positioned according to the normal flow of a page. They ignore anything specified by top, bottom, right or left properties. Fixed Positioning An element with fixed position is positioned relative to the browser window. It will not move even if the window is scrolled--it will always stay in the same, fixed location on the screen. See this in action: http://www.w3schools.com/Css/tryit.asp?filename=trycss_position_fixed The file fixedPosExample.html included in the class3.zip file References: http://www.barelyfitz.com/screencast/html-training/css/positioning/
  • 21. CSS Position: Relative Relative Positioning A relative positioned element is positioned relative to its normal position. You use the properties top, right, bottom and left to position an element. For example, position:relative; left:-20px; will set an element 20 pixels to the left of its normal position; it subtracts 20 pixels from its normal left position. Reference: http://www.w3schools.com/Css/tryit.asp?filename= trycss_position_relative
  • 22. CSS Position: Absolute Absolute Positioning The position of an absolutely positioned element is determined by its offset values in the properties: top, right, bottom and left. But, unlike relative positioning, where the offsets are measured relative to its normal position, an absolutely positioned element is offset from its "container block." “Container block"? It's the first parent element that has a position other than static. If no such element is found, the containing block is <html>. Absolutely positioned elements can overlap other elements. Unlike a Fixed element, an absolute element will move as you scroll away from it.
  • 23. CSS Float CSS float: an element can be pushed to the left or right, allowing other elements to wrap around it. When an element is set to float, text and other content will flow around the floated element. The float property specifies whether or not an element should float. It also specifies which direction it should float (left, right). Example: .alignLeft { float: left; } This is most commonly used with images, in order to align them left or right so text flows around an image. It is also useful when working with layouts. Source: http://www.w3schools.com/Css/css_float.asp
  • 24. CSS Float If you want to read more after class, here are some great tutorials on using floats to create a layout: http://css.maxdesign.com.au/floatutorial/tutorial0916.htm http://www.w3schools.com/css/tryit.asp?filename=trycss_flo at6 http://articles.techrepublic.com.com/5100-10878_11- 5160911.html
  • 25. CSS Clear The clear property specifies which sides of an element where other floating elements are not allowed. Source: http://www.w3schools.com/cssref/pr_class_clear.a sp
  • 26. Refresher: the div tag The <div> tag defines a division or a section in an HTML document. It is often used to group elements to format them with styles. It's a really handy way to add a certain style to a whole group of elements. Reference: http://w3schools.com/tags/tag_div.asp
  • 27. Exercise: page layout w/ CSS absolute positioning See handout: Creating a layout with CSS: Absolute Positioning Follow screenshot for live code
  • 28. Further Reading General Web Development Tutorials: http://www.webmonkey.com/tutorials/ http://www.webmonkey.com/cheat-sheets/ http://www.webmonkey.com/2010/02/color_charts/ http://htmldog.com/guides/ Positioning with CSS: The Official CSS Guide: http://www.w3schools.com/Css/css_positioning.asp CSS Positioning in 10 Steps: http://www.barelyfitz.com/screencast/html- training/css/positioning/ http://www.brainjar.com/css/positioning/