Showing posts with label CSS. Show all posts
Showing posts with label CSS. Show all posts

Friday, December 14, 2007

Semantic Naming Conventions for CSS

Be Consistent

Consistently write the code the same way. This helps make the code easier to read and more managible.


Be Managable

As well as consistency, you may have to do other things to help other people on your team manage code more easily like not using shortcuts when working with programmers who are less familiar with css and having a set of semantic naming conventions for everyone to use.


Semantic Naming Conventions


Consider "structural naming, as opposed to presentational naming" - Eric
Meyer


Consider the semantic role. Here's a naming conventions table of names used on popular websites.

Using the same names helps write code faster. This means that you may end up writing the same code over and over. A CSS Framework can help you use the CSS you have already written for other projects.


CSS Frameworks

Here is a place to start on the subject:




Other ways to make your life easier

Introducing BleachedBlack and White: without the distractions of colour



Read More at

Thursday, May 31, 2007

Cleaning your code

More Importantly, First:
validate your markup

CSS:
CSS Superdouche

Friday, April 27, 2007

They're All in the Same Gang

Oh, a link to Vitamin again. Yeah, yeah, yeah, what is that? I'll get to it later. And why is it listed among the likes of alistapart, eric myer, mezzoblue?

Answer: Their Advisory Board consists of...
*Dan Cederholm: SimpleBits
Thomas Fuchs
: Script.aculo.us
Cal Henderson: Flickr
*Molly E. Holzschlag: molly.com
*Shaun Inman: Mint
Jeffrey Kalmikoff: Threadless
*Eric Meyer: meyerweb.com
*Mike Rundle: 9rules
*Dave Shea: CSS Zen Garden & mezzoblue
*Jeff Veen: Google
*Ryan Carson: Carson Systems

*all authors on alistapart and/or referenced in alistapart articles

They're all in the same gang!

So I will start to map out the Gang connection starting with ALA as a connection source:
ALA
}SimpleBits -- Dan Cederholm
}Mint -- Shaun Inman
}9rules -- Mike Rundle
}CSS Zen Garden -- Dave Shea
}mezzoblue -- Dave Shea
}Adaptive Path -- Jeff Veen
}Zeldman Presents -- Jeffery Zeldman
}HappyCog -- Jeffery Zeldman
}Various -- Ryan Carson, Eric Meyer, Molly E. Holzschlag

Wednesday, April 25, 2007

CSS for Print

Quick Link: Going to Print

Standards Compliant
W3C CSS Print Profile [css3]
W3C Paged Media [css3]
W3C XHTML Print DTD

CSS Print Media


Seperate styles will need to be added for printing. You have options on how you can add them to your code:
Link (preferred)
link rel="stylesheet" type="text/css" media="print" href="print.css" /
Import
@import url(paged.css) print,projection;
Embed
STYLE type="text/css"
@media print {
BODY {font-size: 10pt; line-height: 120%; background: white;}
}
@media screen {
BODY {font-size: medium; line-height: 1em; background: silver;}
}
/STYLE


Remove the Extras
#header, #footer, #nav { display: none; }


"What I do is gang up all the things we don’t want to print in a single block at the top of the sheet. I always know where the 'don’t print' stuff is, and removing another thing from the printout is as easy as adding the class or ID selector to the common display: none; rule." - Jason Fried (getting things done the simple way) [3]
Floats Don't Always Print
Well, they only print from Gecko-based browsers. So cross-browser printing means stopping the floats.
#floatedContent { float: none; }

Bye, Bye Backgrounds
Get rid of background images and colors by setting your body background to white and all other content with background images or colors to transparent. Remember to update your font colors also when you were using light font on a dark background.
body { background: white; }
#contentWithBackgrounds { background: transparent; }

Print Readability
Use points and serif fonts (Georgia, Times New Roman) for print. All font sizes that are not relative (% or em) to the body font size will have to be adjusted (ex. 12px changed to 12pt; 14px changed to 14pt).
body { font-size: 12pt; font-family: serif;}

Control the Print Layout with Your Margins




"Unfortunately, some browsers have trouble handling padding appropriately, so it’s currently a better idea to move things around with margins whenever possible." - Eric Meyer [1]
Visible Links
Ideally you would want your links to stand out and be referenced in the print version.
This example provided by Eric Meyer at the least will show your links as bold, underlined text and at the most will show as red text with the linked URL displaying next to the hyper linked text. Gecko-based browsers give the most ideal results.

a:link, a:visited
{
color: #520;
background: transparent;
font-weight: bold;
text-decoration: underline;
}

