Sunday, September 19, 2010

CSS Tips I Wish I Knew When I First Started

CSS Tips I Wish I Knew When I First Started

css webdesign1

I have been working with CSS for many years now, and although it is relatively easy to learn, there are always some tips and tricks that you don’t know about, and new stuff to be learnt all the time. I wanted to take a moment to give you some tips and tricks that I wish I knew when I first started using CSS.

Resets & Browser Inconsistencies

It’s not big secret that not all browsers are created equal. Internet Explorer may show something completely different than Mozilla Firefox. Mozilla Firefox may show something completely different to Apple Safari.

We also don’t know what the default margin, padding, font-size, etc. are for these browsers. To handle these differences, many CSS developers like to level the playing field by creating a CSS Reset. In the early stages, we would have just used a global reset, which would look like the following:

* { margin: 0; padding: 0; }

It soon became clear that resetting only the margin & padding wasn’t really enough. Developers started to created a CSS Reset. Eric Meyer created a widely accepted and comprehensive set of reset rules.

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td {
margin: 0;
padding: 0;
border: 0;
outline: 0;
font-weight: inherit;
font-style: inherit;
font-size: 100%;
font-family: inherit;
vertical-align: baseline;
}

/* remember to define focus styles! */

:focus {

outline: 0;

}

body {

line-height: 1;

color: black;

background: white;

}

ol, ul {

list-style: none;

}

/* tables still need ‘cellspacing=”0″‘ in the markup */

table {

border-collapse: separate;

border-spacing: 0;

}

caption, th, td {

text-align: left;

font-weight: normal;

}

blockquote:before, blockquote:after,

q:before, q:after {

content: “”;

}

blockquote, q {

quotes: “” “”;

}

This has become the most popular CSS reset available today. It is also important to note that some elements have been deliberately excluded from the list, including Input, Button and HR.

User ‘Overflow: Hidden’ to clear floats

I always used to use a clearing div to clear any floating divs I was using. This would always look like the following:

.clear { clear:both; }

Although this does work perfectly fine, it can make your code look messy. Instead you can use overflow: hidden on your container div tag. So you could use the following:

#contain { overflow: hidden; }

Grouping elements together

One of the rules of keeping good coding is to keep your code simple, clean and easy to read. This technique helps with readability as well as performance. In the early days, I used to do two or three elements that are doing the same thing, until I found out you can group these elements together.

So instead of writing:

