Nesting and Floating. Nesting and Floating Elements To make our page content appear the way we want, and to make the best use of screen space, we can.

Slides:



Advertisements
Similar presentations
Cascading Style Sheets
Advertisements

Cascading Style Sheets
Chapter 3 – Designing your web pages Dr. Stephanos Mavromoustakos.
Session 4: CSS Positioning Fall 2006 LIS Web Team.
Advance CSS (Menu and Layout) Miftahul Huda. CSS Navigation MENU It's truly remarkable what can be achieved through CSS, especially with navigation menus.
Web Pages and Style Sheets Bert Wachsmuth. HTML versus XHTML XHTML is a stricter version of HTML: HTML + stricter rules = XHTML. XHTML Rule violations:
Floating Elements CS380.
Today’s objectives Site performance Padding, Margins, Borders
New Semantic Elements (Part 1). Semantics Explained The textbook definition of "semantics" is the study of the relationship between words and their meanings.
Technologies for web publishing Ing. Václav Freylich Lecture 6.
WEB DESIGN Multimedia and Web. Today’s Objectives  Quick review selector types  Layout and positioning.
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.
CSS (Cascading Style Sheets): How the web is styled Create Rules that specify how the content of an HTML Element should appear. CSS controls how your web.
Web Design Transparent Backgrounds. Why : Allow text to appear clearly above a graphic background image that still can be seen in the background. Without.
Web Development & Design Foundations with XHTML Chapter 6 Key Concepts.
Principles of Web Design 6 th Edition Chapter 7 – Page Layouts.
ITP 104.  While you can do things like this:  Better to use styles instead:
CSS The Definitive Guide Chapter 8.  Allows one to define borders for  paragraphs  headings  divs  anchors  images  and more.
Copyright © Terry Felke-Morris CSS Flow & Positioning 1 Copyright © Terry Felke-Morris.
 This presentation introduces the following: › 3 types of CSS › CSS syntax › CSS comments › CSS and color › The box model.
WRT235: Writing in Electronic Environments CSS Classes, IDs, divs.
Getting Started with HTML Please use speaker notes for additional information!
End User Computing More on HTML and CSS Sujana Jyothi Department of Computer Science
Tutorial #6 – Creating Fixed Width Layouts. Tutorial #5 Review – Box Model Every html element is surround by a box Content, Padding, Border, Margin Can.
Lecture 2 - HTML and CSS Review SFDV3011 – Advanced Web Development 1.
More CSS.
Copyright (c) 2004 Prentice-Hall. All rights reserved. 1 Committed to Shaping the Next Generation of IT Experts. Adding Graphical Elements Essentials for.
CSS October 19. Review of CSS CSS was designed to separate the content of HTML pages from their appearance We are primarily dealing with external style.
WRA HTML & CSS – BUILDING WEBPAGES. TODAY’S AGENDA Review: external stylesheets Review: transforming a list Intro: the object Intro: the.
Floating Elements CS The CSS float property (reference) 2 img.headericon { float: right; width: 130px; } CSS  removed from normal document flow;
Cascading Style Sheets (CSS). A style sheet is a document which describes the presentation semantics of a document written in a mark-up language such.
Layout with Styles Castro Chapter 11. Tables vs. CSS You can produce “liquid layouts” (layouts that stretch as the browser is resized) using tables or.
INTRODUCTORY Tutorial 5 Using CSS for Layout and Printing.
Web Design (12) CSS Introduction. Cascading Style Sheets - Defined CSS is the W3C standard for defining the presentation of documents written in HTML.
Web Development & Design Foundations with XHTML Chapter 6 Key Concepts.
CONTROLLING Page layout
Week 5.  Normal document flow  Affecting document flow with float and position properties using CSS  Using these properties to create layouts.
04 – CSS Informatics Department Parahyangan Catholic University.
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.
Ch 11 HTML and CSS Web Standards Solutions A Web Standardistas’ Approach.
Cascading Styles Sheets Positioning HTML elements.
HTML & CSS Contents: the different ways we can use to apply CSS to The HTML documents CSS Colors and Background CSS Fonts CSS Text CSS box model: padding,
NAVIGATION USING HTML TO SET UP THE BASIC STRUCTURE OF A NAV BAR.
Cascading Style Sheets for layout
More CSS.
CSS Box Model.
Web Development & Design Foundations with XHTML
CSS Box Model.
Nesting and Floating.
Fix the CSS syntax errors below
Nesting and Floating.
Float.
Advanced CSS BIS1523 – Lecture 20.
Nesting and Floating Elements
Cascading Style Sheets for layout
Cascading Style Sheets (Layout)
Creating a Baseline Grid
Creating Layouts Using CSS
Styles and the Box Model
Positioning.
MORE Cascading Style Sheets (The Positioning Model)
CSS Box Model.
More CSS.
Float.
New Semantic Elements (Part 1)
CSS Box Model.
Positioning.
Nesting and Floating.
Laying out Elements with CSS
CGS 3066: Web Programming and Design Fall 2019 CSS Part 2
Presentation transcript:

