# CSS and Web Design

# Learning about CSS

<span class="caps">CSS</span>, or Cascading Style Sheets, have taken over the design end of websites, it seems. I’m not that good with them yet, so I’m starting to collect useful <span class="caps">CSS</span> Links.

- [http://css.maxdesign.com.au/](http://css.maxdesign.com.au/) – *Great site to learn <span class="caps">CSS</span>. Straightforward to find available topics.*
- [http://www.csszengarden.com/](http://www.csszengarden.com/) – *an amazing demonstration of what can be accomplished visually through <span class="caps">CSS</span>-based design. Each link on the side shows exactly the same text with a completely different <span class="caps">CSS</span> design and layout.*
- [http://businesslogs.com/design\_and\_usability/my\_5\_css\_tips.php](http://businesslogs.com/design_and_usability/my_5_css_tips.php)
- [http://del.icio.us/tag/css](http://del.icio.us/tag/css)

Here is a list of Books that were recommended thru the <span class="caps">CWP</span> group.

1\. [Designing With Web Standards](http://www.amazon.com/exec/obidos/ASIN/0321385551/ref%3Dnosim/jeffreyzeldmanprA/) – Jeffrey Zeldman

2\. [<span class="caps">CSS</span> Definitive Guide](http://www.amazon.com/CSS-Definitive-Guide-Eric-Meyer/dp/0596527330/sr=1-3/qid=1171569720/ref=pd_bbs_sr_3/002-3753062-0508037?ie=UTF8&s=books) OR [http://proquest.safaribooksonline.com/0596527330](http://proquest.safaribooksonline.com/0596527330)  
has a ton of info — better as a reference than to just read since it’s information overload – it covers all sorts of minute details on <span class="caps">CSS</span> and is guaranteed to give you a headache.(Sue)

3\. [<span class="caps">CSS</span> Cookbook](http://www.amazon.com/CSS-Cookbook-2nd-Christopher-Schmitt/dp/0596527411/ref=pd_sim_b_2/103-4788431-9696611?ie=UTF8&qid=1171569720) by Christopher Schmitt -

4\. [The Zen of <span class="caps">CSS</span> Design](http://www.amazon.com/Zen-CSS-Design-Visual-Enlightenment/dp/0321303474/sr=8-1/qid=1171569312/ref=pd_bbs_1/002-3753062-0508037?ie=UTF8&s=books): Visual Enlightenment for the Web is a great book for design ideas from a more artistic than technical standpoint.

5.[Web Developers Handbook](http://www.alvit.de/handbook/)

6.[Bullet Proof Web Design](http://www.amazon.com/Bulletproof-Web-Design-flexibility-protecting/dp/0321346939): Improving flexibility and protecting against worst-case scenarios with <span class="caps">XHTML</span> and <span class="caps">CSS</span> (Paperback) by Dan Cederholm (Author)

7\. [<span class="caps">CSS</span> Mastery](http://www.amazon.com/CSS-Mastery-Advanced-Standards-Solutions/dp/1590596145/ref=pd_bxgy_b_img_b/102-9974745-6216962): Advanced Web Standards Solutions (Paperback)  
by Andy Budd (Author), Simon Collison (Author), Cameron Moll (Author)

Also, don’t forget that <span class="caps">UCLA</span> has access to Safari Online [Proquest](http://proquest.safaribooksonline.com/)) which lists 5 or 6 books on <span class="caps">CSS</span> that you can read online for free from a <span class="caps">UCLA</span> computer (or using the <span class="caps">VPN</span> from off-campus).(Sue)

# What sort of menus can I make with CSS?

There are practically no limits to what you can do with <span class="caps">CSS</span>, the trick is figuring out how to make it do what you want! Or another way of looking at it is: what sort of ideas can you come up with to use <span class="caps">CSS</span> in a new (and hopefully useful) way?

Here are just a few common things you’ll see sites do with <span class="caps">CSS</span>:

- Drop-down menus that show up when you hover your mouse over them
- Pull-up menus, that go up instead of down
- Horizontal menus
- Nested hierarchical menus
- Menus with images in them
- Stylized borders

Tons of great examples can be found here: [http://www.cssplay.co.uk/menus/index.html](http://www.cssplay.co.uk/menus/index.html)

# Top Ten Web Design Mistakes of 2005

By Jakob Nielsen:

[http://www.useit.com/alertbox/designmistakes.html](http://www.useit.com/alertbox/designmistakes.html)

# The importance of "!important" in CSS

Normally, <span class="caps">CSS</span> works by having the most recently-declared rule take precedence. However, this isn’t always the case. Rules can be followed by the expression “!important” to give them precedence over later rules.

This can come up a lot in systems like Plone, where a large amount of <span class="caps">CSS</span> has already been written, to which you make your own additions. The existing <span class="caps">CSS</span> may use !important rules which will override any rules you declare, no matter where you place them. Needless to say, this can be very confusing, since it goes against what most of us have been taught about <span class="caps">CSS</span>.

Most of the time, you’ll be using !important to get your new <span class="caps">CSS</span> to override some existing rules that have been declared !important. An example usage would be:  
`p { font-size: 10px !important; }`

This makes sure that later <span class="caps">CSS</span>, including user stylesheets that browsers sometimes apply, does not override this rule. However, many times you’ll want to override a rule that has already been declared !important. To do so, just make your new rule !important as well, and place it somewhere after the rule you want to replace.

Internet Explorer 6 and earlier versions do not recognize the !important rule. If you are trying to override someone else’s !important rules, this does not matter much, since your later rules will override them no matter what. However, if you are trying to create new rules that user stylesheets won’t override, you’re out of luck. IE7 should fully support the rule.

The official W3C word on !important can be found at: [http://www.w3.org/TR/](http://www.w3.org/TR/)<span class="caps">REC</span>-CSS2/cascade.html#important-rules

Number 4 out of [Ten <span class="caps">CSS</span> tricks you may not know](http://www.evolt.org/ten-css-tricks-you-may-not-know) mentions the lack of !important support in IE6, and how it can be used to feed it browser-specific code.

# CSS Design Concerns for IE6, IE7, and Firefox

Below is the beginning of (hopefully) an ongoing collection of design-related <span class="caps">CSS</span> issues concerning different browsers. For this initial posting, I focus on Firefox, IE6, and IE7.

The good news regarding IE7 is that a lot of bugs were fixed. See the following for a [list of fixes.](http://blogs.msdn.com/ie/archive/2006/08/22/712830.aspx)

Unfortunately, those improvements leave a fairly large gap between how IE6 and IE7 render the same <span class="caps">CSS</span>. See [http://kimblim.dk/csstest/](http://kimblim.dk/csstest/) for a good look at <span class="caps">CSS</span> testing of Selector and Pseudo-selectors for Firefox, IE6, IE7b3, and Safari. You will notice that IE7 and Firefox display more similarly than IE7 does with IE6.

If you looked through the above site, you noticed that IE6 did not properly display any of the Selectors and Pseudo-selectors that were tested. In an effort to demonstrate some of the steps that can be taken to make the same page (or element within a page) display similarly across IE6, IE7, and Firefox, I listed some **workarounds** (min/max-width, inline vs. block-level elements) for a few of the tested Selectors and Pseudo-selectors. You will find them at: [http://www.sscnet.ucla.edu/ssc/lederman/browser\_design\_issues\_1.html.](http://www.sscnet.ucla.edu/ssc/lederman/browser_design_issues_1.html)

Some general ways to deal with IE6:

In an effort to have your web pages validate, use Conditional Comments to write browser specific rules/code, etc. You can find more info at: [http://msdn.microsoft.com/workshop/author/dhtml/overview/ccomment\_ovw.asp.](http://msdn.microsoft.com/workshop/author/dhtml/overview/ccomment_ovw.asp)

When using Conditional Comments, make sure that the links for them come later than the main <span class="caps">CSS</span> file link in the coding, <span class="caps">AND</span> that the rules within the Conditional Comment have at least the same or higher specificity than any similar rules in the main sheet. Otherwise, the rules in the Conditional Comments will not override the main <span class="caps">CSS</span>.

Though not an ideal solution, hacks can be helpful at times. A [list of <span class="caps">CSS</span> hacks.](http://brunildo.org/test/csshacks.html)

Two common hacks, the Star <span class="caps">HTML</span> hack and the Underscore hack, both IE-specific, (you can see a list of common hacks specific to which browsers at [http://www.centricle.com/ref/css/filters](http://www.centricle.com/ref/css/filters)), can be avoided using the following approach:

Write a rule, adding the IE-specific declaration.

.title h3 { height: 21px; }After each rule, add a second rule using a child selector. This is key because IE6 will ignore this rule, but Firefox and IE7 will apply it.

.title h3 {height: 21px; }  
 .title &gt; h3 {height: auto; min-height: 21px; }

Though this leaves your <span class="caps">CSS</span> a bit bloated, it is an approach that avoids using these two common hacks in favor of a <span class="caps">CSS</span>-based solution. I should note that I havenï¿½t tested this approach yet using really *complicated* coding. Iï¿½ve read that the above method requires you to be operating in strict mode, however, I found the method to work just fine (as far as I tested it) while in transitional mode. Test away!

# Forcing a page break with CSS

Here is a simple style sheet method for making a web page have page breaks, or form feeds in it.

**Example:**

Try going to the following example page and printing it. It will come out on two separate pages. [http://www.sscnet.ucla.edu/test/formfeed.htm](http://www.sscnet.ucla.edu/test/formfeed.htm)

**Source Code:**

```
1. <html><head><title>Form Feed Test</title>2. <STYLE TYPE="text/css"> P.newpage {page-break-before: always} </STYLE>3. </head>4. <body>5. <center><h1>Page 1</h1></center>6. <P CLASS="newpage">7. <center><h1>Page 2</h1></center>
```

**Explanation:**

- Line 2 is where you set up your style sheet definition.
- Line 6 shows what you put wherever you want a page break.

# What's a solid starting point (global reset) for a CSS file?

Browsers often have different ways of rendering the same element. For example we expect lists to be left-indented. Firefox does this by applying a left padding of 40 pixels to an unordered list (`<ul>`). Either Opera or Internet Explorer acheives the same effect by applying a *margin* of 40 pixels.

Now this is fine and dandy if you don’t want to change that indent value.

Let’s say you test in Firefox want to pull the list back a little so you:

`ul {  padding-left: 30px;}`

Looks good… until some other browser adds that 30 pixels of padding onto their 40 pixels of margin. Crap. The original solution proposed was simple and elegant:

``

- {  
     padding:0;  
     margin:0;  
    }

It also broke forms and obviously is not inclusive of everything for a true “global whitespace reset.” You can read more on this implementation (which was revised) on the now classic [leftjustified.net](http://leftjustified.net/journal/2004/10/19/global-ws-reset/) post.

Yahoo! have their [own <span class="caps">CSS</span> Reset](http://developer.yahoo.com/yui/reset/), which has a broader scope. Not sure setting h1 through h6 at 100% is an improvement over default behaviour though. ^^

An alternate (still in progress) reset [is up at Eric Meyers website](http://meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded/), and has evolved through a couple comment heavy blog posts.

# UX Team ( UCLA Library - Digital Initiatives & Information Technology )

The UX Team is charged by the <span class="caps">UCLA</span> Library Digital Initiatives &amp; Information Technology leadership to improve the user experience of all library digital interfaces by

- Adopting an improved and systematic UX process on new projects/products
- Auditing and remediating legacy applications
- Maintain that capability by moving from Stage 3 to Stage 4 in the maturity model
- UX prior to coding
- Design as problem-solving process (driven by data, goals) not just style and form
- Increase repertoire of UX tools
- Expand UX team
- Achieve official designation
- add new roles and membership
- UX champion in upper management

UX Team   
Joshua Gomez  
Tinu Awopetu  
Ashton Prigge  
Sharon Shafer

# Hi, are there any UCLA style resources or style guides for websites?

Edit: 9/7/2012  
<span class="caps">UCLA</span> released Brand Guidelines 1.0 in March 2012. The document contains guidance on things like fonts, colors, tone, photography, and design. There are new colors and a lot of colors got discontinued, like all of the greys.

<span class="caps">UCLA</span> also released the templates for the web gateway in <span class="caps">HTML</span> only. They are available here: [www.images.ucla.edu](http://www.images.ucla.edu). <span class="caps">UCLA</span> employees will be able to log in via their Bruin Online ID. If you’re not an employee (ie you are student or a volunteer), you will need to register for an account.

—Sirinya Tritipeskul Matute, <span class="caps">UCLA</span> Fund

---

Here is the website for the <span class="caps">UCLA</span> Graphic Identity: [http://www.identity.ucla.edu/](http://www.identity.ucla.edu/)  
It has information on the <span class="caps">UCLA</span> Logo and colors.

I would suggest you visit The <span class="caps">UCLA</span> Campus Web Publishers (<span class="caps">CWP</span>): [http://cwp.ucla.edu/](http://cwp.ucla.edu/)  
There you will find many resources including the above site.

# UX Resources

[http://ux.stackexchange.com/](http://ux.stackexchange.com/)

[https://www.reddit.com/r/userexperience/](https://www.reddit.com/r/userexperience/)

[http://uxmyths.com/](http://uxmyths.com/)

# What to do when CSS stylesheets refuse to apply

There are a number of common mistakes users make when writing <span class="caps">CSS</span> stylesheets that are difficult to debug. Because browsers differ in how picky they are about errors, pages may look fine in some browsers but wrong in others. A common symptom of these problems is large sections of your page that seem to have no styles applied to them at all.

One mistake when writing <span class="caps">CSS</span> is to comment your stylesheets using the hash sign (#), which is used in many languages such as Perl and Python to denote comments. In <span class="caps">CSS</span>, however, it’s used as an ID selector, meaning your “comments” will be interpreted as strange <span class="caps">CSS</span>. The proper way to comment <span class="caps">CSS</span> code is to use C-style comments, which begin with `/*` and end with `*/`. They do not have to begin and end on the same line, but take care not to nest comments.

Another mistake is omitting the semicolon (;) after each attribute. You don’t need semicolons after selectors or brackets, just after assigning attribute values such as `border: none;`. Some browsers are fine without semicolons, others are not. To be safe, always use them.

Finally, try adding the phrase `!important` at the end of a rule that refuses to apply, right before the semicolon. (For users of IE 6 and below, don’t bother, this keyword isn’t supported.) See [the importance of !important in <span class="caps">CSS</span>](https://kb.ucla.edu/link/636) for an explanation why.

A great resource when debugging tricky <span class="caps">CSS</span> problems is the W3C <span class="caps">CSS</span> validator: [http://jigsaw.w3.org/css-validator/](http://jigsaw.w3.org/css-validator/)

Here’s another: [Will the browser apply the rule(s)?](http://centricle.com/ref/css/filters/)

# Web Accessibility Resources

This article is a resource list to help Web developers design sites that are accessible to persons with disabilities. The list will evolve as technology changes, and also in response to issues raised by <span class="caps">UCLA</span> Web developers. It will be further supplemented by other materials produced by the [<span class="caps">UCLA</span> Disabilities and Computing Program](http://www.dcp.ucla.edu) .

See also other articles in this Knowledge Base under the “accessibility” tag.

## UC System Accessibility

“Accessible Web Design Resources ":[http://www.ucop.edu/irc/itaccessibility/resources/](http://www.ucop.edu/irc/itaccessibility/resources/) This will collect best practices for Web designers across the UC’s. For those already familiar with basic accessibility concepts, the [Design Tips](http://www.ucop.edu/irc/itaccessibility/resources/designtips/) and [Technical Topics](http://www.ucop.edu/irc/itaccessibility/resources/techtopics.html) pages will be the most immediately useful.

## WebAIM

Web Accessibility In Mind (WebAIM) at Utah State University has emerged as a leading reference site for many accessibility topics.:

[Introduction to Web Accessibility from WebAIM](http://www.webaim.org/intro/)  
[Resources from WebAIM](http://www.webaim.org/resources/) , including [Evaluating Web Sites for Accessibility with the Firefox Web Developer Toolbar](http://www.webaim.org/articles/evaluatingwithfirefox/) ;  
The [<span class="caps">WAVE</span> Accessibility Tool](http://wave.webaim.org/) , and many more.

## Others

[World Wide Access: Accessible Web Design](http://www.washington.edu/doit/Brochures/Technology/universal.design.html) (University of Washington, DO-IT Program)

“Accessibility tagged articles from 456Berea Street blog ":[http://www.456bereastreet.com/archive/categories/accessibility/](http://www.456bereastreet.com/archive/categories/accessibility/) (current issues in accessibility and usability)

# Sass versus LESS

Quoting, "One of the hot new trends in web design is <span class="caps">CSS</span> pre-processed languages and there’s two big ones vying for your attention—LESS and Sass. <span class="caps">LESS</span> and Sass are both ways of writing <span class="caps">CSS</span> code with a syntax that allows you to use features not yet available with Cascading Style Sheets (<span class="caps">CSS</span>), such as variables, nesting, conditionals, and more.

Pre-processed <span class="caps">CSS</span> languages add features to <span class="caps">CSS</span> that aren’t there yet—like variables, conditionals, and functions. They’re called pre-processed, because their final step is a processing, also called compiling, that converts the pre-processed language to regular <span class="caps">CSS</span>. In a nutshell, what you use on your site ends up being plain vanilla <span class="caps">CSS</span>, but comes as a result of processing the <span class="caps">LESS</span>, Sass, or other pre-processed language files you create." *via [Lynda.com blog](http://blog.lynda.com/2012/07/20/an-introduction-to-less-and-sass-pre-processed-css-languages/)*

Review links—

- [http://coding.smashingmagazine.com/2011/09/09/an-introduction-to-less-and-comparison-to-sass/](http://coding.smashingmagazine.com/2011/09/09/an-introduction-to-less-and-comparison-to-sass/)
- [http://css-tricks.com/sass-vs-less/](http://css-tricks.com/sass-vs-less/)
- [http://www.hongkiat.com/blog/sass-vs-less/](http://www.hongkiat.com/blog/sass-vs-less/)
- [http://blog.lynda.com/2012/07/20/an-introduction-to-less-and-sass-pre-processed-css-languages/](http://blog.lynda.com/2012/07/20/an-introduction-to-less-and-sass-pre-processed-css-languages/)

Lynda.com has modules on the topic—

- **<span class="caps">CSS</span> with <span class="caps">LESS</span> and Sass**, [http://www.lynda.com/](http://www.lynda.com/)<span class="caps">CSS</span>-tutorials/<span class="caps">CSS</span>-<span class="caps">LESS</span>-<span class="caps">SASS</span>/107921-2.html
- **Responsive <span class="caps">CSS</span> with Sass and Compass**, [http://www.lynda.com/](http://www.lynda.com/)<span class="caps">CSS</span>-tutorials/Responsive-<span class="caps">CSS</span>-Sass-Compass/140777-2.html

Resources—

- [http://sass-lang.com/](http://sass-lang.com/)
- [http://lesscss.org/](http://lesscss.org/)
- [http://incident57.com/codekit/](http://incident57.com/codekit/)
- [http://gruntjs.com/](http://gruntjs.com/)
- [http://compass-style.com/](http://compass-style.com/)
- [http://css-tricks.com/semantic-class-names/](http://css-tricks.com/semantic-class-names/)
- [http://codepen.io/](http://codepen.io/)