CSS BEST PRACTICES.

Slides:



Advertisements
Similar presentations
Chapter 3 – Web Design Tables & Page Layout
Advertisements

Layouts Using Tables Web Design – Section 4-5 Part or all of this lesson was adapted from the University of Washingtons Web Design & Development I Course.
15 LAYOUT Controlling the position of elements Creating site layouts Designing for different sized screens.
Cascading Style Sheets
Web Pages and Style Sheets Bert Wachsmuth. HTML versus XHTML XHTML is a stricter version of HTML: HTML + stricter rules = XHTML. XHTML Rule violations:
Tutorial 4: Creating page layout with css
CONCEPTS FOR FLUID LAYOUT Web Page Layout. Website Layouts Most websites have organized their content in multiple columns (formatted like a magazine or.
XP 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
4.01 Cascading Style Sheets
Working with Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of a document.
Different ways to implement CSS. There are four different ways to use CSS in your web pages: – Inline CSS – Embedded CSS/Internal CSS – Linked CSS/External.
Multimedia & The World Wide Web winny HCI 201 Multimedia and the www.
Tutorial 4: Using CSS for Page Layout. 2 Objectives Session 4.1 Explore CSS layout Compare types of floating layouts Examine code for CSS layouts View.
ITP 104.  While you can do things like this:  Better to use styles instead:
The Characteristics of CSS
INTRODUCTION TO HTML5 CSS Styles. Understanding Style Sheets  HTML5 enables you to define many different types of content on a web page, including headings,
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.
Page Layout with CSS Learning Web Design: Chapter 16.
CSS = Cascading Style Sheet CSS consists of rules to display, style and decorate HTML elements Why CSS ? – Separate decoration from HTML markup (Ex :,,…)
Introduction to Programming the WWW I CMSC Winter 2003 Lecture 6.
Use CSS to Implement a Reusable Design Selecting a Dreamweaver CSS Starter Layout is the easiest way to create a page with a CSS layout You can access.
CSS BEST PRACTICES.
INTRODUCTION TO CSS. TOPICS TO BE DISCUSSED……….  Introduction Introduction  Features of CSS Features of CSS  Creating Style Sheet Creating Style Sheet.
Course created by Sarah Phillips BBCD Melbourne BAPDCOM Version 1 – April 2013.
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.
Course created by Sarah Phillips BBCD Melbourne BAPDCOM Version 1 – February 2013.
Internet Technology Dr Jing LU Updated Dr Violet Snell / Dr Kalin Penev 1 Internet Technology (week 6)  Recap: Validating HTML  Page Layout.
Microsoft Expression Web 3 – Illustrated Unit D: Structuring and Styling Text.
Cascading Style Sheets Primary readings Presentations Explain & review projects with class mates.
CSS Positioning & Layout Creating layouts and controlling elements.
8/13/2003 Designing Without Tables Using CSS by Reshma Kumar and Marina Naito.
CSS FOUNDATIONS IN-DEPTH The nitty-gritty of css...
Fundamentals of Web DevelopmentRandy Connolly and Ricardo Hoar Textbook to be published by Pearson Ed in early Bootstrap.
CONCEPTS FOR FLUID LAYOUT Web Page Layout. Essential Questions What challenges do mobile devices present to Web designers? What are the basic concepts.
Mimi Opkins.  One of the major benefits of using CSS is that you’re not forced to lay your sites out in tables.  The layout possibilities of CSS give.
Tutorial 4 Using CSS for Page Layout. Objectives Session 4.1 – Explore CSS layout – Compare types of floating layouts – Examine code for CSS layouts –
Cascading Style Sheets for layout
Laying out Elements with CSS
Cascading Style Sheets Layout
CSCI 1720 W3.CSS – Part 1 East Tennessee State University Department of Computing CSCI 1720 Intermediate Web Design.
>> Navigation and Layouts in CSS
4.01 Cascading Style Sheets
Concepts for fluid layout
Cascading Style Sheets for layout
Cascading Style Sheets (Layout)
CSS part 2 Outro.
Cascading Style Sheets
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Cascading Style Sheets - Building a stylesheet
Cascading Style Sheets
Objectives Create a reset style sheet Explore page layout designs
Responsive Web Design (RWD)
Styles and the Box Model
MORE Cascading Style Sheets (The Positioning Model)
Responsive Web Design (RWD)
HTML – Organizing Page Content
What are Cascading Stylesheets (CSS)?
Cascading Style Sheets™ (CSS)
Cascading Style sheet. What is CSS?  CSS stands for Cascading Style Sheets  Cascading: refers to the procedure that determines which style will apply.
Laying out Elements with CSS
Cascading Style Sheets - Building a stylesheet
Concepts for fluid layout
4.01 Cascading Style Sheets
CSc 337 Lecture 5: Grid layout.
Various mobile devices
Presentation transcript:

CSS BEST PRACTICES

Lecture Overview Understanding grid frameworks CSS design best practices Stylesheet organization Fixed vs. fluid layouts Look at existing templates

The 960 Grid System (1) It was a de facto standard for standardized layouts (Nathan Smith is credited with its creation) The grid is typically structured as follows Total width 960px / Total content area is 940px 12 columns @ 60px each Each column has 10px left & right margin which forms 20px of gutter space As screens get wider, some consider the 960 grid obsolete

The 960 Grid System (2) There are 12, 16, and 24 column versions Download from http://adapt.960.gs/

The 960 Grid System (Illustration)

How it Works Create an outer <div> tag with the class container_12 or container_16, … Create sub elements grid_x where x is the number of columns Continue to create elements until the total is 16 Create a <div> tag with the clear class to reset Continue to create columnar elements See grid960.html

The 1200 PX Grid System Nearly all modern monitors support at least 1280 x 1024 pixels 1200 is divisible by 2, 3, 4, 5, 6, 8 10, 12, 15, 16, 20, 24, 30, 40 ,48, 60, 80, 120, 200, 240, 400 http://1200px.com This came out of the 960 system from years ago There are other grid systems too

Design Steps (1) Draw a logical layout first What the page should look like Create an HTML structure that will support the layout Create the HTML before the CSS. Don’t create the CSS concurrently Use semantic tags instead of <div>, where appropriate Then create the CSS

Design Steps (2) If your CSS is getting complex, use multiple stylesheets Keep a library of commonly used and helpful CSS classes

Stylesheet Organization (1) Divide your stylesheet into sections such as Global styles Header Page structure Text styles Navigation styles Forms Do use comments to identify sections

Stylesheet Organization (2) Don’t use inline styles except for development and testing Do use external style sheets They can be cached so pages load faster A single stylesheet can be applied to every page of a site This method separates content from presentation

Fixed vs. Fluid Layouts A fixed layout has a wrapper that’s a fixed width The inner components are expressed as a fixed width or percentages A fluid or liquid layout is expressed in percentages

Fixed Layouts Pros Cons Easier Widths are the same for every browser No need for min-width or max-width properties Cons Excessive whitespace on large screens Problematic on small screens

Fluid Layouts Pros Cons More user friendly Minimizes the extra whitespace Avoid scroll bars on smaller screen resolutions Cons Need to test on varying screen resolutions Problems with images and video

Elastic Design It combines characteristics of fixed and fluid layouts All elements are sized with em’s More flexible but harder to code FYI 1 em is 12 points So 2 ems is 24 point

Color Keep a color reference somewhere in your CSS file The color reference is typically expressed as a comment in the CSS

Some Best Practices Declare the most generic items first, and then the more specific ones This takes advantage of CSS inheritance Use intuitive naming conventions and think of future edits Avoid names like left and right as positioning might change later Use hyphens for class names and underscores for IDs

Some Best Practices Divide stylesheets into sections Do use shorthand properties instead of detailed properties for brevity and efficiency margin:5px 1px 4px 10px; Is faster than margin-top:5px; margin-right:1px; margin-bottom:4px; margin-left:10px;

Some Best Practices Don’t be repetitive and do reuse attributes

Some Best Practices Minimize the use of IDs Avoid !important unless absolutely necessary Do use resets to override default browser formatting

Existing Templates There are thousands of existing template Examples Some free. Some not Pay attention to licensing Examples http://templated.co/ http://www.free-css.com/

Other Tools and Frameworks Bootstrap CSS Fluid and fixed versions Uses a 12 column 5 Flexible across devices http://getbootstrap.com/css/ A list of frameworks http://usablica.github.io/front-end-frameworks/compare.html

Other Tools and Frameworks Less is a CSS pre-processor that extends the CSS language http://lesscss.org/ SASS is another stylesheet language http://sass-lang.com/ Normalize https://necolas.github.io/normalize.css/5.0.0/normalize.css