#content a:link:after, #content a:visited:after
{
content: " (" attr(href) ") ";
font-size: 90%;
}

#content a[href^="/"]:after
{
content: " (
http://www.yourURL.com" attr(href) ") ";
}



Replace http://www.yoururl.com/ with the site's URL.

Paper Size

"We chose 535 pixels as the maximum dimension for the page layout because that is the widest table that will print on standard letter size or A4 paper " - Yale Style Manual [5]



Resources

[1] Going to Print

[2] Print Different

[3] Little CSS print stylesheet tip

[4] W3C Paged media

[5] Yale Style Manual - dead link


Read More


Related Topics: Email for Print

Monday, April 16, 2007

Designing An Email That Will Be Printed

Delivery

Don't just attach an HTML file and a bunch of images to a message and hit “send.”
Don't just paste all your code into your email application, either.

Use a Multipart/Alternative MIME Format so that your mail transfer agent bundles your HTML code, PLUS a plain-text version of the message, together into one email.

Layout

Rely on styles within the TABLE, TD, H1, H2, P, A, and other tags.

Rather than use a p tag, use a font tag with br tags to create the paragraphs

Redefine the font tag inside and after each anchor tag

Create a gutter around the frame (wrapper) table by setting the width to a percentage and/or using the cellpadding to at least 5.

Avoid colspans

Be sure TD cell widths have accurate widths

Email layouts will have to be left-aligned in Lotus Notes

Use those deprecated tags like background= and bgcolor= instead of CSS

The recomended width is 400 - 500 px which is less than the width recomended for printing.

Look Good at 194 pixels wide for AOL users

Tables are recomended and as few as possible. DIVs usually fail and are not usually supported.

Tweak the cellpadding and cellspacing attributes of the HTML tables instead of style="padding: 5px 5px 5px 5px;"

Padding style in the content TDs is set at 10 pixels all round for Google

Browser based emails strip out your HTML, HEAD, and BODY tags. Which means that you should use embedded or inline styles placed below the body tag and that no styles can be placed on the body tag. CSS is not supported well in gmail so it is recommended to test without CSS.

For background color of email, put all content inside a table with the preferred color & style the table width at 98% because Yahoo needs the 1% cushion on both sides.

No CSS-positioning

Required: Gmail requires inline styles.

Images paths are to be absolute paths to images hosted on your server.

In your plain text layout, you’ll want to enter a hard return after each line gets about 60 characters long and create dividers with special characters (ie. *, -, and _). Don't use periods to create divider lines.

Outlook 2007 will not support background images, background colors on nested tables/divs, floats, positions, and poor support on padding & margin attributes.

Required: an extra line break or two after the final HTML tag for AOL & O2000 users

Test with placeholder images for apps that block images and don't use alt tags so that placeholders show up.

Don't start any line with a period. Some ISPs use email servers that will strip any content below a line in your email that starts with a period.

Placing the closing td tag right after (on the same line as) the IMG tag eliminates the annoying and mystifying 1 pixel gap.

Content

Required: use your title tags

Required: an opt-out link

No JavaScript, or ActiveX, or embedding

Use target="_blank"

No free hosted images

"List a valid, physical mailing address. The more contact information you provide, the more reputable your email will look."

Required: Use a legitimate working reply-to with your company domain.

Test

Test in as many email applications as possible! (AOL, Yahoo, Yahoo!Mail Beta, Hotmail, Gmail, Outlook 2003, Outlook 2000, Outlook Express, Thunderbird, Apple Mail, Apple’s Entourage, Lotus Notes 6.5.3 and 6.5.4, Eudora 6.2)

Test for free with a MailChimp free trial account

You can use a downloadable validator to test what actually will work in Outlook 2007 Word Based Email Viewer.

Print


<style type="text/css">
h1{
page-break-before: always;
}
</style>

OR


<DIV style="page-break-after:always"> … </DIV>

Yale Style Manual choses 535 px as the max width because that is the widest table that will print on standard letter size paper. Our width should be no wider than 500px for an email so we are already print friendly.

Resources

HTML Email Design from Mail Chimp

Email Newsletter Design Archives

Microsoft takes email design back 5 years

Email Design Gallery

How To Code HTML Email Newsletters (All New Version)

Style in Email

Quick Tip: Testing your email design with images turned off

Pre Gmail and Outlook 2007, ALA Optimism: CSS and Email, Kissing in a Tree

HTML Emails - Taming the Beast

Review: 10 Emails with Images-Off

Mail Chimp Directory:

What Email Applications Should You Test?

HTML Email Tips for Web Designers

Top HTML Email Coding Mistakes

Tools:

