CSS Box Model. What is the CSS Box Model? The “Box Model” is a tool we use to lay out our web pages in a number of individual "boxes" or "containers".

Slides:



Advertisements
Similar presentations
Web Page Design Using Tables Here you see three examples of how tables can be used to organize your content. We call this page layout or design. You can.
Advertisements

CSS Layout Crash Course An Advance CSS Tutorial. Inline vs. Block Many HTML elements have a default display setting of Block. Block elements take up the.
ADVANCED CSS William Neely CEO, Piecewise.com. CSS FONTS AND TEXT CSS ‣ Line-height allows to indicate the amount of space between lines; allows for equal.
Today’s objectives Site performance Padding, Margins, Borders
CSS provides a way to stray away from the traditional methods of using tables to lay out pages. Success with this technique depends on understanding of.
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.
4.01 Cascading Style Sheets
1 The Structure of a Web Table beginning of the table structure first row of three in the table end of the table structure table cells You do not need.
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.
ITP 104.  While you can do things like this:  Better to use styles instead:
Basic Responsive Design Techniques. Let’s take a look at this basic layout. It has a header and two columns of text, in a box that is centered on the.
 This presentation introduces the following: › 3 types of CSS › CSS syntax › CSS comments › CSS and color › The box model.
10/4/2015Tables1 Spring, 2008 Modified by Linda Kenney 4/2/08.
Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border 
Css ( CASCADING STYLE SHEETs ) CSS Box Model. All HTML elements can be considered as boxes. In CSS, the term "box model" is used when talking about design.
Designing a Web Page with Tables. A text table: contains only text, evenly spaced on the Web page in rows and columns uses only standard word processing.
Web sites Design: Cascading Style Sheet (CSS) (Cont’d) Dimensions and Position of Elements –Width and Height Space –Table Cell Padding –Left and Top Position.
Part 4 Introduction to CSS. CSS Table Table Borders table, td, th { border:1px solid black; } Firstname Lastname Bader Ali Paul Manuel The example below.
WRA HTML & CSS – BUILDING WEBPAGES. TODAY’S AGENDA Review: external stylesheets Review: transforming a list Intro: the object Intro: the.
Web Foundations THURSDAY, OCTOBER 3, 2013 LECTURE 6: CSS CONTINUED.
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.
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.
Today’s objectives Layouts | floats Measurement units Type properties
CONTROLLING Page layout
Department of Computer Science, Florida State University CGS 3066: Web Programming and Design Spring 2016 CSS Positioning 1.
HTML and Dreamweaver November 11th. Agenda Box Model Displaying and positioning elements – Padding – Margin – Float – Display – Position HTML Demo.
CSS Table Styling. Up to this point, as we haven't applied any CSS styling to our tables, our example tables have not been too pleasing to the eye. CSS.
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.
Chapter 5 pp HTML Elements & Attributes Format Content Or Examples This Text Is A Hyperlink.
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.
>> CSS Layouts. Recall Properties of Box – Border (style, width, color) – Padding – Margin – Display – Background – Dimension Welcome Padding Area Border.
CHAPTER 15 Floating and Positioning. FLOAT VS. POSITION  Floating an element moves it to the left or right, allowing the following text to wrap around.
Laying out Elements with CSS
CSS Box Model.
CSS Box Model.
CSS Box Model.
The Box Model in CSS Web Design – Sec 4-8
Cascading Style Sheets Boxes
4.01 Cascading Style Sheets
CSS Table Styling.
Google fonts CSS box model
The Box Model in CSS Web Design – Sec 4-8
CSS Layouts: Grouping Elements
CS1220 Web Programming Saloni Chacha.
Box model.
Cascading Style Sheets (Layout)
The Box Model in CSS Web Design – Sec 4-8
CSS Table Styling.
Styles and the Box Model
CSS Borders and Margins.
CSS Box Model.
Putting Images on Your Web Page
CSS Box Model.
Float Property Elements that seem to “float" on the right or left side of either the browser window or another element are often configured using.
Responsive Framework.
More CSS Page layout Boriana Koleva Room: C54
Floating and Positioning
CSS Box Model.
CSS and Class Tools.
Laying out Elements with CSS
CSS Boxes CS 1150 Fall 2016.
4.01 Cascading Style Sheets
CSS Box Model.
CSS Box Model.
Cascading Style Sheets
ITI 133: HTML5 Desktop and Mobile Level I
Positioning Boxes Using CSS
CGS 3066: Web Programming and Design Fall 2019 CSS Part 2
Presentation transcript:

CSS Box Model

What is the CSS Box Model? The “Box Model” is a tool we use to lay out our web pages in a number of individual "boxes" or "containers". When we plan our web page design, we must take into account not only the size of page content, but also the margins, borders, and padding involved. Before we start building a page, we can plan where everything will go by arranging these boxes on the screen. Our goal is to create a balanced layout, with plenty of "white space" around the content.

The components of a box: Margin Border Content Padding

Introducing the tag: The tag is our basic building block when laying out a page design. By defining the height and width of the, we are "reserving" that amount of space on the screen for whatever content we wish to place there. The actual content will go inside the opening and closing tags.

Example : By establishing the box dimensions, we can leave it there as a placeholder until we have our content ready. In the meantime, the rest of the page can be built out with our other content..box300 { width:300px; height:300px; border:1px solid black; } This is a 300 by 300 pixel box with a 1px border. This is outside the box. This is a 300 by 300 pixel box with a 1 px border. This is outside the box.

Adding padding: By adding 10px of padding on all four sides of the content, we have effectively made our box 320px by 320px (321px by 321px with the border)..box300 { width:300px; height:300px; border:1px solid black; padding:10px; } This is a 300 by 300 pixel box with a 1px border and 10px padding. This is outside the box. This is a 300 by 300 pixel box with a 1px border and 10px padding. This is outside the box.

Adding margin: By adding 10px of margin on all four sides of the border, we have now made our box 341px by 341px overall..box300 { width:300px; height:300px; border:1px solid black; padding:10px; margin:10px; } This is a 300 by 300 pixel box with a 1px border and 10px Padding and 10px margin. This is outside the box. This is a 300 by 300 pixel box with a 1px border and 10px padding and 10px margin. This is outside the box. The dotted line here shows where the margin is but it will not show on the actual page.

Calculating overall dimensions: When designing our page, we have to calculate how much size a element will consume: Total element width = defined width + left padding + right padding + left border + right border + left margin + right margin. Total element height = defined height + top padding + bottom padding + top border + bottom border + top margin + bottom margin

Pixels vs. Percent: The width property can be specified in pixels or in percent. By using "width:50%", we are telling the browser to make the width of the element exactly 50% of the space available. Using percent instead of pixels can make our page layout highly flexible. For example, we can use the entire screen real estate, no matter what size screen or resolution our web visitor has.

A technique to center a : Because we don't know what the screen resolution will be for our visitors, it can be challenging to get our pages to display attractively for all viewers. A useful technique is to set the right and left margins of a to the value "auto". This tells the browser to maintain an equal distance on the right and left, effectively centering the no matter how wide the available area is:.centerme { margin:0 auto; } This same technique can be used on a element that contains all your page content in order to center your page on the screen, no matter what the screen resolution of your web visitor.