Viewers: in countries Watching now:
In this hands-on course, James Williamson demonstrates the concepts that form the foundation of Cascading Style Sheets (CSS), including styling text, adding margins and padding, and controlling how images display. The course also explores the tools needed to work with CSS, the differences between embedded and external styles, how to use selectors to target elements, and what to do when styles conflict.
Although every browser has its own set of quirks and bugs, you're probably going to spend more time dealing with Internet Explorer's bugs and specific issues than with any other browser. Now due to Explorer's large user base, you usually don't have the option of simply ignoring it and hoping that users will simply use a more standards-compliant browser. I mean, to be honest, Internet Explorer 9 is fairly standards-compliant. It's a really excellent browser, but there are still a large portion of users out there still using earlier versions, so what this all boils down to is that you simply have to have a site-wide strategy for dealing with Internet Explorer's quirks.
Before going too deep into developing a browser strategy, I want you to introduce you to positioniseverything. You can find this site at positioniseverything.net. Now, this site consists primarily of older information, but it is still the go- to guide on browser bugs and ways around those bugs, and it has a primary focus on Internet Explorer. So if you're new to CSS, reading through these past articles will give you a solid foundation into browser and standards development over time and how to address browser bugs.
While most browser bugs have fixes that you can use and those are often referred to as hacks, those hacks aren't necessarily a good idea. Often fixing a bug in one version can actually trigger an error in another version. Now for the most part, they add extra weight to your code, and they can make maintaining your site difficult, especially in a team environment where keeping track of when and where hacks are being used can be really, really difficult. More importantly, they can cause problems with future versions of browsers as well. Now, if all this seems rather maddening, it's because it is.
Learning about and dealing with various browser-CSS-related issues is one of the most vexing but necessary things that you're ever going to do as a web designer. And there are various ways of dealing with Internet-Explorer-specific issues, and I can't recommend strong enough researching and learning as many cross-browser-compatibility issues as possible. Doing so will help shape and guide your overall browser-compatibility strategy. In the end the strategy that you use will depend on the browsers and browser versions that you need to support. And while I can't say that there is any one perfect strategy to use, I can discuss the ones that I use when approaching browser inconsistencies. It's the result of many years of dealing with bugs and my own personal focus on generating clean, maintainable code.
First, I try very, very hard to avoid using hacks. Now, a browser hack usually consists of a really odd-looking selector or rules written in a way that one browser will interpret it and render it, while the remaining browsers just ignore it or even overwrite the hack. Rather than use hacks, I try to avoid design issues that trigger browser errors altogether. Now to illustrate this, I want to go back to IE 6. In Internet Explorer 6 if you floated an element to one direction and also placed a margin on the same side, IE 6 would double the margin value.
While there was a way to solve this, I chose to simply never apply a margin in the same direction as a float. That way I avoided the invalid code required to fix it, while never triggering the bug. It's a habit that I still stubbornly cling to today, even though it is no longer necessary. That means that you have to be diligent in learning all you can about browser bugs and how they're triggered, so that you can avoid them when possible. Once you understand the various browsers and their issues, you'll find that you start designing with them in mind.
This may seem limiting, but in reality, you can do anything you want visually and stay within those browser constraints. Next, if I have to deal with IE- specific errors, I'll place all Internet- Explorer-specific CSS fixes in separate files and serve them through conditional comments, as shown here. Now this reduces the weight of extra markup in my CSS, filters the browser- specific styles so they go directly to the browser that needs them, and makes it easier to update my code by making any hacks easy to locate and update.
You can even create conditional comments through specific versions or a range of Internet Explorer. For example, this one is saying if less than in the Explore 9, so be research IE-specific conditional comments and how to serve CSS through them. And finally, I've long ago given up on the notion that my pages are going to look exactly the same in every single browser. As a designer, that may seem disappointing, but let's be honest. The web is constantly evolving, with additional devices and browsers being added all the time. Thankfully, most devices have embraced standards to one degree or another, making our job a little bit easier.
By designing along existing web standards, we can make sure that the widest possible audience can see our content the way that we intended. By making sure that my design has the flexibility to still be impactful, regardless of a minor rendering issue here or there, I make sure that that page actually works in a wider array of clients. I'm not claiming that this strategy is the best, but I found it to be very effective for my own sites. I encourage you to do as much research as you can into browser differences and rendering issues. Based on what you learn, who your target audience is, and the requirements of your content, you're going to develop a strategy that works for you and does the best possible job of ensuring consistent user experience.
There are currently no FAQs about CSS: Core Concepts.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.