Styles and the Box Model

Slides:



Advertisements
Similar presentations
CSS Cascading Style Sheets. Objectives Using Inline Styles Working with Selectors Using Embedded Styles Using an External Style Sheet Applying a Style.
Advertisements

Quiz #3 - CSS Lecture Code: Get Neighbors’ URLs for MP1
Cascading Style Sheets
Today CSS HTML A project.
Web Pages and Style Sheets Bert Wachsmuth. HTML versus XHTML XHTML is a stricter version of HTML: HTML + stricter rules = XHTML. XHTML Rule violations:
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.
CONCEPTS FOR FLUID LAYOUT Web Page Layout. Website Layouts Most websites have organized their content in multiple columns (formatted like a magazine or.
16 HTML Tables and Frames Section 16.1 Create a basic table using HTML Define borders Merge cells Align content in tables Section 16.2 Create a frames-based.
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.
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic CSS: Cascading Style Sheets.
MORE Cascading Style Sheets (The Positioning Model)
Working with Cascading Style Sheets. 2 Objectives Introducing Cascading Style Sheets Using Inline Styles Using Embedded Styles Using an External Style.
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.
Working with Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of a document.
The Characteristics of CSS
Cascading Style Sheets CSS. CSS Positioning Normal Flow Top -> bottom | left -> right Arranged in the order they appear in the code make room for one.
Cascading Style Sheets CSS. div … Used like a container to group content Gives context to the elements in the grouping Give it a descriptive name with.
CONCEPTS FOR FLUID LAYOUT Web Page Layout. Website Layouts Most websites have organized their content in multiple columns (formatted like a magazine or.
 This presentation introduces the following: › 3 types of CSS › CSS syntax › CSS comments › CSS and color › The box model.
 Word doc for you to download › Link at the beginning of class › 10 Questions › Answers to be added inline  Post to Sakai when completed › No resubmits.
 Remember that HTML is just text  Need to point to pictures  Use the img tag  alt: › screen reader › REQUIRED for this class and to validate.
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Tutorial 7.
Lecture 2 - HTML and CSS Review SFDV3011 – Advanced Web Development 1.
WRA HTML & CSS – BUILDING WEBPAGES. TODAY’S AGENDA Review: external stylesheets Review: transforming a list Intro: the object Intro: the.
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.
Internet Technology Dr Jing LU Updated Dr Violet Snell / Dr Kalin Penev 1 Internet Technology (week 6)  Recap: Validating HTML  Page Layout.
CSS Fun damentals The Document Hierarchy Element Relationships The Box Model.
INTRODUCTORY Tutorial 5 Using CSS for Layout and Printing.
CNIT 132 – Week 4 Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of.
BEGINNER WEB DESIGN. INTRODUCTION Vocabulary Design Tools of the Trade HTML CSS.
Chapter 5 pp HTML Elements & Attributes Format Content Or Examples This Text Is A Hyperlink.
 Add one element at a time  If it doesn’t do what you want, › Delete it › DON’T just keep piling on more items.
CONCEPTS FOR FLUID LAYOUT Web Page Layout. Essential Questions What challenges do mobile devices present to Web designers? What are the basic concepts.
CSS Introductions. Objectives To take control of the appearance of a Web site by creating style sheets. To use a style sheet to give all the pages of.
Creating Web Documents CSS examples (do more later) Lab/Homework: Read chapters 15 & 16. Work on Project 3, do postings.
Cascading Style Sheets for layout
CSS.
Working with Cascading Style Sheets
Cascading Style Sheets Layout
Cascading Style Sheets™ (CSS)
4.01 Cascading Style Sheets
CSS Layouts: Grouping Elements
CSS: Cascading Style Sheets
Webpage layout using CSS
Concepts for fluid layout
Positioning Objects with CSS and Tables
Madam Hazwani binti Rahmat
Advanced CSS BIS1523 – Lecture 20.
Cascading Style Sheets for layout
Cascading Style Sheets (Layout)
Intro to CSS CS 1150 Fall 2016.
Cascading Style Sheets
CSS Applications to XML 19-Sep-18.
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Intro to CSS CS 1150 Spring 2017.
Fixed Positioning.
Controlling Layout with Style Sheets
Second CSS Lecture Applications to XML
MORE Cascading Style Sheets (The Positioning Model)
Web Development & Design Foundations with H T M L 5
Cascading Style Sheets™ (CSS)
Training & Development
Floating and Positioning
Concepts for fluid layout
4.01 Cascading Style Sheets
CSS Applications to XML 20-May-19.
The div Element and CSS for layout
Web Programming and Design
CSS Applications to XML 3-Jul-19.
Cascading Style Sheets™ (CSS)
Presentation transcript:

Styles and the Box Model

Overview… We will look at: Introduction to Styles. HTML Styling Embedding Styling Internal Style Sheets/External Style Sheets Layout Structure

Introduction to Styles Styling on HTML pages are implemented in many different ways some very bad and some good. Lets look at these documents….. What’s the difference?

HTML Format This is the basic format of an HTML page… This is displayed like…

Font Tag To change the colour of the text displayed. We make use of the font tag. This changes the output to….

Embedded Styling – BAD example

Embedded Styling – BAD example The font tag is a depreciated HTML tag and is no longer used within HTML5. Within this example there are 63 instances of red text applied throughout the document. So what if we wanted to change this colour from Red to Blue?

Internal Style Sheet - BETTER This example shows creating a stylesheet within the HTML page.

Internal Style Sheet - BETTER The code shows all the styles being used within the example. This style is applied as a class called “BodyText”. By creating a style class, it allows us to use this over and over again within the HTML page.

External Style Sheet - BEST The best way of storing our styles is by making use of Cascading Style Sheets (CSS). An external CSS is separate to HTML and allows us to contain all of our styles together and just to reference the in the HTML page. When using CSS, HTML is used to tell the page where to get its formatting from. Compared to an internal stylesheet, this allows the same stylesheet to style multiple pages instead of just the one. The biggest advantage to this method is that one change to the CSS will impact the entire the whole site.

External Style Sheet - BEST A stylesheet is referenced on a HTML page though the use of a single line of HTML located within the <head> tags. Href is the destination. Rel is the relationship between the documents Type specifies the media type

Marking up HTML Once style is defined in a stylesheet, it needs to be applied to the HTML. There are two sorts of styles to be used: Inline – Applied to text in a single line. Utilises <span> tags. Block – Applied to a block of text/area. E.g. Paragraph Utilises <div> tags.

<div> vs <span> Using span tag follows the flow of text. This is accomplished by… Block styles are applied at the start of the paragraph. So what would happen if we changed the second span to a div?

<div> vs <span> This would apply block level formatting and change the output to… By using the <div> tags, it has created a division within the text, therefore split it into sections. We don’t want this. So a <div> tag would be used around the outside and a <span> tag on the inside.

Basic HTML5 Layout HTML5 provides us with a basic layout structure to use that is split into 6 areas. header – Content that appears on every page of the site typically at the top footer - Content that appears on every page of the site typically at the bottom nav - The navigation elements for the page article - The main document for this page section - A sub section in the main document aside - A section on the page with additional information (often advertising)

Layout

Creating the Layout A new HTML document has been created with the following unformatted content…

Positioning In regards to styling, we have several options to consider with its positioning. Static - We may leave the text in the flow of the text Absolute - We may remove the text from the flow and specify exact coordinates with respect to the parent container Fixed - We may remove the text from the flow and specify exact coordinates with respect to the browser window Relative - We may position the text relative to its position in the flow

Re-defining Tags When styling we have the option to redefine tags. We can apply formatting whenever the tag appears. Firstly, we will mark-up the document for where we want the formatting to apply. In this case it’s the header…

Tag Surroundings To understand the box model, we need to think of a box around the tag content.

Tag Surroundings All of the surrounding boxes to the content posses a top, left, height and width property. These are determined with reference to the parent container such as article. Lets apply a border so we can see the edges of the styling. This creates the following…

Adjusting the Padding Changing the padding changes how the text sits in relation to the border. This results the space between the text and border being increased by 10 pixels.

Adjusting the Margin Lets increase the margin… This results in…

Changing Positioning Changing the positioning takes it out of the flow of content. Lets change the position to absolute… And we get a not very attractive layout.

Adjusting the Width and Height So far we have used “px” as a unit of measurement. We can also use %, em or vw and vh. Percentages mean that its calculated based on its parent. EM mean the box is calculated based on font size. VW is based on the viewable width of the page. VH is based on the viewable height of the page. Dependant on content will depend on which would be the best method to use.

Adjusting the Width and Height Lets set the values to percentages….

Adjusting the Width and Height

Recap We have looked at:- Introduction to styling HTML Styling Styling Methods Embedded Styling Internal Styling External Styling Inline and box styling Layout Positioning Tag Surroundings Adjustments

Next Week… We are going to look into Hypertext, Images and Tables including:- Types of hypertext Creating Links Types of Hyperlinks available Styling Hyperlinks Other Attributes used in hyperlinks.