CSS Margins. The Margin properties define the space around elements. It is possible to use negative values to overlap content. The top, right, bottom,

Slides:



Advertisements
Similar presentations
1 Cascading Style Sheets Continued Different kinds of selectors in a style sheet –Simple- Pseudo-Class –Contextual- Pseudo-Element –Class Image Styles.
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.
Part 5 Introduction to CSS. CSS Display - Block and Inline Elements A block element is an element that takes up the full width available, and has a line.
Client-Side Internet and Web Programming
With CSS, a color is most often specified by: a HEX value - like "#ff0000" an RGB value - like "rgb(255,0,0)" a color name - like "red“ Example h1.
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.
Today’s objectives Site performance Padding, Margins, Borders
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
Text Properties, Line Box, CSS. Text Properties Properties related to the display of text. Text-align : left, right, center I like FSU!
TUTORIAL 4: CREATING PAGE LAYOUT WITH CSS Session 4.3.
Using CSS for Page Layout. Types of HTML Elements Block-Level Element –Creates blocks of content e.g. div, h1..h6, p, ul, ol, li, table, form –They start.
The Viewport body element w/ bg image body element w/ bg image wrapper.
Streamlining Website Development in Dreamweaver Roger L. Runquist Western Illinois University Roger L. Runquist Western Illinois University.
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.
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.
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.
CSS Introduction Cascading Style Sheets Provides a great deal of control over the presentation of the document HTML indicates both semantics of a document.
CSS The Definitive Guide Chapter 8.  Allows one to define borders for  paragraphs  headings  divs  anchors  images  and more.
1 What is CSS?  CSS stands for Cascading Style Sheets  Styles define how to display HTML elements  Styles are normally stored in Style Sheets  Styles.
CSS My favourite ICT lesson By Federico Boschi Cascading Style Sheets.
CSS Border.
Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border 
Doncho Minkov Telerik Web Design Course html5course.telerik.com Technical Trainer
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.
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.
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.
CSS Class 2 -Add margins to elements on a page. -Set width and height of elements. - CSS shorthand properties for box model. -Style links. -Style tables.
XP Review 2 New Perspectives on JavaScript, Comprehensive1 Introducing Cascading Style Sheets Formatting Web Pages with CSS.
THE BOX MODEL Putting layouts together with CSS. The Box Model  How would you describe a box?  Container?  Tags or elements are “containers”  puts.
1 CS428 Web Engineering Lecture 08 Border, Margin, Padding … (CSS - III)
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
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 properties for margin  CSS properties for dimensions (width,
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:
Web Design (12) CSS Introduction. Cascading Style Sheets - Defined CSS is the W3C standard for defining the presentation of documents written in HTML.
Tutorial 4 Creating Page Layouts with CSS
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:
CSS Text Text properties allow you to control the appearance of text. It is possible to change the color of a text, increase or decrease the space between.
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.
Week 5.  Normal document flow  Affecting document flow with float and position properties using CSS  Using these properties to create layouts.
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.
End User Computing Applied CSS: Building our course homepage Sujana Jyothi Department of Computer Science
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.
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,
Laying out Elements with CSS
CSS Layouts: Grouping Elements
The Internet 10/25/11 XHTML Tables
Cascading Style Sheets
Fixed Positioning.
CSS Borders and Margins.
Second CSS Lecture Applications to XML
MORE Cascading Style Sheets (The Positioning Model)
Web Development & Design Foundations with H T M L 5
More CSS 22-Feb-19.
CS3220 Web and Internet Programming More CSS
CS3220 Web and Internet Programming More CSS
Positioning Boxes Using CSS
CS3220 Web and Internet Programming More CSS
Presentation transcript:

CSS Margins

The Margin properties define the space around elements. It is possible to use negative values to overlap content. The top, right, bottom, and left margin can be changed independently using separate properties. A shorthand margin property can also be used to change all of the margins at once.

Margin Property The margin property is a shorthand property for setting all of the properties for the four margins in one declaration. Note: Negative values are allowed. Inherited: No

Example h1 {margin: 10px} all four margins will be 10px h1 {margin: 10px 2%} top and bottom margin will be 10px, left and right margin will be 2% of the total width of the document. h1 {margin: 10px 2% -10px} top margin will be 10px, left and right margin will be 2% of the total width of the document, bottom margin will be -10px h1 {margin: 10px 2% -10px auto} top margin will be 10px, right margin will be 2% of the total width of the document, bottom margin will be - 10px, left margin will be set by the browser

Possible Values ValueDescriptionNNIE margin-top margin-right margin-bottom margin-left Sets the properties for the margins. The values comes in % (defines a margin in % of the total height/width of the document), length (defines a fixed margin), and auto (the browser sets a margin). 4.0

Browser Notes Note in IE 4.0+: This property does not work with inline elements The "margin-bottom" property does not work with table cells Note in IE 5.5 Beta 1: This property works with inline elements Notes in Netscape 4.0+: This property does not work properly with inline elements, input fields, images, and list items This property ignores the bottom margin declaration entirely if a top margin has been specified

Margin-Bottom Property The margin-bottom property sets the bottom margin of an element. Note: Negative values are allowed. Inherited: No

Example h1 { margin-bottom: 10px } h2 { margin-bottom: -20px }

Possible Values ValueDescriptionNNIE autoThe browser sets a bottom margin4.0 lengthDefines a fixed bottom margin4.0 %Defines a bottom margin in % of the total height of the document 4.0

Browser Notes Note in IE 4.0+: This property does not work with table cells or inline elements Note in IE 5.5 Beta 1: This property works with inline elements Notes in Netscape 4.0+: This property does not work with inline elements, input fields, images, and list items This property ignores negative values

Margin-Left Property The margin-left property sets the left margin of an element. Note: Negative values are allowed. Inherited: No

Example h1 { margin-left: 10px } h2 { margin-left: -20px }

Possible Values ValueDescriptionNNIE autoThe browser sets a left margin lengthDefines a fixed left margin %Defines a left margin in % of the total width of the document

Browser Notes Note in IE 4.0+: This property does not work with inline elements Note in IE 5.5 Beta 1: This property works with inline elements Notes in Netscape 4.0+: This property does not work properly with inline elements, images, and list items This property ignores negative values on table cells

Margin-Right Property The margin-right property sets the right margin of an element. Note: Negative values are allowed. Inherited: No

Example h1 { margin-right: 10px } h2 { margin-right: -20px }

Possible Values ValueDescriptionNNIE autoThe browser sets a right margin lengthDefines a fixed right margin %Defines a right margin in % of the total width of the document

Browser Notes Note in IE 4.0+: This property does not work with inline elements Note in IE 5.5 Beta 1: This property works with inline elements Notes in Netscape 4.0+: This property does not work properly with inline elements, images, and list items This property ignores negative values on table cells

Margin-Top Property The margin-top property sets the top margin of an element. Note: Negative values are allowed. Inherited: No

Example h1 { margin-top: 10px } h2 { margin-top: -20px }

Possible Values ValueDescriptionNNIE autoThe browser sets a top margin lengthDefines a fixed top margin %Defines a top margin in % of the total height of the document

Browser Notes Note in IE 4.0+: This property does not work with inline elements Note in IE 5.5 Beta 1: This property works with inline elements Notes in Netscape 4.0+: This property does not work with inline elements, images, and list items This property ignores negative values on inline elements, images, list items, and table cells