SlideShare une entreprise Scribd logo
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/

Contenu connexe

En vedette

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
 

En vedette (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
 

Dernier

Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...CzechDreamin
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀DianaGray10
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024Stephanie Beckett
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupCatarinaPereira64715
 
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCustom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCzechDreamin
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeCzechDreamin
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastUXDXConf
 
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Julian Hyde
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor TurskyiFwdays
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityScyllaDB
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
 
Enterprise Security Monitoring, And Log Management.
Enterprise Security Monitoring, And Log Management.Enterprise Security Monitoring, And Log Management.
Enterprise Security Monitoring, And Log Management.Boni Yeamin
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekCzechDreamin
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaCzechDreamin
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka DoktorováCzechDreamin
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxJennifer Lim
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxDavid Michel
 
Strategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering TeamsStrategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering TeamsUXDXConf
 

Dernier (20)

Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCustom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at Comcast
 
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Enterprise Security Monitoring, And Log Management.
Enterprise Security Monitoring, And Log Management.Enterprise Security Monitoring, And Log Management.
Enterprise Security Monitoring, And Log Management.
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
Strategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering TeamsStrategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering Teams
 

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/