Nesting and Floating

Nesting and Floating Elements To make our page content appear the way we want, and to make the best use of screen space, we can nest and float XHTML elements. Nesting merely refers to placing elements inside other elements. As in real life, smaller boxes can be nested into larger boxes. We will use this frequently when laying out our web page. Floating in XHTML refers to causing elements, such as containers, to stay to the right or left side of the page, while other elements appear to their side, rather than just above and below. Let's build some examples of nesting and floating to make each of these concepts clearer.

Example: Nesting Elements Here we've placed a box (yellow) inside another box (blue), which is inside a parent box (green)..green { width: 300px; height: 300px; background-color: green; }.blue { width: 200px; height: 200px; background-color: blue; }.yellow { width: 100px; height: 100px; background-color: yellow; }... Notice the comments after the final two closing tags. These can help us later, especially if there's a lot of code between the opening and closing tags.

The Need for Floating Elements How do we use the remaining horizontal space on the page? A common method is to use the float property..green { width: 120px; height: 120px; background-color: green; }.blue { width: 120px; height: 120px; background-color: blue; }... Up to now, the elements we created in our documents were "stacked" vertically. Once we closed an element, the following element appeared directly below it:

The float Property Here we created a separate class to float an element to the left side of the page and applied the class to both div containers..green { width: 120px; height: 120px; background-color: green; }.floatleft { float: left; }.blue { width: 120px; height: 120px; background-color: blue; }... Although is the most commonly floated element, other XHTML elements - such as - can be floated on the page too.

Text with Floated Elements Text placed into the document will use the available space alongside the floated elements. When it runs out of space, it will wrap to the next empty line and continue normally.....floatleft { float: left; }... Paragraph 1 Paragraph 2 Paragraph 3 Paragraph 4 Paragraph 5 What if we want text (or other elements) to start at an empty line before all the floated space has been used? We can accomplish that with the clear property.

Clearing the Float....floatleft { float: left; }.clearfloat { clear: both; }... Paragraph 1 Paragraph 2 Paragraph 3 Paragraph 4 Paragraph 5 By applying the class containing the clear property, we are forcing subsequent content to appear below the floated elements. We could have applied the clearing class directly to the content element instead - in this case, the element for the third paragraph. But by using a separate to clear the float, our markup is a little easier to read and understand.

Floating Right and Left....floatleft { float: left; }.floatright { float: right; }.clearfloat { clear: both; }... Paragraph 1 Paragraph 2 Paragraph 3 Paragraph 4 Paragraph 5 We can also float elements to both the right and left sides of the page. Subsequent content will then fill the available space between. Let's see how this method can be used to create a basic web page layout.

Basic Page Layout Using Float.header { width: 600px; height: 100px; border: 1px solid orange; }.nav { width: 125px; height: 250px; border: 1px solid green; }.sidebar { width: 125px; height: 250px; border: 1px solid blue; }.main { height: 350px; }.footer { width: 600px; height: 50px; border: 1px solid red; } Header Nav Menu Sidebar Main Content Footer