h1 { color: #444; }
h2{ color: #444; }

You can group these elements like so:

h1, h2 { color:#444; }

Use CSS Shorthand

Using CSS Shorthand has two beneficial aspects to it, the first one being less code. The second is improving the performance. So instead of writing the following:

body {
font-family: verdana;
font-size: .7em;
line-height: 1.4em;
margin-bottom: 10px;
margin-top: 10px;
}

You can write the same thing with less lines and less coding:

body {
font: normal .7em/1.4em verdana,;
margin: 10px 0;
}

Box Model – Margin, Padding & Borders

The box model is the basis for all layouts. If you use CSS, you need to take the box model into account. It governs the dimensions & spacing of the elements on a page.

All box models have five spacing properties: width, height, padding, margin and border. Width and height are tricky attributes, as they require a bit of calculation. When measuring an element’s width, designers must consider the entire box.

Using the example above, the box has a total width of 260px. The margin, padding, and border are 30px each (remember, that’s 30px on top, 30 on bottom, 30 right, and 30 left). So, in this example, the margin takes up 60 pixels of the box’s width. Likewise, the border and padding consume 60px each. All together, the margin, border, and padding amount to 180 pixels of the box’s total width.

We know that the box’s total width is 260px, but in CSS the width attribute refers to the content area on the inside of the box. So, for this example, we have to subtract 180 pixels (for margin, border, and padding) from 260 (total box width), leaving us with a content area of 80px. Therefore, our CSS looks like this:

div {
margin:30px;
border:30px solid yellow;
padding:30px;
width:80px;
height:80px;
}

Conditional Comments

IE is one of the worst browsers to develop CSS for, while most browsers show the same thing about 80% of the time, IE will not. Therefore you will be doing a lot of IE Hacks to make sure your website shows the same in all browsers.

This can take a lot of CSS to accomplish, making your main style sheet larger than it really needs to be. So the easiest way to accomplish this is to use the HTML conditional comments to detect IE browsers and display the CSS.:


Target All versions of IE

Using conditional comments to target IE and cut out your hacks will slim down your main style sheet, and help load the page quicker in browsers that don’t need the correction code.

That’s it

That’s it for now. I am always learning new stuff, and with CSS3 making its way through, there will more than likely be another tutorial on the way.

Design is in the Details: Using CSS Selection Pseudo-Classes to Declare Your Team Spirit

css3 using selection pseudo-classesI’m hesitant to admit it, but I’m not a huge football fan. My boyfriend, however, loves “his” team — the USC Trojans. And if there’s one thing I’ve learned over the years, it’s that football fans will use any excuse to dress up or decorate with their team colors. Actually, real fans don’t even need a reason to show team spirit.

So, in honor of football fans everywhere and to kick off the fall football season in America, I thought it would be fun to show how to use one of the new tools in CSS3 to decorate a web page with your team colors. Let’s play with the selection declaration.

There are many neat design tricks in CSS3. The selection declaration — ::selection — is a quick way to add some polish onto a design and give a website the “wow” factor that really makes clients happy. Using a .selection class can override the operating system’s default highlight color with any color you specify.

As with so many of the best html and css goodies, browser support varies. Safari and Firefox both recognize the selection declaration, but you’ll need to implement the code a bit differently for each browser. Here’s how to use CSS3′s new selection declaration to add a dash of unexpected color to your web design. Read more

iPhone 4 GUI PSD (Retina Display)

Thanks for you patience on this one. It took a good deal longer to complete given the sheer size and level of detail the retina display has. It wasn’t a simple scale-up from the last file. It was clear as we created it that Apple has spent a lot of time considering how each element should be translated to such a dense resolution. What were single pixel elements are now two or three pixels thick and effects are exaggerated to become visible. For anyone designing for the retina display (640×960) it really is quite a different experience. When you work at 100% everything seems absolutely huge but small details get lost when viewing it on the device. You really need to be mindful of how it looks on the phone since your monitor displays things so differently.

The file is huge, both in file size (62.7MB) and dimension (4074×2986). You’ll need to work at 25% – 50% even on the largest screens to roughly grab elements before zooming into 100% for the actual work.


From: http://www.teehanlax.com/

Free High-Quality Useful Icon Sets

When it comes to freebie designs, beautiful icons sets are tops. Designers scour for these free treasures more than anything else. You can use icon sets in Web applications, website designs and on your desktop. If well designed, they make a great impression on others. Beautifully designed icons also prove the quality of a designer’s work, so many designers make theirs freely available online, thus giving their work more exposure.

In the overview below, we present 50 beautifully designed, free and professional high-quality icons for desktop and Web design. All of them can be freely used for private projects, and some are available for commercial use as well. Regardless, always read the licenses — they may change from time to time.


From : http://www.smashingmagazine.com/



50 Beautiful, Free and High-Quality Icon Sets

Container Icon Pack
Container Icon Pack contains 40 high-quality (256 x 256 pixel) icons in PNG and ICO formats. This package includes box, cargo, trash icons and more. Created by Mehmet Gozetlik.

Transp in 50 Free High-Quality Icon Sets

Baggy Icon Set
Contains five high-quality icons in three formats (ICO, ICNS and PNG) and six sizes, ranging from 16 to 512 pixels!

Baggy-icon-set in 50 Free High-Quality Icon Sets

Round theme icons
A beautiful set of 106 various rounded icons.

Docky in 50 Free High-Quality Icon Sets

Fortune 500 Badges
Over 200 badges of famous brands, PSDs included.

Brands in 50 Free High-Quality Icon Sets

Red Moleskine
Red Moleskine is a beautiful icon set in PNG format and sizes of 16, 32, 64, 128, 256 and 512 pixels.

Red-Moleskine in 50 Free High-Quality Icon Sets

Old-School Icon Set
A set of six beautiful old-ish icons: typewriter, camera, radio, TV set, Gameboy, and telephone. In PNG and ICO.

Oldschool in 50 Free High-Quality Icon Sets

Playground
Nine beautiful and original icons (in PNG and ICO), created by the talented Miriam Moshinsky.

Gorg in 50 Free High-Quality Icon Sets

Windows 7 Build
A set of various basic software and office icons.

 in 50 Free High-Quality Icon Sets

Classic Timer Icon
A quality timer icon in transparent vector format, with different sizes.

Classic-timer-icon in 50 Free High-Quality Icon Sets

Nes Icons Pack
A set of retro icons (TV, NES, Pad, Alimentation box, Zelda box, Zelda game, Desktop, 1up, Magic Toad) in ICO and PNG (512 × 512 pixels).

Retr in 50 Free High-Quality Icon Sets

Jeans Feed Icons
A set of stylish feed icons as denim pockets.

Icon-Feed-Jeans in 50 Free High-Quality Icon Sets

Cemagraphics Icons
A set of various beautiful icons in PNG (32 × 32 and 512 × 512 pixels).

Icn in 50 Free High-Quality Icon Sets

To-Do List Icon
Use these icons in your Web applications to make them more attractive.

To-Do-List-Icon in 50 Free High-Quality Icon Sets

Social Media Handycons
Handycons is a free hand-drawn set of 12 social-media icons. All icons are available in four sizes: 16, 24, 32 and 48 pixels.

Social-media-handycons in 50 Free High-Quality Icon Sets

Canon 400D + lens 17-85mm
Set of two icons: camera and lens. Comes in sizes of 512 and 16 pixels and iContainer, ICNS, PNG and ICO format.

Canon-400D in 50 Free High-Quality Icon Sets

Retrofukation
A stylish set of icons to complement almost any theme out there. Designed to be easily distinguishable, simple and intuitive. This icon pack contains over 100 icons. Designed by Jamie Green.

Retro2 in 50 Free High-Quality Icon Sets

e-Commerce Icons
A huge set of icons that you can use for an online shop.

Prod in 50 Free High-Quality Icon Sets

Function icons set
A beautiful and useful set of 128 icons, available in 48 × 48 pixels.

Wef in 50 Free High-Quality Icon Sets

Elementary Icons
A set of smaller Web developer-style icons.

 in 50 Free High-Quality Icon Sets

Human 02
Here is a nice multi-purpose icon set for your business website.

 in 50 Free High-Quality Icon Sets

32px Mania Icon Set
Another series of smaller icons that can add flair to any website design.

 in 50 Free High-Quality Icon Sets

Business Icons
A collection of random business-related icons with a Web 2.0 look.

 in 50 Free High-Quality Icon Sets

Chums Icon Set
This is the ultimate collection of high-quality tech-related icons. You can find everything from iPods to digital cameras.

 in 50 Free High-Quality Icon Sets

Tom Tom
Does your business deal with GPS and navigation systems? Then this is the icon set for you.

 in 50 Free High-Quality Icon Sets

Black Neon Agua Icons
A unique icon set that is ideal for darker website designs.

 in 50 Free High-Quality Icon Sets

Credit Cards Icons
15 beautiful credit card icons in AI and EPS format. And here are yet more credit card icons.

Cred in 50 Free High-Quality Icon Sets

Antique Icons
A set of antique icons in PNG, ICNS and ICO formats, ranging from 16 × 16 to 256 × 256 pixels.

Retro3 in 50 Free High-Quality Icon Sets

Hand-made food and beverage icon set
Seventeen hand-drawn icons, created by Victor Amanatidis.

Kilo in 50 Free High-Quality Icon Sets

Social Media Mini Iconpack
This icon set consists of 30 finely crafted social media icons in a size of 16 × 16 pixels. They are free to use non-commercially.

Sm in 50 Free High-Quality Icon Sets

Manto Smiley Icon Set
Twenty original emoticons by Chinese designer Manto.

Manto in 50 Free High-Quality Icon Sets

Emotions For WordPress Icons
Emoticons for WordPress.

Ew in 50 Free High-Quality Icon Sets

Green and Blue Icon Set
Five icons, each in 128 × 128 pixels and PNG format. Included are icons to represent gallery, downloads, emoticons, calendar and folder.

May in 50 Free High-Quality Icon Sets

Airport Express
This icon is for personal use only. Download includes iContainer, PNG and PSD formats.

Airport-Express in 50 Free High-Quality Icon Sets

Coquette Part 3 Icons
This free playful icon set contains curvy and colorful icons made with one goal: to get some affection and playfulness into your projects. The 50 high-quality icons come in sizes of 16, 32, 48, 64 and 128 pixels, and in 32-bit transparency PNG format.

Coquette-Part-3-Icons in 50 Free High-Quality Icon Sets

Email Me Icons
These icons are free for personal use and available in 32, 48, 64 and 128 pixels.

Email-me-icons in 50 Free High-Quality Icon Sets

Reality
A set of beautiful, realistic icons of different daily-use object. These are free for non-commercial use.

Reality in 50 Free High-Quality Icon Sets

Music Icons
Beautiful icons of music instruments. Icons are absolutely free for any purpose.

Music-icons in 50 Free High-Quality Icon Sets

Sleek XP: Basic Icons
A set of 50 stock icons in PNG and ICO formats.

Sleek-XP-Basic-Icons in 50 Free High-Quality Icon Sets

Set of Social Icons
A set of beautiful social icons in PNG format and sizes of 16, 32 and 64 pixels.

Set-of-social-icons in 50 Free High-Quality Icon Sets

GP Icons
A set of 23 PNG icons of different software products. Has a great grunge style.

GP-iCons in 50 Free High-Quality Icon Sets

Banking Stuff Icons
Banking-related icons for non-commercial use, in sizes of 32, 48, 64, 128 and 256 pixels.

Banking-Stuff-icons in 50 Free High-Quality Icon Sets

Smashing Magazine’s Icons

Smashing Retro Icon Set
A set of 10 beautiful, high-quality “vintage” icons. The set contains 10 original icons: search, sign-up, calendar, news, RSS, comments, email, ads, home and address.

Preview2 in 50 Free High-Quality Icon Sets

Flavours Icon Set
This set, aimed to help designers in their Web and user interface designs, contains 177 icons in a resolution of 48×48 pixels. The files are available in the PNG and PSD sources, so you can modify the files as you wish. Created by Oliver Twardowski.

Flavour-preview in 50 Free High-Quality Icon Sets

Stationery Icons Set
A useful set of 22 vector icons (256 × 256 pixels). It contains book, brush, crayon, clip, color pencils, document, eraser, pad, palette, post-it note, scale and scissors, as well as the Fireworks source file.

Stat-smallpreview in 50 Free High-Quality Icon Sets

On Stage Icons Set
The set contains 49 free vector icons, including PSD, which can be useful for both corporate and personal projects. You can use the set for free, without any restrictions whatsoever. The icons are available in PNG format in a resolution 128×128 pixels. Also included in the package are 100% pure shape-based layered PSDs.

Df On Stage Preview in 50 Free High-Quality Icon Sets

Fresh Icons Set
This set contains 59 raster and vector icons. The set includes icons in PNG, ICNS and ICO formats. An EPS vector file is available as well.

Release in 50 Free High-Quality Icon Sets