MailChimp Inbox Inspector

Friday, March 30, 2007

CSS Naming Conventions

Be Consistent.
Be Managable.
Consider "structural naming, as opposed to presentational naming" - Eric Meyer
Consider the semantic role.

Here's a naming conventions table of popular websites.

Make your life easier and apply these:
Modular CSS
A CSS Framework

Some Tricks to keep up your sleeve:
Introducing Bleached
Black and White: without the distractions of colour
Global White Space Reset

Monday, March 12, 2007

Centering DIV with CSS

Liquid:
.container{margin-left: 10%; margin-right: 10%;}

Fixed (including ie4-6):
body{text-align: center;min-width: 750px;}
.container{margin-left: auto; margin-right: auto;width: 750px;text-align: left;}

Resources:
CSS Centering - fun for all!
Centering a Div

Thursday, March 01, 2007

2 columns in CSS

The Basic Layout Classes

The DOCTYPE has to be correct for this to work.

.contentContainer {
margin:0 auto;
width:800px;
}
.contentL {
float:left;
width:400px;
}
.contentR {
float:right;
width:400px;
}


The widths are very sensitive properties

content L width + content R width must be < = "contentContainer". Any padding or margin applied will disrupt their side-by-side balance so be careful.


Let Me Clear My Float

You will need to "push down" the div that follows the "contentContainer" div with this CSS property:

.following-div {
clear:both;
}

Backgrounds can cause trouble too

If you run into problems with background colors/images not showing up (in Firefox) of your "contentContainer" div, you can add one of these classes:

.contentContainer {
float: left;
}

or


.floatfix {
clear: both;
}


insert < br class="floatfix" > before the "contentContainer" 's closing div tag



Anatomy of the Layout

¿ Porque Container? Because

Resources

Simple 2 column CSS layout
Webmaster World Forum

Further Research

http://www.glish.com/css/9.asp

http://www.456bereastreet.com/lab/developing_with_web_standards/csslayout/2-col/

http://www.neuroticweb.com/recursos/2-columns-layout/

http://css-discuss.incutio.com/?page=TwoColumnLayouts

http://realworldstyle.com/2col.html

http://wellstyled.com/css-2col-fluid-layout.html

http://www.bigbaer.com/css_tutorials/two-column-header-footer.htm

http://www.maxdesign.com.au/presentation/page_layouts/

--- http://css.maxdesign.com.au/floatutorial/tutorial0809.htm

HR + CSS

solid line:

hr { border: 0;
color: #666;
background-color: #666;
height: 1px;
width: 80%;
text-align: center;
}

styled line options:

chose one:
dotted
dashed
solid
double
groove
ridge
inset
outset

use this code:
hr {
border: none 0;
border-top: 1px dotted #666;
width: 80%;
height: 1px;
text-align: center;
}

image as HR:
div class="hrIMG"
.hrIMG {
background: #fff url(../images/HR.gif) no-repeat center bottom;
height: 1px;
}

To put an image on top of an hr:
work with the div options at http://www.sovavsiti.cz/css/hr.html

Resources:
blakems.com

Thursday, February 22, 2007

Cute Drop Quote

I like this drop quote on Designing for the Web [Jan 2006]:

CSS vs Tables

"...tables or absolute positioning. That’s so 1999." - A List Apart
Educating your client why css layout instead of a table layout:
"Large and/or nested tables in particular can dramatically slow page display." - Designing for the Web
"Web standards such as HTML 4, XHTML, and Cascading Style Sheets (CSS) gives you the best of all possible worlds" - Jeffery Zeldman

"The most amazing thing about this tutorial, is that somehow, even though it was completely unrelated, and supposed to be humorous, people STILL managed to get into a tables vs. css debate. YAWNNNNNNNNNN. So tired. So over it. Will someone just buy the domain tablesvscss.com and document all the arguments so we can keep it all in one place and never have to look at it again? I am pro web standards, but at the end of the day, it is such a meaningless thing to be zealous about. People are hungry. " - a comment by anathema on an educational CSS "how to" post

Wednesday, February 14, 2007

center img

W3C SAMPLE :
img class="centeredPIC"
IMG.centeredPIC { display: block; margin-left: auto; margin-right: auto }



FINAL:

#flkr-cntrPIC{ display: block; margin-left: auto; margin-right: auto; float: center; padding: 5px; margin-bottom: 8px; border: 1px solid #ccc;}

an image, centered.




References:
Web Publishing Secrets - Zeldman [written 10 days before 9/11]
Centering Images is harder than you think [2004/09]
W3C section on centering [lu 2007/01/15]