CSS Links and Tips - Print Version

CSS Links and Tips

 

CSS Layouts

Struggling with a table-less CSS layout?

Getting a cross-browser layout working can be difficult. There are several resources that can help. One of the easiest to use is the Inkfish 'Layout-o-matic' tool, which lets you select the type of layout you want and then generates the css for it.

See www.inknoise.com

They also have a tool for creating CSS based rollovers which is useful to explore.



Using CSS to format printed versions of a page.

If you try to print a web page more often than not you get navigation links, large pictures that take up a lot of space (and ink), banner adverts and a host of other things you don't need.

Alternatively you may have the option of a 'Print this page' link that opens another window with a fairly plain version of the page suitable for printing.

There is a better way....

This is done by specifying an '@media print' group of styles within your stylesheet:

@media print{

.noprint {display: none;}
body {font-size: 12pt;}
}

This example specifies that the styles enclosed apply to printing only and contains a class called 'noprint' which lets you define areas of the page as non-printable, perhaps menus, graphics or banners. It also sets the body font-size to 12pt, rather than pixels, em or %'s, which aren't really suitable for printing.

In a similar way you can specify certain areas of a page for printing only, using a '@media screen' group of styles. The example below uses a class 'nodisplay' with 'display: none;' to define area of the page you don't want displayed on the screen. (The classes can use any name you want for easy recognition).


@media screen {

.nodisplay {display: none;}

}
 

To see this in action, print this page or use 'print preview'. You'll see that the top of the page, the footer and the newsfeed at the right hand side of the page are not printed. A title is printed, but it's not the one shown on the screen.


Indenting the second and subsequent lines of a paragraph

It's sometimes useful to indent the second and subsequent lines of a paragraph. For instance where you need decimal lists, something you can't do with a normal UL.

1.1 Il dualismo tipico del catarismo, si fondava sulla lettura del Nuovo Testamento, e più precisamente di passi dei Vangeli di Matteo e di Giacomo nei quali è ricordata in più punti la parola di Gesù, ovviamente interpretata come legittimazione evidente della contrapposizione di due principii: "un albero cattivo produce frutti cattivi, non può un albero buono produrre frutti cattivi, ne un albero cattivo produrne di buoni."

1.2 Fino a pochi decenni orsono l'eresia catara era conosciuta quasi esclusivamente attraverso forme indirette, provenienti da relazioni dei suoi oppositori, tra cui atti dell'Inquisizione e note di polemisti cattolici. Uno dei pochi testi catari noti era il cosiddetto Rituale di Lione, pervenuto in appendice ad una versione occitana del Nuovo Testamento.

Give the <p> tags a style:

.indent {
padding-left:25px;
text-indent:-25px;
}


Protecting Email addresses (not a CSS tip!)

The easiest way to stop email harvesters getting your address off a web page is by not putting it there in the first place!

Instead of an email address give your users a response form to fill in and send. You may have to protect against robot form submitters but that's probably the easier option.

If you MUST have an email address on a page, add it in html in the following format and DON'T make it a clickable link.

me<code>@</code>mysite.com

This shows correctly, allows users to copy and paste it into their email client, but isn't seen by the automatic harvesters.

Hint: You can check whether the spam bots can 'harvest' email addresses from your pages by using the tool at:

http://willmaster.com/possibilities/demo/RetrieveEmails.cgi


Other Links

Ten CSS tricks you may not know from Evolt.org

70 Expert Ideas For Better CSS Coding - Worth reading!

RoundedCornr - Want to create boxes with rounded corners? This tool does it for you, creating the necessary images, html and CSS. Various options available too.

WebsiteTips.com CSS Section - a huge resource of CSS links and tips

 

 




A List Apart
  • Mapping Memory: Web Designer as Information Cartographer The rise of the social web demands that we rethink our traditional role as builders of digital monuments, and turn our attention to the close observation of the spaces that our users are producing around us. It's time for a new metaphor. Consider cartography.

     

    Hide Your Shame: The A List Apart Store and T-Shirt Emporium is back. Hot new designs! Old favorites remixed! S, M, L, XL. Come shop with us!

  • CSS Sprites2 - It's JavaScript Time In 2004, Dave Shea took the CSS rollover where it had never gone before. Now he takes it further still—with a little help from jQuery. Say hello to hover animations that respond to a user's behavior in ways standards-based sites never could before.

     

    Hide Your Shame: The A List Apart Store and T-Shirt Emporium is back. Hot new designs! Old favorites remixed! S, M, L, XL. Come shop with us!