Today’s objectives Site performance Padding, Margins, Borders

Slides:



Advertisements
Similar presentations
Client-Side Internet and Web Programming
Advertisements

Cascading Style Sheets Color and Background Controls Border and Margin Controls (Boxes)
9-May-15 More CSS. 2 A different emphasis CSS is the same for XML as it is for HTML and XHTML, but-- XML contains no display information If you want your.
Week 9 Using the Box Properties. 9-2 The CSS Visual Formatting Model Describes how the element content boxes should be displayed by the browser –Based.
Tutorial 4: Creating page layout with css
Tutorial 5 Working with the Box Model. XP Objectives Understand the box model Create padding, margins, and borders Wrap text around an image Float a block-level.
CSS: Class 1 Background Images, Controlling Position of Background Images, Add Padding to Page Elements, Add Borders to Elements on a Page.
 2003 Prentice Hall, Inc. All rights reserved. Chapter 6 - Cascading Style Sheets™ (CSS) Outline 6.1 Introduction 6.2 Inline Styles 6.3 Embedded Style.
Text Properties, Line Box, CSS. Text Properties Properties related to the display of text. Text-align : left, right, center I like FSU!
CSS, cont. October 12, Unit 4. Creating a Sidebar We know how to create a sidebar –Use the float property div#sidebar{ float: left; } Item1 Item2 Item3.
Cascading Style Sheets Part 3 Fall, 2007 Modified by Linda Kenney Nov. 12, 2007.
An Introduction to Cascading Style Sheets CSS Layout, and the CSS Box Model Nick Foxall SM5312 week 9: CSS Layout.
MORE Cascading Style Sheets (The Positioning Model)
14-Jul-15 CSS Applications to XML. 2 A different emphasis CSS is the same for XML as it is for HTML, but-- HTML already does a pretty good job of layout.
Selectors thru Borders. CSS – Cascading Style Sheets – is a way to style HTML HTML is the content base of a web page CSS provides the presentation qualities.
Cascading Style Sheets – Block Level. Block Level Style So far we have done text-level CSS With block level CSS, we used a generic container tag Similarly.
Slide 1 of 83 Table Borders To specify table borders in CSS, use the border property. The example below specifies a black border for table, th, and td.
Working with Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of a document.
Dreamweaver -- CSS. Dreamweaver -- MX New icons are added in MX Most of the features commonly used in web design, and are same as FrontPage. New feature.
ITP 104.  While you can do things like this:  Better to use styles instead:
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 6 Key Concepts 1 Copyright © Terry Felke-Morris.
The Missing Manual MARGINS, PADDING, & BORDERS—CHAPTER 7.
CSS The Definitive Guide Chapter 8.  Allows one to define borders for  paragraphs  headings  divs  anchors  images  and more.
CIS 1315 – Web Development for Educators CIS 1315 HTML Tutorials 3 & 4: Working With CSS.
Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border 
Chcslonline.org Text –wrapping around Images. chcslonline.org To wrap text around an image, lets set up a style in our style sheet. open a new notepad.
INTRODUCTORY Tutorial 4 Exploring Graphic Elements and Images.
Floating Elements CS The CSS float property (reference) 2 img.headericon { float: right; width: 130px; } CSS  removed from normal document flow;
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 6 Key Concepts 1 Copyright © Terry Felke-Morris.
Cascading Style Sheets Chapters 5-6 Color and Background Controls Border and Margin Controls.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 6 Key Concepts 1 Copyright © Terry Felke-Morris.
Cascading Style Sheets Part 3 Spring, 2008 Modified by Linda Kenney April 21, 2008.
Web Foundations THURSDAY, OCTOBER 3, 2013 LECTURE 6: CSS CONTINUED.
>> The “Box” Model. Pre-requisite Create a new project in Netbeans called Week5 Create a new html file and name it box.html Create a new css file and.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 6 - Cascading Style Sheets™ (CSS) Outline 6.1 Introduction 6.2 Inline Styles 6.3 Embedded Style.
Week 8 – Part 2 Page Layout Basics Key Concepts 1.
1 CS428 Web Engineering Lecture 08 Border, Margin, Padding … (CSS - III)
CSS Fun damentals The Document Hierarchy Element Relationships The Box Model.
CSS Layout Cascading Style Sheets. Lesson Overview  In this lesson, you will learn:  CSS Box Model  CSS properties for border  CSS properties for.
CIS234A Lecture 5 Instructor Greg D’Andrea. Font Styles Review Font-Family: generic family, font family Font-Size: em, pt, px, %, mm, cm, in Font-Style:
11/12/2015 Box Model Reed Crouch. 11/12/2015  HTML elements can be considered as boxes. In CSS, the term "box model" is used when referring to layout.
3.2 Cascading Style Sheets. 2 Positioning Elements Normally, elements are laid out on the page in the order that they are defined in the XHTML document.
CONTROLLING Page layout
Extra-simplified.  Only truly happen when the CSS and HTML are defined as separate files (external style sheet) Introduction The main idea of CSS is.
5 th ed: Chapter 4 4 th ed: Chapter 5 SY306 Web and Databases for Cyber Operations SlideSet #5: Advanced CSS.
CSS - Quiz #3 Lecture Code:
Department of Computer Science, Florida State University CGS 3066: Web Programming and Design Spring 2016 CSS Positioning 1.
Coding with HTML {. THE BASICS { What is HTML and how can you use it to make websites?
HTML and Dreamweaver November 11th. Agenda Box Model Displaying and positioning elements – Padding – Margin – Float – Display – Position HTML Demo.
CIS234A Lecture 6 Instructor Greg D’Andrea. Span and Div The span and div elements are a generic means by which we can add structure to documents. The.
CSS Box Model. What is the Box Model? Each XHTML element appearing on our page takes up a "box" or "container" of space. Each box size is affected not.
Tutorial #5 Working with the Box Model. Tutorial #4 Review - CSS Create a homework page Final Project Discussion Exam on Blackboard Styling Lists (List-style-type,
Chapter 7.  Change body and link styles  Create a drop-down menu  Change color and font styles in the menu  Create a pop-up effect using CSS  Utilize.
CS 120: Introduction to Web Programming Lecture 10: Extra Features and Website Design Part 1 Tarik Booker CS 120 California State University, Los Angeles.
Chapter 4 and 5. Objectives Introduce markup: elements and attributes How browsers interpret HTML documents Basic structure of HTML document What do style.
Unit 3 - Review. Topics 1. Tag, Attribute, Value 2. CSS Rule Syntax + link 3. Categories of Selectors 4. Inline vs Block Tags 5. CSS Layout 6. CSS Box.
Cascading Style Sheets Boxes
Semester - Review.
CSS Layouts: Grouping Elements
>> The “Box” Model
CSS Applications to XML 19-Sep-18.
Objectives Create a reset style sheet Explore page layout designs
Cascading Style Sheets
CSS Borders and Margins.
Second CSS Lecture Applications to XML
More CSS 22-Feb-19.
Floating and Positioning
CSS Boxes CS 1150 Fall 2016.
CSS Applications to XML 20-May-19.
CSS Applications to XML 3-Jul-19.
Presentation transcript:

Today’s objectives Site performance Padding, Margins, Borders Practice layout

The Need for Speed (Site Performance) Performance of your site- limiting file sizes and reducing the number of requests to the server. Optimizing images so they are the smallest file size possible without sacrificing Quality Minimize HTML and CSS documents by removing extra character spaces and line returns.

The Need for Speed (Site Performance) Keep JavaScript to a minimum. Add scripts in parallel with other page assets. Don’t load unnecessary assets (such as images, scripts, or JavaScript libraries). Reduce the number of times the browser makes requests of the server (known as HTTP requests). Every trip to the server in the form of an HTTP request takes a few milliseconds, and those milliseconds can really add up. All those little Twitter

Padding, Margins, and Borders CSS

Padding, Margins, and Borders Web browsers treat all html elements as boxes. A tag is a box with content inside (text, graphic or other html element). <div></div> <ul></ul <li></li>

Padding, Margins, and Borders Other Element TOP MARGIN TOP BORDER TOP PADDING HELLO WORLD! LEFT PADDING LEFT BORDER RIGHT PADDING RIGHT BORDER Other Element LEFT MARGIN RIGHT MARGIN Other Element BOTTOM PADDING BOTTOM BORDER BOTTOM MARGIN Other Element

Padding, Margins, and Borders Padding: space between the content and the content’s border. Separates content from its border. TOP BORDER PADDING PADDING HELLO WORLD! PADDING PADDING

Padding, Margins, and Borders Border: line drawn around each edge of the box. Can be four sides, on any single side, or any combination of sides. HELLO WORLD!

Padding, Margins, and Borders Border style values: none: Defines no border dotted: Defines a dotted border dashed: Defines a dashed border solid: Defines a solid border double: Defines two borders. groove: Defines a 3D grooved border. ridge: Defines a 3D ridged border. inset: Defines a 3D inset border. outset: Defines a 3D outset border. HELLO WORLD!

Padding, Margins, and Borders Background-color: fills space inside border, including padding area. Margin separates one element from another.

Margins Other Element TOP MARGIN LEFT MARGIN RIGHT MARGIN HELLO WORLD! Other Element LEFT MARGIN RIGHT MARGIN Other Element BOTTOM MARGIN Other Element

Padding, Margins, and Borders Padding adds space between the content, and the border and keeps the content from appearing cramped inside the box. Margins add white space (gutter) between elements giving the overall look of the page a lighter appearance.

Padding, Margins, and Borders Four properties control padding: padding-top, padding-right, padding-bottom, and padding-left. Four properties control margin edges: margin-top, margin-right, margin-bottom, and margin-left. padding-top : 5px; padding-right : 5px; padding-bottom : 5px; padding-left : 5px; margin-top : 5px; margin-right : 5px; margin-bottom : 5px; margin-left : 5px; padding: 10px 5px 5px 10px; margin: 0 10px 10px 20px;

Padding, Margins, and Borders The order of the four values is: top, right, bottom, and left. TRouBLe - Top, Right, Bottom, and Left. padding: 10px 5px 5px 10px; margin: 0 10px 10px 20px; Shortcut padding-top : 5px; padding-right : 5px; padding-bottom : 5px; padding-left : 5px; margin-top : 5px; margin-right : 5px; margin-bottom : 5px; margin-left : 5px;

Padding, Margins, and Borders When value is 0, don’t need measurement unit (e.g., em, px). Use margin: 0; instead of margin: 0px;. When same value for all four sides, use a single value margin: 5px;

Padding, Margins, and Borders When same value for both top and bottom and another value for left and right, use two values: margin : 0 2em; Sets top and bottom margins to 0; left and right margins to 2ems.

Collapsing margins - two margins actually become one. Bottom margin of unordered list = 30 pixels. Top margin of a following paragraph = 20 pixels. You think: 30px + 20px = 50px spacing BUT browser uses the largest margin (30px) You can use padding to get around this issue.

Collapsing margins - two margins actually become one. Browser does NOT add two vertical margins values but applies larger of the two margins. Item1 Item2 Items 3 – margin bottom 30px 30px not 50px Paragraph – margin top 20 px

Collapsing margins - two margins actually become one. Add box <div> titled SPECIALS and then add a 25px to top and bottom margins to separate box from the heading above and paragraph below. Add a heading <h1> inside SPECIALS and put 20px to top and bottom margins of <h1>. Does this add 20 pixels of space between the <div class=“SPECIALS> and <h1>? NO! Margin appears above the div.

Collapsing margins All margins = 0 <h1>Topic A</h1> <div class=“special"> <h1>Topic B</h1> <p>Students learn precepts of Web design that…</p> </div> <p>Students will be…</p> <DIV class=“SPECIALS”> All margins = 0

Collapsing margins Add 20px top & bottom margin to SPECIALS DIV – <h1>Topic A</h1> <div class=“special"> <h1>Topic B</h1> <p>Students learn precepts of Web design that…</p> </div> <p>Students will be…</p> Add 20px top & bottom margin to SPECIALS DIV – makes sense!

Collapsing margins <h1>Topic A</h1> <div class=“special"> <h1>Topic B</h1> <p>Students learn precepts of Web design that…</p> </div> <p>Students will be…</p> Add 40px top & bottom margin to Topic B heading. CONFUSING! Top margin NOT added above “Topic B” but added above the DIV below Topic A.

Collapsing margins Border added to SPECIALS DIV <h1>Topic A</h1> <div class=“special"> <h1>Topic B</h1> <p>Students learn precepts of Web design that…</p> </div> <p>Students will be…</p> Border added to SPECIALS DIV Top margin IS now added about “Topic B” and NOT added above the DIV.

Collapsing margins All margins = 0; No border SPECIALS DIV: 20px Top|bottom; No Border Special DIV Topic B: 40px Top|bottom; No border Border added to Special DIV H1 Topic B

Collapsing margins Getting around this problem: Add padding <div> SPECIALS or Add border Padding and border sit between the two margins, the margins no longer touch, and the <h1> margin appears within the <div>

Collapsing margins Horizontal (left and right) margins and margins between floating elements don’t collapse in this way. Absolutely and relatively positioned elements don’t collapse either.

Block boxes and inline boxes Although web browsers treat every tag as a kind of box, not all boxes are alike. Block boxes and inline boxes—that correspond to the two types of tags—block-level and inline tags.

Block boxes and inline boxes A block-level tag creates a break before and after it. <p> <h1>,<div>, etc. Inline tags don’t create a break before or after them. <span>, <em>, <strong>

Block and inline elements Top or bottom margins and padding do NOT increased or decrease height of inline elements. Make a in-level element act like an Block element: Must use display : block; em { padding-top: 20px; padding-bottom: 20px; display: block; }

Block and inline elements Make a block-level element act like an inline element: display: inline; ul li { display: inline; } This is useful for setting navigation items

CSS – Clark video