Cross-Browser Compatibility. Myth or Reality? There's a long tradition to be overcome Sniffers to look for browser and OS combinations Separate code forks.

Slides:



Advertisements
Similar presentations
JQuery MessageBoard. Lets use jQuery and AJAX in combination with a database to update and retrieve information without refreshing the page. Here we will.
Advertisements

The Deconstruction of a Dynamic XHTML Web Page. DXHTML? What's so great about it? You can use XML-based languages like SVG and SMIL with relative ease.
LIS650 lecture 4 Thomas Krichel today Advice CSS Properties –Box properties –List properties –Classification properties Fun with selectors.
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.
XHTML Week Two Web Design. 2 What is XHTML? XHTML is the current standard for HTML Newest generation of HTML (post-HTML 4) but has many new features which.
The DOM tree CS The DOM tree CS380 2 Types of DOM nodes  element nodes (HTML tag)  can have children and/or attributes  text nodes (text in.
Cascading Style Sheets
Standards and Increasing Maintainability on Web- based Systems James Eaton SE4112/16/2006.
1 HTML Standards & Compliance. 2 Minimum Required HTML tags: (must go in this order!)
XHTML Basics.
1. Content – Collective term for all text, images, videos, etc. that you want to deliver to your audience. 2. Structure – How the content is placed on.
HTML/XML XHTML Authoring. Creating Tables  Table: An arrangement of horizontal rows and vertical columns. The intersection of a row and a column is called.
History Leading to XHTML
Web Standards & Techniques Why Should I Care? I’m so sick of the attitude I run into “well, web standards inhibit innovation.” What a crock. What’s inhibiting.
 CSS ids  Pages  Sites  HTML: class=“name”  Names may define format OR content › Either works  CAN apply multiple classes to the same tag  Multiple.
XHTML 16-Apr-17.
Chapter 16 Dynamic HTML and Animation The Web Warrior Guide to Web Design Technologies.
Unit 2, cont. September 14 HTML,Validating your pages, Publishing your site.
Chapter 1 Understanding the Web Design Environment
© Ms. Masihi 1.  A web page is created using a language called, Hypertext Markup Language, better known as HTML Code.  HTML is a user friendly language.
XP Tutorial 5New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Designing a Web Site with Frames Using Frames to Display Multiple Web Pages Tutorial.
Chapter 1 Variables in the Web Design Environment
Pemrograman Berbasis WEB XML part 2 -Aurelio Rahmadian- Sumber: w3cschools.com.
HTML & CSS A brief introduction. OUTLINE 1.What is HTML? 2.What is CSS? 3.How are they used together? 4.Troubleshooting/Common problems 5.More resources.
XP Tutorial 9New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with XHTML Creating a Well-Formed Valid Document Tutorial 9.
ULI101 – XHTML Basics (Part II) What is Markup Language? XHTML vs. HTML General XHTML Rules Block Level XHTML Tags XHTML Validation.
Lesson 4: Using HTML5 Markup.  The distinguishing characteristics of HTML5 syntax  The new HTML5 sectioning elements  Adding support for HTML5 elements.
Selectors. Learning Objectives By the end of this lecture, you should be able to: – Select items using jQuery based on ID, class name, or HTML tag. –
XHTML The Basics A brief history of HTML SGML (Standard Generalized Markup Language) Then came HTML Followed by the browser…and the great browser wars.
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.
JavaScript & DOM Client-side scripting. JavaScript JavaScript is a tool to automate client side (which is implemented using HTML so far) JavaSript syntax.
Chapter 1 Understanding the Web Design Environment Principles of Web Design, 4 th Edition.
Week 1 Understanding the Web Design Environment. 1-2 HTML: Then and Now HTML is an application of the Standard Generalized Markup Language Intended to.
XHTML1 Building Document Structure Chapter 2. XHTML2 Objectives In this chapter, you will: Learn how to create Extensible Hypertext Markup Language (XHTML)
Learning Web Design: Chapter 4. HTML  Hypertext Markup Language (HTML)  Uses tags to tell the browser the start and end of a certain kind of formatting.
1 HTML XHTML. 2 Understand the Doctype tag Know the html tags which are now classed as depreciated Understand how Dreamweaver adds styles Add styles to.
Cascading Style Sheets CSS by Pavlovic Nenad by. 2Cascading Style Sheets Presentation Contents What are CSS? What are CSS? History of CSS History of CSS.
JavaScript – The DOM JavaScript is object based The browser is object based – We can access the browser's objects in the same way we did JavaScript's Two.
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.
XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard.
WEB DESIGN AND PROGRAMMING Advanced CSS Techniques.
DHTML AND JAVASCRIPT Genetic Computer School LESSON 5 INTRODUCTION JAVASCRIPT G H E F.
XHTML By Trevor Adams. Topics Covered XHTML eXtensible HyperText Mark-up Language The beginning – HTML Web Standards Concept and syntax Elements (tags)
Lecture 2 - HTML and CSS Review SFDV3011 – Advanced Web Development 1.
CSS : Cascading Style Sheets Ann Dobbs Class: i385e.
Review for exam 1 Midterm Closed Book. Review for Exam 1 Blackboard topic Review for exam 1 Sample Question Multiple Choice True / False Matching type.
1 Javascript DOM Peter Atkinson. 2 Objectives Understand the nature and structure of the DOM Add and remove content from the page Access and change element.
Advanced Topics Lecture 8 Rachel A Ober
Cascading Style Sheets (CSS) Part II IT210: Web-based IT.
Positioning Objects with CSS and Tables
May 6, 2009 Browser Compatibility Testing Definition It is a non functional type of testing where web based applications are tested on various browsers(IE.
- WE’LL LOOK AT THE POSITION PROPERTY AND HOW CSS RESOLVES CONFLICTS BETWEEN STYLING INSTRUCTIONS The position property; CSS specificity hierarchy.
CIS67 Foundations for Creating Web Pages Professor Al Fichera Rev. August 25, 2010—All HTML code brought to XHTML standards. Reference for CIS127 and CIS.
Chapter 10 Dynamic HTML (DHTML) JavaScript, Third Edition.
CSS Layout Cascading Style Sheets. Lesson Overview  In this lesson, we’ll cover:  Brief CSS review  Creating sections with the tag  Creating inline.
Introduction to Web Site Development Department of Computer Science California State University, Los Angeles Lecture 9: JavaScript.
Tutorial 5 Working with Web Tables. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Learn and Apply the structure of.
INTRODUCTION ABOUT DIV Most websites have put their content in multiple columns. Multiple columns are created by using or elements. The div element is.
Cascading Style Sheets for layout
Cao Yuewen SEEM4570 Tutorial 03: CSS Cao Yuewen
Positioning Objects with CSS and Tables
Cascading Style Sheets for layout
Web Programming– UFCFB Lecture 9
Digital Design – Copyright Law
HTML A brief introduction HTML.
SEEM4570 Tutorial 3: CSS + CSS3.0
That detail is only sort of important That detail is only sort of important. What is important is that you have all of these HTML elements floating.
Introduction to DHTML, the DOM, JS review
Web Programming– UFCFB Lecture 9
Positioning Objects with CSS and Tables
Presentation transcript:

Cross-Browser Compatibility

Myth or Reality? There's a long tradition to be overcome Sniffers to look for browser and OS combinations Separate code forks for different browsers Special HTML "tricks" to overcome browser defaults and bugs Proprietary DOM and HTML So can cross-browser compatilibity be real?

The Reality Yes! Cross-browser compatibility lies within your reach! First, you must do as Yoda says: "Unlearn what you have learned" Second, adjust your thinking for a new reality Third, start coding! Let's look at some common pitfalls and things that must be unlearned

Shed the Deadweight Things to give up: Invalid HTML LAYERit's dead and it's time to move on Proprietary DOMs document.layers died with LAYER itself document.all is still alive, but it's also completely proprietary Code forking Most forking is based around incompatible proprietary DOMs, so give them up and forking is unnecessary

Shiny New Toys! Try playing with these: Valid HTML Purify your structure and compatibility will follow W3C DOM Both IE5.x+ and NS6 support the W3C DOM, so code written once can run in both with NO FORKING! How can this process be any easier? Let's find out!

Validating Your HTML The fastest way to improve your pages Any page that triggers an error is invalid and the problem needs to be fixed If you can get a page to validate with no errors or warnings, you're golden The results will be different depending on what DOCTYPE you use There's a CSS validator too Valid CSS is as important to page layout as valid HTML

DOCTYPE Issues Do NOT lie about your DOCTYPE! If you have HTML 4.0 Transitional markup, then say so; don't claim XHTML 1.1 Strict! The DOCTYPE you use will trigger one of two layout models in recent browsers Old, missing, or transitional DOCTYPEs will trigger "legacy" layout mode XML, XHTML, and strict DOCTYPEs will trigger "standards" layout mode

Legacy vs. Standards What's the difference? Plentytoo much to list here, in fact! Some highlights: 'height' and 'width' do not apply to inline elements 'width' means the content's width, not the aggregate of content + padding + border 'class' and 'id' values are case-sensitive units are required on length measures 'body' and 'html' can be styled separately

Common Errors We see a lot of recurring problems… Generally poor structure: TD elements outside of TRs Unclosed TABLE elements SPANs wrapped around DIVs Badly-nested inline elements FORMs spread across multiple cells, or wrapped around a few rows or cells of a table Class and ID names treeated as though they're case-insensitive

An Example of Bad FORM Have you ever done this? … That construct is invalid and can cause functionality and layout problems Similarly, putting the in one cell and in a different cell is a bad idea

Even Worse Markup Here's a popular one: … Yikes! Wrapping an inline element around a block- level element is no good The beginning of a block-level element implicitly terminates any unclosed elements, so the 'span' ends right before the 'div' begins Convert the 'span' to a 'div', adjust your styles and scripts as necessary, and be happy

Enjoy the Free DOM Both IE5+ and NS6 follow the W3C DOM You can manipulate style, structure, even content in a truly cross-browser fashion Any other standards-compliant browser will be able to run the same scripts and get the same results

The Proof Is In The Showing A working example: The show/hide functionality is all W3C DOM- based and does no browser detection at all Confession: there's an OS detect to set the proper graphic effect for the icons

Picking a Piece of HTML There are two basic choices document.getElementById('idname') Lets you manipulate whatever element in the document has that unique 'id' value document.getElementsByTagName('tagname') Lets you manipulate all elements of a given type There isn't a way to select elements by class name, so we'll just have to build one ourselves

getElementsByClassName The source: function getElementsWithClassName(elementName,className) { var allElements = document.getElementsByTagName(elementName); var elemColl = new Array(); for (i = 0; i < allElements.length; i++) { if (allElements[i].className == className) { elemColl[elemColl.length] = allElements[i]; } } return elemColl; } Use notes: To get all elements with a given class call getElementsWithClassName('*','className'); Doesn't work with non-standard browsers (including IE4 and NN4.x)

Forked Source The source: function getElementsWithClassName(elementName,className) { var allElements; = document.getElementsByTagName(elementName); var elemColl = new Array(); if (document.getElementsByTagName) allElements= document.getElementsByTagName(elementName); else if (document.all) { // -=-=- IE4 code fork -=-=- if (elementName=='*') allElements= document.all; else allElements= document.all.tags(elementName); } for (i = 0; i < allElements.length; i++) { if (allElements[i].className == className) { elemColl[elemColl.length] = allElements[i]; } } return elemColl; }

21st Century Forking The past: Forking the script for every browser you want to support Changing the behavior means rescripting in every tine The present: One script, many browsers Changing the behavior is a one-time thing Caveat: support for older browsers still requires forking Of course, you probably already have that code available

If You Must Detect… …do it properly! Detecting on the browser name (navigator.appName) is NOT enough! Both Netscape 4.x and Netscape 6.x will return "Netscape" There needs to be some parsing of the user agent string to see who created the browser and what version it is There are some good practical sniffers on mozilla.org

In Summary Simple steps for simpler authoring Transition from away from proprietary DOMs and toward the W3C DOM The only code forks you should need are for old browsers that aren't up to standard Validate your markup and CSS, and make sure your DOCTYPE is correct Remember that the DOCTYPE affects which layout mode modern browsers will use