CSS Box Model <span> & <div>

Slides:



Advertisements
Similar presentations
HTML and CSS. HTML Hyper Text Markup Language Tells browser how to display text and images.
Advertisements

CSS Cascading Style Sheets. Objectives Using Inline Styles Working with Selectors Using Embedded Styles Using an External Style Sheet Applying a Style.
CSS Styling CSS Box Model & CS110: Computer Science and the Internet.
Cascading Style Sheets
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 6 Key Concepts 1 Copyright © Terry Felke-Morris.
Today CSS HTML A project.
CSS. Intro to CSS Cascading Style Sheets – styles and enhances appearance of webpage.css extension.
- Relative and Absolute URLs -HTML and CSS Validation -Caches -3 ways of adding style -Firebug CS110: Computer Science and the Internet.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 6 Key Concepts 1 Copyright © Terry Felke-Morris.
Slide 1 CMPS 211 Internet Programming Spring 2008 Dynamic Effects with Styles Chapter 12 2/6/08.
Very quick intro HTML and CSS. Sample html A Web Title.
CHAPTER 8 ADVANCED CSS. LEARNING OBJECTIVES Assign formatting styles to a CSS class definition Use a tag’s class attribute to apply the styles defined.
Cascading Style Sheets. CSS stands for Cascading Style Sheets and is a simple styling language which allows attaching style to HTML elements. CSS is a.
Web Development & Design Foundations with XHTML Chapter 7 Key Concepts.
Cascading Style Sheets Basics. Why use Cascading Style Sheets? Allows you to set up a series of rules for all pages in a site. The series may be changed.
Cascading Style Sheets By: Valerie Kuna. What are Cascading Style Sheets? Cascading Style Sheets (CSS) are a standard for specifying the presentation.
Advance CSS (Menu and Layout) Miftahul Huda. CSS Navigation MENU It's truly remarkable what can be achieved through CSS, especially with navigation menus.
CSS BASICS. CSS Rules Components of a CSS Rule  Selector: Part of the rule that targets an element to be styled  Declaration: Two or more parts: a.
1 Pengantar Teknologi Internet W03: CSS Cascading Style Sheets.
Cascading Style Sheet CSS CS1520 Ali Alanjawi. 2 TA Information Ali Alanjawi Homepage: Office:
Recognizing the Benefits of Using CSS 1. The Evolution of CSS CSS was developed to standardize display information CSS was slow to be supported by browsers.
1 Dreamweaver CS5 intermediate class by Cookie Setton Build a CSS website WITHOUT TABLES Just when you thought you were starting to understand HTML coding,
Web Pages and Style Sheets Bert Wachsmuth. HTML versus XHTML XHTML is a stricter version of HTML: HTML + stricter rules = XHTML. XHTML Rule violations:
กระบวนวิชา CSS. What is CSS? CSS stands for Cascading Style Sheets Styles define how to display HTML elements Styles were added to HTML 4.0 to.
Class four: the box model and positioning. is an HTML tag which allows you to create an element out of inline text. It doesn’t mean anything! try it:
Unit 20 - Client Side Customisation of Web Pages
CSS normally control the html elements. Three Ways to Insert CSS There are three ways of inserting a style sheet: External style sheet Internal style.
Web Design with Cascading Style Sheet Lan Vu. Overview Introduction to CSS Designing CSS Using Visual Studio to create CSS Using template for web design.
More CSS CS HTML id attribute 2 Coding Horror! Our mission is to combine programming and “human” factors with geekiness! output  A unique ID for.
Tutorial 6 Creating Fixed-Width Layouts
Beginning Web Site Creation: Dreamweaver CS4. XHTMLCSS  Describes the structure  Content  Collection of styles  Formatting body { background-color:
CSS Basics LIS Webteam April 8, Why CSS? What’s wrong with HTML? Structure vs Style Early web design used hacks to style webpages with HTML – like.
4.01 Cascading Style Sheets
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.
ITP 104.  While you can do things like this:  Better to use styles instead:
 This presentation introduces the following: › 3 types of CSS › CSS syntax › CSS comments › CSS and color › The box model.
CSS Tutorial 1 Introduction Syntax How to use style specifications. Styles.
Web Design (12) CSS Introduction. Cascading Style Sheets - Defined CSS is the W3C standard for defining the presentation of documents written in HTML.
- WE’LL LOOK AT THE POSITION PROPERTY AND HOW CSS RESOLVES CONFLICTS BETWEEN STYLING INSTRUCTIONS The position property; CSS specificity hierarchy.
1 Cascading Style Sheets
WEB FOUNDATIONS CSS Overview. Outline  What is CSS  What does it do  Where are styles stored  Why use them  What is the cascade effect  CSS Syntax.
WebD Introduction to CSS By Manik Rastogi.
CSS.
Cascading Style Sheets (CSS) Internal Style Sheets Classes
4.01 Cascading Style Sheets
Semester - Review.
Google fonts CSS box model
CSS Layouts: Grouping Elements
Unit 3 - Review.
>> Introduction to CSS
Creating Page Layouts with CSS
Cascading Style Sheets
Cascading Style Sheets (Layout)
Cascading Style Sheets
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Chapter 6 More CSS Basics Key Concepts
The Internet 10/13/11 The Box Model
Fixed Positioning.
DynamicHTML Cascading Style Sheet Internet Technology.
CSS Style Sheets: Intro
What are Cascading Stylesheets (CSS)?
DynamicHTML Cascading Style Sheet Internet Technology.
How to use the CSS box model for spacing, borders, and backgrounds
Stylin’ with CSS.
4.01 Cascading Style Sheets
Web Client Side Technologies Raneem Qaddoura
Introduction to Cascading Style Sheets (CSS)
Cascading Style Sheets™ (CSS)
Presentation transcript:

CSS Box Model <span> & <div> CS110: Computer Science and the Internet CSS Box Model <span> & <div> http://www.petervaldivia.com/technology/networks/index.php

Some style improvements… Introduce span, first for inline style: <span style=“color: red; background-color: white”>optional</span> Then create a new class of span element that is colored red HTML: <span class=“optional”>optional</span> external style sheet: span.optional { color: red; background-color: white; } For headers, add font-weight: normal; How can we style the word “optional” to be red? While we’re at it, let’s tone down those bold headers…

… and some house cleaning /* new CSS for the americanLit.html page */ body { font-family: sans-serif; font-size: medium; background-color: white; } h1, h2, h3 { font-weight: normal; h1 { color: maroon; h3 { color: blue; .optional { color: red; /* original CSS rules */ body { font-family: sans-serif; font-size: medium; } h1 { color: maroon; background-color: white; h3 { color: blue; li.optional { color: red; Tips of the day: Create separate rules for the common and distinct properties of multiple tags Add comments! http://www.loop11.com/technology-update/

CSS Box Model box content margin padding width border color: maroon; background-color: pink; width: 200px; padding: 20px; border: 5px dashed blue; margin: 50px; } margin padding width box content border To understand page layout, you first have to understand that, to a web browser, a web page is a series of boxes. The boxes have a width and height, and they get assembled (laid out) on the page, much the way Ben Franklin might have laid out the text and pictures in his newpaper. Boxes come in two kinds: blocks and inline. A block is something big like a paragraph or a <div>. Blocks are preceded and followed by line breaks, so Ben Franklin or the layout engine stacks them vertically on the page. (Normally, a block doesn't have anything to the left or right, though we will see some exceptions later.) An inline element (box) is something like a word, where Ben Franklin or the layout engine fills up a line with as many as it can, then goes on to the next line, and so forth. You may be surprised to learn that <img> elements are inline, so that a line is filled with as many images as will fit before starting the next line. (That's why centering an image is tricky; we'll look at that a bit later.) The top, bottom, left and right sides of the margin, padding and border can be styled differently to create many distinct appearances

Add structure with <div> HTML: <div class="week”> <h3>Week 1: <em>The Romantic Movement</em></h3> <ul> <li>Washington Irving, <em>Rip Van Winkle</em> <li>Edgar Allen Poe, <em>The Raven</em> <li class="optional">Walt Whitman, <em>Song of Myself</em> </ul> </div> CSS: div.week { background-color: lavender; padding: 20px; margin: 20px; border: 2px solid blue; width: 350px; }

id vs. class HTML: CSS: <h1>American Poetry and Prose</h1> <div id="header"> <h1>American Poetry and Prose</h1> </div> CSS: div#header { background-color: mistyrose; border-bottom: 4px double maroon; border-top: 4px double maroon; padding-left: 20px; }

Centering things HTML: CSS: <div class="pets"> p.center { <p class="center"> Ellen's (evil) cat Cleopatra </p> <img src="images/cleo.jpg" alt="Ellen's cat cleo"> </div> CSS: p.center { text-align: center; } div.pets { width: 400px; background-color: wheat; padding: 20px 0 20px 0; margin-left: auto; margin-right: auto;

Explore the Box Model with Firebug If Firebug is not installed in Firefox on your Mac: Select Add-ons from the Tools menu Enter firebug in the search box in the upper right corner Click on the link “See all 471 results” at the bottom of the page Move mouse to first item and click on “+ Add to Firefox” button Click on “Install Now” Select Firebug from the View menu to start There must be only one <div> with that id. For brevity, if there is only one element with that id, you can omit the element type, reducing the selector to just #navbar. View this page with Firebug: http://cs.wellesley.edu/~cs110/ellen/L4_CSS_Box/americanLit3.html