Using CSS to Create a Photo Gallery

I have quite a few examples in my CSS Experiments on showcasing your photographs, as a single image or in a gallery format, and I found a very simple, easy-to-understand explanation of how to use CSS to create a photo gallery from Web Reference.

With this article I hope to show you how to produce a professional quality photograph gallery using nothing more than an unordered list of photographs and a Cascading Style Sheet (CSS). I will take you through the styling one step at a time and end up converting an unordered list of photographs into a professional photograph gallery. Each step will be thoroughly explained and will have an example page showing the effect of the additional styling so that you can see what to expect.

The technique presented puts the images in a HTML list and then uses CSS basics and the hover style to create a photo gallery so when you move your mouse over the thumbnail, the enlarged version of the image will appear in the showcase.

This is a great technique which worked on only a few browsers when I first started experimenting with it, but with most people upgraded to newer Internet browsers, and so many people switching to , this technique will work across most browsers now.

Enjoy!

Clearfix CSS Hack: Solving Stair Stepping Images

While I deal with this and other design issues I had with my site in the article WordPress Tips and Tricks – Template Files, Styles, and Themes, the issue keeps coming up. So I decided we needed to address it specifically.

What to do when images start shoving other images round?

Generally, we try to avoid browser hacks, but there was one in particular we couldn’t avoid. It causes floats within floats, especially those with images floated within floating containers, to fail to recognize the height of the floated image within the container and stair step or wrap itself around neighboring containers. Does that make sense?

Let’s spell it out.

One of the biggest problems I had is with floats within floats. A division with a float inside scrambles your layout in FireFox, though it looks great in MSIE. The inside floats don’t line up and when they reach the virtual “end” of the parent container, they overlap past the end and into the next container. The problem is that the float doesn’t “clear” or stop at the end of the container where it should. It needs to be told when to stop with the “clear” function, but unfortunately different browsers need different instructions to accommodate those instructions.

Example of the step stepping of image without using the clearfix hack

After playing around with this for days, here is my final fix from
Positioniseverything’s Easy Clearing.

For example, on the front page of our site, each post excerpt features a bar along the left side in green and often an image in the right side of the container with the text wrapping around the image. The image’s position is controlled with a float selector. In Firefox, since a height was not established in the parent container, it ended when the text ended. If the text went below the image, then it wasn’t a problem. But if it ended before the end of the image, the next container would then begin, stair-stepping into the container above it.

I needed to apply a “clearing” to the container so that the container below it would wait until the container above was finished, and then begin it’s positioning.

The clearfix style is as follows:

.clearfix:after {content: ".";
   display: block; 
   height: 0; 
   clear: both; 
   visibility: hidden;}
.clearfix {display: inline-table;}
/* Hides from IE-mac \*/
* html .clearfix {height: 1%;}
/* End hide from IE-mac */
/* End clearfix */

In the index.php template where the excerpt or post content is displayed, I used this:

<div class="excerpt-post clearfix">
<h2 id="post-">......

The main styles of the excerpt area are controlled by excerpt-post but the addition of the clearfix style adds style instructions to the first style. You can learn more about using combination styles in our article on Understanding CSS Selectors and Attributes.

Example of the step stepping of image without using the clearfix hack

I also used this same technique in our Book Recommendations and Reviews. The ads and review section containers would begin to stair step their way as each container bumped up against the other, unable to determine the previous container’s height. I simply added the clearfix style to their styles.

<div class="clearfix books">
<img scr="blah.jpg" title="Amazon books" class="bookads" height="260" width="120">
<img scr="blah2.jpg" title="Amazon books" class="bookads" height="260" width="120">
<img scr="blah3.jpg" title="Amazon books" class="bookads" height="260" width="120">
</div>

The same technique would apply if the layout was like this:

<div class="clearfix books">Text here.
<div class="bookads">Book Ad here</div>
Text here.</div>

A lot of people blame Microsoft Internet Explorer for having the most bugs, but I did find some major bugs in other browsers.

CSS Experiments – Web Fonts and Embedded Fonts

Playing with fonts is like playing with fire. Sometimes it can light a match on a web page, a sparkler of pretty text. Other times, it can burn down the whole house. Use embedded fonts carefully as not all browsers can see them. To view this paragraph as a handwritten font, try viewing this page in Internet Explorer. Can you see the font that this is written in? Does it look like handwriting? Then you have a browser that can read embedded fonts. Lucky you.

But what about this paragraph? If you are using Mozilla Firefox, or a non-Microsoft Internet Explorer browser, you may be able to see this font, which looks like a form of handwriting. It may look different on your machine.

I will get to how I make this decorative font work in Firefox, but for now, it only works for Internet Explorer. This article is to provide a basic overview of how fonts work then and now.

If you are using a modern browser updated since 2010, the odds are that you can see this Google Font called “Waiting for the Sunrise” which is available for embedding and linking for free.

Fonts have come a long way since the early days of the web when we were restrained to working with 5-12 different fonts. The fonts had to work on every computer in every browser in every corner of the globe.

Today, the possibilities aren’t endless or unlimited, but we now have web fonts that we can use to dress up our web designs with HTML 5 and CSS 3 features and functions.

Still, it’s an intriguing concept, making our fonts look more decorate than plain. Therefore, we’re including instructions on how to create embedded fonts within your web page.

Currently, a font appears within a user’s browser because it is already installed upon their computer. While there are millions of different types of fonts available, most computers have a few core fonts installed by their operating system or browser, or they are installed by other software programs like Adobe Type Manager, Microsoft Plus, WordPerfect, Microsoft Office, and others. We have listed the most popular fonts below and included links to sites which keep score cards of the most popular fonts in use on the web. If you see the font characterics, you have this font installed upon your computer. If you don’t see Courier font here, that old typewriter looking font, you don’t have this font installed. Many of these fonts can be downloaded for free off the Internet. Helvetica, one of the most popular, is a commercial font.

Serif Fonts

  • Times New Roman
  • Courier New
  • Geneva
  • Georgia
  • Bookman Old Style
  • Book Antiqua
  • Haettenschweiler
  • Garamond

Sans-Serif Fonts

  • Helvetica
  • Arial
  • Arial Black
  • Verdana
  • Tahoma
  • Century Gothic
  • Lucida Console
  • Lucida Sans Unicode
  • Trebuchet MS
  • Arial Narrow
  • Comic Sans MS
  • Impact
  • Felix Titling

As you can see from the list, there is little variety among the spices. We are basically stuck with variations on Helvetica or Arial for sans-serif fonts and Times Roman for serif fonts. Georgia is a font on the rise and a definite improvement over Times Roman, but still is another version of Times Roman.

If you want to break through the web font limits, you can. Unfortunately, while the specifications for embedded fonts in web pages has been under development in CSS 3 for a long time, until only recently only Internet Explorer supported this technique.

Using a process known as embedding fonts, you can link a font to a web page document. When the user accesses the page, the font file is downloaded temporarily onto their computer along with the content and images of the page – just another file. Wherever the font is specified within the document through the CSS style sheet to appear, it will.

Now, before you go crazy with the possibilities, remember, these types of embedded fonts only work with Microsoft’s Internet Explorer.

If the font doesn’t load or isn’t recognized, be sure and list a generic font as a fall back. It also has some other drawbacks. For instance, if you can see the Brush font in the above paragraph, then the embedded font is working in your browser. If you can’t…that’s one of the drawbacks. Let’s look at the specifics.

  • Many fonts are copyright protected, therefore the font must be authorized for use on a web page. Many font designers don’t want their font designs used just anywhere, but some do. If in doubt, make sure you get permission from the font designer, if possible, before using.
  • Special software is required to create the embedded font file. While it should be as easy as putting a font file on your site and linking to it, it isn’t. Microsoft offers a free web font embedding software tool called WEFT – Web Embedding Font Tool that attaches your name, company, email address, and Website address to the embedded web font code information for the protection of the font designer’s copyright. Other programs can be found within our link resources below.
  • During the creation of the embedded web font, the path of the font and/or the pages or folders which will use the font must be included. The easiest way to include the path is to set it for the root directory of your Website, such as http://www.cameraontheroad.com/ and then all folders underneath that will be able to access the font. If you only set the path permission to /learn/web/ then you can’t access the font from a page in /learn/travel/.
  • If you are into serious optimization of your web page for fast loading, embedded font files add to the total file size of your document. It must load into the user’s machine along with the rest of the content and graphics.

When you have created your first couple of embedded font files and uploaded them to the appropriate folder on your Website host server, you are ready to start the process.

Begin by uninstalling the font you just created from your system. This way, when you are testing the page, you will see the font if the embedded font codes are working. If you don’t see the font and you see its generic equivalent, the process isn’t working. You want to make sure the font loads when you view the page. You can reinstall it later.

Then edit your CSS style sheet to include the following, with your font name and file name and location specifics. This is an example of one of our embedded fonts.

/* Embedded Fonts */
<!–
@font-face {

font-family: Bradley Hand ITC;
font-style:normal;
font-weight: 700;
src: URL(../../BRADLEY0.eot);
}

@font-face {

font-family: Formal436 BT;
font-style:normal;
font-weight: normal;
src: URL(../../FORMALB0.eot);
}

–>

Using the CSS @import, the font is “loaded” with the style sheet. Notice the comment codes around the embed font statements. This helps any browser that doesn’t recognize the @import rule to ignore it. The URL reference to the font should be from the location of the style sheet and not the page itself.

To set these fonts to be used within a specific class or division, there are two ways. One method is to set it normally through a tag rule such as:

h1 {
font-family:"Bradley Hand ITC", "Comic Sans MS", sans-serif; font-size:120%; font-weight:bold; color:blue}

Another method is to give the font a class statement so you can use the font on a specific tag or division. Remember to add alternative fonts in case the technique doesn’t work with the browser.

.bradley {
font-family:"Bradley Hand ITC", "Comic Sans MS", Arial, Helvetica, sans-serif}

.formal {
font-family:"Formal436 BT", "Arial Black", sans-serif}

In the HTML, the reference would be the same as for other classes:

<div class="bradley">This would be Bradley Hand ITC font.</div>

This would be Bradley Hand ITC font.

If you can’t see the above in a handwritten style font, you might see it in Comic Sans or a sans-serif generic font. Try F5 to reload the page. If it still doesn’t look like handwriting, this technique doesn’t work with your browser. Here is a graphic of what the font should look like:

Graphic Example of the Bradley Font

CSS3 and Web Fonts

With the development and embrace of CSS3, web fonts are now popping up all over the web. These work similar to the Internet Explorer embedded fonts but now cross browsers. They can be downloaded and installed on your server or linked to directly from the source. Expect font creators and innovators to start offering a wide range of affordable or free fonts to keep up with the demand over the next few years.

To use web fonts, you can either download and install the font file on your server or link to it from within your web page’s head section for use in CSS anywhere on your site.

This is a Google Font called “Wallpoet,” a stencil computer style font.

Google Web Fonts offer a free method for designers to embed or link to free fonts hosted and provided by Google. This is “Over the Rainbow,” a handwritting font.

In the head of the HTML web page structure, a link to the font on Google is added. This allows the font to work anywhere within the site’s design with some simple CSS references. An alternative is to download the font or to use the @import CSS function to import the font to the stylesheet.

&lt;link href='http://fonts.googleapis.com/css?family=Over+the+Rainbow' rel='stylesheet' type='text/css'&gt;

or in the stylesheet:

@import url(http://fonts.googleapis.com/css?family=Over+the+Rainbow);

and within the design:

h1 { font-family: 'Over the Rainbow', arial, serif; }

There are hundreds of web fonts now available. I’ve included links to articles and lists below.

Embedded Fonts – Links and Resources

Views of a Web Page

Web pages aren’t viewed by everyone equally. We’ve taken one of our web pages and passed it through some tests to resize, reshape, mash, smash, shrink, expand, and mess with our design. If you are going to experiment with CSS, or even if you are just designing a simple Theme or web page layout, you have to put your web pages through extensive testing to make sure your design works across all the different browsers, and that means any equipment used to view, read, see, or hear your web pages.

Below are the graphic results of what different computerized media can do to your web page. The graphics aren’t represented as 100% original screen size but as representations of what it should look like. We took a great deal of care to make sure our pages are as accessible as possible, so the glaring errors and problems your page may or may not have might not be shown here. This is to encourage you to do these tests yourself to see how your page would look under the various conditions web pages are viewed so your design will work for everyone.

To see how you would view the original page we tested, check out our article on Dot Animal Syndrome for nature photography.

Screen Sizes

The view you see on your computer monitor is based upon the size of the screen, the screen resolution, and the depth of color. The following tests are done to compare actual screen sizes and not compare screen resolution or color depth. In the next section we look at font sizes which can relate to screen resolution quality. We’ve done our best to take one web page and set it to be viewed at different screen sizes, emulating the most popular screen sizes used on desktop computers, laptops, and handheld computers, which compare with future cell phone access to web pages.

Screen Size 640×480

Screen size of640x480Our web page viewed at a screen size of 640×480. At one time this was the most common screen size used by most computer users. As you can see, the content around the photograph of the bear is wedged between the left column content and the photograph. We only see the top 5-8cm of the web page, requiring scrolling to move down into the content beyond the header and the photograph to the right. The text is readable and not crowded around the graphics.

Screen Size 800×600

Screen Size 800x600Most web pages are designed to be accommodated by the average screen size in use today which is 800×600, though this number is dropping as more people invest in better quality and higher resolution and larger monitors. As of 2003, about 45% of all Internet users had 800×600 sized screens. The page looks fine at this page size, readable, uncrowded, and well laid out. There is still a lot of text that needs to be scrolled down through, but there is enough of the page showing to invite the viewer to scroll down.

Screen Size 1024×768

Screen Size 1024x768The larger screen size of 1024×768 is gaining popularity, representing about 51% of users (2003), and expected to grow as people invest in higher resolution and larger monitors. We can see more of the content and the width of the page is now wider. As the screen size widens, designers may have to take into consideration their “narrow” view of forcing web pages into widths to accommodate the 800×600 average, since there will be so much more screen real estate to cover. Page layout designs like ours are based upon a combination of absolute and relative values so the page expands to fill the screen unlike those designed only with absolute column and page width values.

Screen Size 1280×1024

Screen Size 1280x1024While still in the minority, the use of 1280×1024 screen sizes are growing as people improve their monitors and computer hardware. The width of the page is greatly increased and we see more of the document. The photograph is almost lost in the majority of text now visible on the screen. With the extra wide space, designers must consider how to lay out their pages to accommodate the extra width. Web designers who force their page to be sized to accommodate the smaller screen sizes will suddenly have a lot of empty space to the left and right of their designed page. Instead of the traditional portrait (top to bottom) content flow, some designers may turn to landscape layouts (side to side) creating several columns to fill the width of the screen. A wider forced screen layout would cause the viewer of the same page on a smaller screen to scroll to the left and right to see the entire page unless the page was coded with relative column widths. The latest version of Cascading Style Sheet (CSS) codes should include methods to take into account different screen sizes with alternative style sheets, further enhancing and complicating the design process.

Also notice how the font sizes have shrunk with these ever-widening screen views. As the screen resolution changes, so does the font size. Forcing a specific font size won’t change this. It is based on pixel size (dots-per-inch – dpi) and the higher the screen resolution, the smaller the font, unless it is modified by the user. By designing a page with a forced font, you take away the rights of those using higher resolution screens to adjust the font size of your page to allow them to read it.

Screen Size for Ipaq, PDA or Similar Handheld Computer

Screen Size for Ipaq or Similar Long Screen Handheld Computer Handheld computers are growing in popularity for their portability as View of a web page on a handheld computerwell as capability. Many of them are now incorporating cell phone and wireless technology, become one device that does everything for the mobile computer user.

The screens come in two average sizes currently, a short square shape and a longer rectangular shape. Many handheld computers (PDAs) feature a retractable base which opens to reveal a writing pad or more of the screen. Some handheld computer software systems recognize when the bottom section is open or closed, resizing the content on the screen accordingly. Some allow for quick switching from horizontal to vertical viewing, again changing the perspective of the viewed page.

Screen Size for PDA or Similar Short Screen Handheld Computer In general, most web pages can be viewed by the software typically provided by the PDA manufacturer. Working with Cascading Style Sheets (CSS), the designer can control how their page will look when viewed on a handheld computer. This technology is still new, but expect it to grow quickly. We’ve embedded such CSS code within our style sheet which looks like this:

@media handheld {
  body  { background: center center; background-position: 45% 55%}
   #sidebar { display:none}
   #content { margin: 0}
   #footer {text-align:left}
   .ad  { display:none}
      }

Estimation of the view on a handheld computer using CSS style sheet coding These instructions tell the browser that if the page is being read by a handheld computer, position the page within the center of the “screen”, do not display the sidebar menu, reduce the content menu margin to zero (to fill the small screen), moves our footer code from the right to the left so the user might not have to scroll from left to right to see it, and not to display any advertising, which slows the loading of the page. The result should look like the example to your right, depending upon the screen size and software involved.

Variable Font Sizes for Internet Browsers

Font size on a web page is controlled by three things:

  • The designer’s embedded font code
  • The setting of the Internet browser for font size
  • The monitor’s screen resolution quality

Designers work hard to make their pages look as good as possible, and one of the choices they face comes with the fonts they choose. While there are hundreds of thousands of fonts available for printed material, a font used within a web page design typically must be on the user’s computer already. This means there are only a limited number fonts a designer has to choose from in order to be viewed by the most amount of users. The one thing designers can control is the size of the font. Thinking of web pages as another form of desktop publishing, many novice designers set the fonts with absolute values such as point sizes to force the font to be the same size no matter what. Well, the no matter what is limited to their machine, screen size and screen resolution and Internet browser’s default font size. Not mine.

Results of a Font Survey of the Most Common Fonts Online by Visibone. external site Built into Microsoft Internet Explorer and other Internet browsers is the ability to view a page’s fonts at different sizes. Typically they are named x-small, small, medium, large, and x-large or smaller, small, medium, large, and larger. In Internet Explorer, you can change the web page font size by accessing the menu for VIEW, TEXT SIZE and choosing the size. If a page has been designed with relative or variable font sizes in mind, the font size will reset itself. If the fonts have been hard-coded, embedded into the document as absolute values, then the font size will not change. When a designer uses absolute value references for fonts, they are taking away the right of the Internet user to choose the font size that helps them read the page in comfort. Internet browsing software designed for accessibility, for disabled users, can have difficulty working around absolute font values, or the results might not be “pretty”. When possible, use relative sizes when choosing fonts to make your page accessible for everyone.

This should mean that a 12 point Times Roman should look the same on everyone’s machine. It doesn’t. The other part of the problem is screen resolution. The higher quality the screen resolution, the smaller the font will appear on the screen. As you saw in the above examples on screen sizes, more and more people are using larger screens and most of them are taking advantage of the higher quality resolutions. This means that your 12 point font viewed with an 800×600 screen will look like a 10 point font or possibly smaller when viewed with a 1280×1024 size screen. Let’s look at some examples.

Text Size for Large Type

Text Size for Large TypeViewed at a screen size of 800×600 with the font set at the largest font size, the font is large and easy to read, and the content still flows well around the page. In a life-size view of this page, the font size would be about 14-18 points, even though the web page’s default base font is set at 11 points. This is approximately how a page would be viewed at about 8 or 16 bit color resolution, fairly low (640×480 to 600×800).

Text Size for Medium Type

Text Size for Medium TypeViewed at a screen size of 800×600 with the font set at medium, the page is set at what we designed the base font size to be, about 11 points. It is readable, and the graphics and content flows through the page. This is approximately how a page would be viewed at a fairly medium resolution, about 24-32 bits (800×600).

Text Size for Small Type

Text Size for Small TypeViewed at a screen size of 800×600 with the font set at smallest, the text is still readable, though it takes some work. The font size is about 6-8 points, even though it was set at 11 points. Web designers who use absolute fonts get a web page view similar to this when viewed at high resolutions (32 – 128 bit and greater) on large monitors with screen sizes of 1024×768 and higher. The font may be set at 10 or 12 point, but they look like 6-8 point when viewed at the higher resolutions.

View of a Printed Page

View of a Printed PageUsing Cascading Style Sheets (CSS) we encoded our web page to be printed without the background graphic in the header and the sidebar content. The style code also sets a print margin and does not print the advertising. It looks like this:

@media print {
    BODY  {background:white; font-size: 10pt; margin: 0}
  #sidebar  { display:none; }
  #bottom  { display: none}
  #header  { height: 30px}
  #header p  { font-size: 120% }
  #content  { margin-left: 0; float: none; width: auto; }
  #content a:link:after, #content a:visited:after {
  content: " ("attr(href) ") ";
  font-size: 90%;
  }
  #content a[href="/"]:after  {
  content: "(http://www.cameraontheroad.com" attr(href) ") ";
  }
  .ad  { display:none}
  h1, h2, h3, h4, h5, h6  {page-break-after: avoid;
      page-break-inside: avoid; }
  blockquote, table,
  pre  { page-break-inside:avoid; }
  ul, ol, dl  { page-break-before: avoid; }
}

To see how your own web page would look without print, in Microsft Internet Explorer from the menu choose FILE, PRINT PREVIEW.

Viewed with Different Internet Browsing Software

Different Internet browsing software views web pages differently. Some interpret the HTML and CSS codes differently. Others have trouble with Javascripts and layers. Older software didn’t know what CSS was so it will just ignore it. Other browser software, like Lynx, strips all the pretty out of page and boils it down to its barest content. Let’s look at some examples.

Viewed with Lynx Internet Software

Viewed with Lynx Internet softwareLynx Internet Browser Software is designed for the disabled and for those tired of the graphic heavy Internet who just want to get to the content. It is commonly used by the academic community and hard core computer users. Lynx ignores all graphics code and layout style and displays the content of a page, stripped of all its prettiness. It features an 80 column page width and displays the content in Courier font. It does some interesting things, though. If your page features meta tags that specify your main home page, table of contents, email address and copyright information, it will display this as content. All links wrapped around graphics will display as the ALT tag.

By checking to see if your page can be viewed with Lynx, you can check the accessability of your page to the disabled, and really put your HTML to the test. Does it pass? [[Note: Due to abuse, you have to save an empty HTML file called delorie.htm to your site's root folder in order for the Lynx viewer to work. It's like giving "permission" to use their tools.]] There is another technique by CRSchmidt.net’s Lynx Viewer. Just type in the name of your site after the link and it will show your site as if it were viewed with Lynx, stripping away all styles. To view our site, type http://crschmidt.net/services/lynx/www.cameraontheroad.com and the Lynx view will open in a new window so you can compare.

Backwards Compatibility

Viewed with backwards compatibility viewerOlder Internet browsers don’t recognize new code standards such as Cascading Style Sheets (CSS). What they don’t “see” they ignore. The page to the right was created using the Backwards Browser Compatibility test. It tests for Microsoft Internet Explorer version 5.0 and older. Since it doesn’t recognize the CSS style sheet, it just shows the simplest of page layouts. Is it still viewable? Can you read it and see the pictures associated with text?

This isn’t just a matter of backwards compatibility with older browsers. Can your web page be seen by any browser, with or without its stylesheet? Strip it down to its barest essence and what remains.

We did this with our own web pages to put them through the naked or stylesheet-less test. In this example we show one of our web pages with no stylesheet. That’s right. No CSS. Only the default look of the tags by your browser. By default, headings are larger than the text but photographs and graphics just sit there, with no text wrapping around them. Now, view the same page with the stylesheet turned on. Totally different.

If your web page design can pass this very strict test and still be readable, then you are on to a good layout and design.

What a Search Engine Sees

View of what a search engine may see when it visits your web page Want to know what the search engine sees when it visits your page? Delorie.com created a free online testing program to strip your page of the pretty design elements and view it as a search engine robot or spider would.

This online tests provides several examples of how a search engine robot may gather information. In the first example, it from all the headers such as H1, H2, H3 and so on. In the last example, it reveals the content of your page, all titles, headers, ALT tags, and TITLE tags clumped together.

Designing your web page for search engines, if you understand that this is the only information a search engine robot or spider is interested in, make sure your page design allows them to get to this information as quickly as possible. Move this content up to the top when possible as a search engine robot or spider typically views only the first 25-50% of a page.

Checking for Color Blindness and Visually Impaired

Deuteranope filter applied to web page
Protanope filterapplied to web page
Tritanope filter applied to web page

Color blindness is much more common than people realize. Vischeck.com’s Color Blindness free online tester, Color Blind Color Tests and Example and Q42 Color Blind Tests will test your web page colors to see how they would be viewed by someone who Grizzly bear, photograph by Lorelle VanFossenis color blind. We ran our test page through tests for the three more common types of color blindness, Deuteranope, Protanopia, and Tritanope. As the results of the color shifts might be difficult to view on your screen, we’ve provided you our original photograph of the bear seen in the web pages to the left of this paragraph to help you see the differences.

Deuteranope (Deuteranopia) affects about 4.9% of the male population. It is the absence of sensitivity to green colors and influences how people view reds and greens. The bear and the graphic text has an almost black and white sepia look with the red tones gone. Notice that the blue letters in the graphic text and the head line for “The Nature of Composition” and the title of the article underneath are almost black.

Protanope (Protanopia) affects about 1 percent of the male population. It is the absence of sensitivity to red and influences how people see colors at the red end of the spectrum, specifically reds and greens. While this sample appears close to the original, there is a hint of red missing and the blue is darker than the original.

Tritanope (Tritanopia) is very rare and affects approximately 0.001 percent of the male population. It is the absence of sensitivity to blue and influences how people see color along the blue scale, especially blue and yellow colors. All blue within the graphics and photograph of the bear are gone, leaving a green and purple tint, and the blue used for the headlines and titles are now black.

Visually Impaired Views

Not all visually impaired people are 100% blind. Many suffer from various degrees of sight impairment including blurred vision, and partial or blocked vision. Microsoft Windows and other operating systems come with accessibility features included. Add-on software, like speech recognition and speech reading and control, are widely available to disabled users, too. Each “see” a web page differently. Part of designing and validating your web pages for accessibility means understanding how those with sight problems can view your web pages.

In an amazing step into stupidity, according to the author of Blindness-Related Resources on the Web and Beyond, he highlights web pages about blindness and for the blind that are not even close to accessible. One of them is the Website for the Helen Keller foundation. These sites serve a valuable lesson in how to design for (and not!) web page accessibility.

Viewed with Accessability features turned on Microsoft Windows. Crecon’s Page View Tester for the Visually Impaired is a poorly designed online tool but it does the job in portraying what your web page would look like using simple accessibility features which enlarge the text to sizes usually bigger than the typical Internet browser.

You can try this yourself through Microsoft Windows. They have an Accessibility feature built into the last few versions of their operating system. Accessibility features in Windows can be turned on through the CONTROL PANEL, ACCESSIBILITY or ACCESSIBILITY OPTIONS icon. Look for HIGH CONTRAST and set the settings for any of the different high contrast settings for the visually impaired. Below you will see several different examples of our test web page viewed at high contrast using the large fonts in black or white backgrounds and different font colors. Different forms of visual impairment see better when viewing different colored letters against a black background. People with dyslexia view dark letters against a blue-tone background better than a white background. The software completely ignores the designer’s font sizes and colors when possible. The more a designer uses absolute coding for fonts, the less likely a visually impaired user will be able to view the site using these tools.

As the text is so large in these examples below, you are viewing the entire page as seen at full width on our monitor set at 1024×768, including the Internet Explorer menu and title bar, and the Start and Taskbar in the bottom. We mention this because if this was viewed on a monitor with the screen setting at 800×600, you would see even less of the web page content with the smaller screen size.

Yellow large high contrast text against a black background.White large high contrast text against a black background.

Green large high contrast text against a black background.Black large high contrast text against a white background.

 

Want More?

As we find more ways to view web pages, we will post our findings here. If you know of a way to view a web page and would like to let us know so we can post the web page view here, please leave a comment below and we’ll get back to you as soon as we’re back online – ah, the joys of the traveling life.

CSS Experiments – How They Were Done and More

We’ve been showing off our CSS experiments and how we created our pages and some other special effects, and you are probably wondering how we did all these popular CSS experiments. Displaying all the code and samples involved a few CSS techniques in addition to our CSS experiments so we could help you understand how this all works.

To display the code for the CSS experiment pages, we created a simple division container with a very light background and border so it would blend into the content rather than stand out. We also added font styles that made the code look like computer code, so it would stand out against the regular content. We also added a line-height rule so the code would be well spaced and easier to read, as it does get confusing. This rule wouldn’t work within the main class selector, so we had to add a child div for the line-height.

.demo {
position:relative; display:block; clear:both; border:2px solid #CCCCFF; margin:5px 0 25px 5px; padding:10px 5px; background:#F4FFF0; font-size:1em; font-family:Courier, “Courier New”, serif; color:black}

.demo div {
line-height:140%; position:relative}

The HTML structure to display the code was kept very simple:

This is the display of the code within this box.
<div class=”demo”><div>This is the display of the code within this box.</div></div>

To highlight a specific code reference, we added a span set to our class rule “red” like this:

<p>This is an example of what we want to <b>highlight in red</b> with a span.</p>

<p>This is an example of what we want to
<span class=”red”><b></span>highlight in red
<span class=”red”></b></span>
with a span.</p>

To create the code within our content, highlighting tags and CSS references used within our CSS experiments, we used the <code> tag set to the keyboard font known as “monospace” or Courier. We use it in our normal articles at a smaller font size, so we changed it to 1em to make it match the font size of the content.

Here is an example of a tag inside a sentence.

code {
font-family:monospace, “Courier New”, Courier, serif; color:black; font-size:1em}

<p>Here is an example of a <code>tag</code> inside a sentence.</p>

Reproducing the code took even more talent and skill. More so than some of our CSS experiments! If I write a piece of code, even though I’m using it inside the text content, it will become the code. So I had to substitute some of the code elements so it would appear as code. This substitutions are known as extended characters or entities. Similar to ascii, they are combinations of letters and symbols that represent characters of the alphabets. There is not a keyboard key for the heart symbol ♥ but there are extended characters which the browser will recognize and translate into the symbol. For ♥, the extended character is &hearts; . To create the < and > characters used throughout HTML coding to hold tag names:

&lt; = <
&gt; = >

This is fairly simple. Most HTML Editors feature a list of extended characters for the designer to choose from instead of remembering the character code. But things get a little more challenging when trying to actually reproduce the extended character on the page such as with this spacer division.

.spacer {
clear:both}

<div class=”spacer”>&nbsp;</div>

For example, to create a “space” on a page, between the division start and end tag there needs to be a non-breaking space. The equivalent of a tap of the keyboard space bar – a tap of the keyboard space bar just won’t do in HTML. There has to be a physical representation of that “tap on the space bar” to create the “space”.

If I write the extended character code for non-breaking space ( ), you wouldn’t see anything because the code is designed to represent “space” or nothing visible. To understand how the code works, you have to be able to physically see the space.

The physcial representation of a space is &nbsp; and to reproduce the extended characters in a visible form, I had to break the extended character down into its basic elements and reproduce those. I can’t simply hold down the shift key and select 7 on the keyboard and then type the “amp;” and expect it to become visible to the viewer. It will become the code. In order for the extended character code to be visible on the web page, the ampersand must be translated into the extended character that represents it.

Let’s break this down to its smallest details. I want to recreate the &nbsp; so it will be seen on a webpage. The extended character code consists of an ampersand and four letters and a semi-colon (nbsp;). If I recreate the ampersand extended character, then type the remaining letters, the extended character will then be visible on the page. So I replace the beginning ampersand of the &nbsp; with &amp; and added the “nbsp;” to get the following, which allowed me to represent the invisible visibly.

&amp; = &

&amp; + nbsp; = &nbsp; = [non-breaking space]

RED represents character code
DARK GREEN represents character code replacement

Let’s put this into use so you can see what the magic is behind what you see on the screen.

&lt; = <
&gt; = >
&amp; + nbsp; = &nbsp; = [non-breaking space]

Seen on the screen:<div class=”hello”>
Written as: &lt;div class=”hello”&gt;

Seen on the screen:<div class=”spacer”> &nbsp;</div>
Written as: &lt;div class=”spacer”&gt;&amp;nbsp; &lt;/div&gt;

RED represents character code
DARK GREEN represents character code replacement

It takes a little time to figure it out, especially when we need the extended character code visible. The only time we’ve needed an extended character visible is for the non-breaking space character (and within this section’s description of the extended characters). Here is another example of how we generate the visible code you see within these pages:

<p>This is some text <span class=”red”>with a span</span> and a <a title=”link” href=”link.html”>link to nowhere</a> for you to see the use of this code.</p>

&lt;p&gt;This is some text
&lt;span class=”red”&gt;with a span&lt;/span&gt;
and a &lt;a href=”link.html”&gt;link to nowhere&lt;/a&gt;
for you to see the use of this code.&lt;/p&gt;

Extended Characters – Entities – Links and References

Want Even More CSS Fun?

There are so many things you can do with CSS. We had a blast designing these CSS experiments and encourage you to experiment with CSS yourself. We’ve just shown you the tip of the ice berg. The newest version of CSS-3 should be available for most web browsers soon and it brings with it even more bells and whistles and fun.

There are a variety of websites on the Internet that will help you explore all the fun and games CSS has to offer. The three I most highly recommend are CSS Zen Garden, Eric Meyer’s CSS Edge, and Mandarian Design for seeing the possibilities in Cascading Style Sheets web design.

CSS Tips, Techniques and Tricks

CSS Tips and Tricks – Filters and Transforming Text

Flippin’ Filter Fun: flipv and fliph

There are tons of filters you can have fun with with your CSS experiments. Remember, these only work on a few browsers, so test them out before putting them into use. Firefox and older browsers have trouble with these, though Microsoft Internet Explorer’s latest versions display these well. We have links to help you explore the fun and games with CSS filters below, but here are a few more examples of some CSS experiments with filters.

The flipv or Vertical Flip actually mirrors the content upside down.

Flip Things Vertically
<div style=”height:5%; width:50%; font-size:1.3em; color:blue; filter:flipv“>Flip Things Vertically</div>

The fliph or Horizontal Flip mirrors the content horizontally. It also flips everything within the division including the margin, padding and width.

Flip Things Horizontal
<div style=”height:5%; width:50%; font-size:1.3em; color:blue; filter: fliph“>Flip Things Horizontal</div>

The Flip Horizontal and Vertical filters appear to be fairly silly CSS experiments, but there are some interesting things you can do with them, if you release your creative spirit. One technique is to use the fliph and flipv repeatedly within the same filter statement. This example flips the text vertically and then horizontally. A text-align:center declaration forces the lines to be in the center close to each other.

Dream Now

Dream Now
<div style=”height:1%; width:30%; padding:10px; text-align:center; font-family:Georgia, Times Roman, serif; color:purple; font-size:140%; font-weight:bold; background:#FFCCFF”>
Dream Now
<div style=”height:1%; filter:flipv fliph“>
Dream Now
</div>
</div>

The example below flips the repeated text horizontally, then vertically, then horizontally to move it upside down under the original text.

Dream Now

Dream Now
<div style=”height:1%; width:30%; padding:10px; text-align:center; font-family:Georgia, Times Roman, serif; color:purple; font-size:140%; font-weight:bold; background:#FFCCFF”>
Dream Now
<div style=”height:1%; filter:fliph flipv fliph“>
Dream Now
</div>
</div>

By uses CSS classes to hold the horizontal or vertical flip instructions, you can apply this technique to design elements within your web page design.

In this example, we’ve actually forced the letters to go sideways, then using the flip filters, we’ve flipped the first one vertically and then horizontally, an the second one has been flipped vertically twice and then horizontally once to create a reverse reflection.

SIDEWAYS SIDEWAYS
CSS Style Sheet:
.verttext {
font-family:Georgia, Times Roman, serif; color:purple; font-size: 120%; writing-mode: tb-rl; filter: flipv fliph; padding:5px}

.verttextflip {
font-family:Georgia, Times Roman, serif; color:purple;font-size: 120%; writing-mode: tb-rl; filter: flipv flipv fliph; padding:5px}

HTML Structure:
<div>
<span class=”verttext”>SIDEWAYS</span>
<span class=”verttextflip”>SIDEWAYS</span>
</div>

Leaf pattern, photograph by Brent VanFossenUsing the photograph to the right of a closeup leaf pattern, we’ll use a similar technique to the one done to create our popular PhotoQuilt notecards, but we will only use the CSS filter for vertical and horizontal. First we will display the two images side by side by using a style declaration of float:left on the first image. Notice also that all the margins and paddings have been set to zero to make sure there is no white space between the images.

Leaf Leaf
<div>
<img src=”/images/web/leafclose.jpg” style=”float:left; margin:0; padding:0″ width=”85″ height=”127″ alt=”Leaf”>
<img src=”/images/web/leafclose.jpg” style=”float:left; margin:0; padding:0″ width=”85″ height=”127″ alt=”Leaf”>
</div>

Let’s apply the flip vertical filter to the second image.

Leaf Leaf
<div”>
<img src=”/images/web/leafclose.jpg” style=”float:left; margin:0; padding:0″ width=”85″ height=”127″ alt=”Leaf”>
<img src=”/images/web/leafclose.jpg” style=”margin:0; padding:0;filter: flipv” width=”85″ height=”127″ alt=”Leaf”>
</div>

Let’s change the vertical flip to the horizontal flip filter on the second image to begin the mirror reflection aspect.

Leaf Leaf
<div”>
<img src=”/images/web/leafclose.jpg” style=”float:left; margin:0; padding:0″ width=”85″ height=”127″ alt=”Leaf”>
<img src=”/images/web/leafclose.jpg” style=”margin:0; padding:0; filter: fliph” width=”85″ height=”127″ alt=”Leaf”>
</div>

Now we have something interesting with our CSS experiments. Remember, these filters aren’t recognized by all browsers, so if you only see two leaf pictures sitting next to each other, or some space between the photographs, then your browser is having trouble interpreting the CSS filter instructions since they are proprietary for Microsoft products. We’ll show you a graphic image of what the final result should look like in a moment.

Let’s double up on what we’ve done to create a first level quilt effect with our CSS experiments. We now have four sets of images, two on top of each other.

Leaf Leaf
Leaf Leaf
<div>
<img src=”/images/web/leafclose.jpg” style=”float:left; margin:0; padding:0″ width=”85″ height=”127″ alt=”Leaf”>
<img src=”/images/web/leafclose.jpg” style=”fmargin:0; padding:0; filter: fliph” width=”85″ height=”127″ alt=”Leaf”>
<br>
<img src=”/images/web/leafclose.jpg” style=”float:left; margin:0; padding:0″ width=”85″ height=”127″ alt=”Leaf”>
<img src=”/images/web/leafclose.jpg” style=”margin:0; padding:0; filter: fliph” width=”85″ height=”127″ alt=”Leaf”>
</div>

Now, let’s double flip the bottom two images so they will create the final results.

Leaf Leaf
Leaf Leaf
<div>
<img src=”/images/web/leafclose.jpg” style=”float:left; margin:0; padding:0″ width=”85″ height=”127″ alt=”Leaf”>
<img src=”/images/web/leafclose.jpg” style=”margin:0; padding:0; filter: fliph” width=”85″ height=”127″ alt=”Leaf”>
<br>
<img src=”/images/web/leafclose.jpg” style=”float:left; margin:0; padding:0; filter: flipv” width=”85″ height=”127″ alt=”Leaf”>
<img src=”/images/web/leafclose.jpg” style=”margin:0; padding:0; filter: fliph flipv” width=”85″ height=”127″ alt=”Leaf”>
</div>

Wow! Let’s take it a little further and reverse the top and bottom two images to change the “look” of the PhotoQuilt. Notice in the code how the third box in the list has no flip filter. It is in the position of the original image.

Leaf Leaf
Leaf Leaf
<div”>
<img src=”/images/web/leafclose.jpg” style=”float:left; margin:0; padding:0; filter: flipv” width=”85″ height=”127″ alt=”Leaf”>
<img src=”/images/web/leafclose.jpg” style=”margin:0; padding:0; filter: fliph flipv” width=”85″ height=”127″ alt=”Leaf”>
<br>
<img src=”/images/web/leafclose.jpg” style=”float:left; margin:0; padding:0″ width=”85″ height=”127″ alt=”Leaf”>
<img src=”/images/web/leafclose.jpg” style=”margin:0; padding:0; filter: fliph” width=”85″ height=”127″ alt=”Leaf”>
</div>

Final images of the PhotoQuilt effect created with CSS Filters fliph and flipv, original photograph by Brent VanFossen Can’t see the effect we’re going for here? Here is a screen shot of what the final results should look like. We’ve taken four exact images and used the CSS filter for flipping horizontally and vertically to position these images, using only CSS styles, to recreate the PhotoQuilt effect. We have more examples of our real PhotoQuilts and how we create our PhotoQuilt Notecards in our Learning Zone.

Flipping CSS around can be fun. Use your imagination and see what is possible.

 

More Text Tips and Tricks:
Engrave and Emboss Filters

The Engrave and Emboss Filters are different from others as they change the background to gray, but the intensity of the effect is based upon the tone of the background color.The closer to white, the more intense the effect. The closer to black or dark tones, the less intense the effect is.

Embossed on white background.
Embossed with green-toned (#009900) background.
This is Embossed with blue background.
<div style=”height:25px; width:50%; padding:10px; font-size:1.2em; font-weight:bold; background:white; filter:progid:DXImageTransform.Microsoft.Emboss ()“>Embossed on white background.</div>
 
Engraved with white background
Engraved with green-toned (#009900) background
Engraved with blue background
<div style=”height:25px; width:50%; padding:10px; font-size:1.2em; font-weight:bold; background:white; filter:progid:DXImageTransform.Microsoft.Engrave ()“>Engraved with white background</div>

These two CSS filters can be used to create buttons or links, such as the one below using the embossed filter. We maintained our web page design link featuring a background and top and bottom borders that look like this link when you hover the mouse over the link. See the interesting results when you move the mouse over the link box below.

<div style=”height:25px; width:25px; padding:10px; font-size:1.5em; font-weight:bold; background:#CCCCFF; filter:progid:DXImageTransform.Microsoft.Emboss()“><a style=”padding:5px” href=”cssfun.html#linkemboss” title=”this link reloads this page on CSS Filter Fun”>Link</a></div>

CSS Tips and Tricks – Backgrounds and Transparencies

We’ve done a lot of different CSS experiments, pushing CSS to its limits with fun and jazzy text, filters, horizontal and vertical flipping, and more, and now it’s time to tackle some fun with more filters.

Be sure and check out more of our CSS Experiments to help you expand your imagination with what is possible with CSS.

Background Transparency CSS Filter

In addition to shadow and drop shadow filters, another popular filter is the alpha transparency filter. Primily recognized by Microsoft Internet Explorer, more browsers are starting to recognize this filter. We used this effect in one of our demonstration layout pages. The alpha transparency filter creates semi-transparent content allowing the background to be visible through the transparency. For web page designers, this opens up a whole new range of artistic possibilities.

NOTE: More information on CSS transparency filters that work with Firefox can be found at Mandarian Design CSS Opacity Transparency Filters and CSS Opacity for Mozilla Firefox and Other Browsers.

The level of transparency (or opacity) is controlled by a fraction or percentage. The higher the number, the less transparency. For instance, 20% or 0.2 opacity would be very transparent and 80% or 0.8 would be almost solid.

The alpha transparency filter can be used on images, text and containers for a variety of design features. There are a few drawbacks, though. Everything within an alpha transparency filter container fades. For example, to the left is the fully opaque box with text in it and to the right is the same box with the 50% opacity alpha transparency filter applied. As you can see, not only has the box’s background faded, the text color has also faded.

At 100% opacity, this is the original box.
At 50% filtered opacity, this is the box
<div style=”display:block; width:150px; background:#000099; color:yellow; font-size:1.3em; padding:5px; filter:alpha(opacity=50); -moz-opacity:0.5; opacity:0.5; -khtml-opacity:.5“>At 50% filtered opacity, this is the box.</div>

When used against a backdrop, such as a colored background, you can see the transparency even more. Notice in the box to the right how the background is visible through the box and the text. Instead of yellow, the text is blending with the light blue background to make it green, changing the colors within the overlaying container.

At 100% opacity, this is the original box.
At 50% filtered opacity, this is the box
 
<div style=”display:block;
height:150px;
width:200px;
background:#00FFFF”>
<div style=”color:yellow;
height:100px;
width:150px;
background:#000099;
filter:alpha(opacity=50);
-moz-opacity:0.5;
opacity:0.5;
-khtml-opacity:0.5;
font-size:1.3em;
padding:5px”>
At 50% filtered opacity, this is the box
</div></div>

When used with an image in the background, the effect is mesmerizing.

30% opacity against the flower

Look closely at this example. The white box in which the text resides is partially transparent, allowing the flower photograph to be visible through the box. Unlike the above boxes where the text became transparent right along with the parent container, the text in this example isn’t transparent. It is solid and you can’t see the flower through the text.

There are several ways to achieve this effect. One is by layering of containers using the z-index. The z-index takes advantage of the power of CSS to not only create containers within containers on a linear basis, but also in 3 dimensions. The z-index works the CSS layers to determine what is in front or behind what container, adding depth to web page designs. Using absolute positioning, two containers, one with the transparency effect and the other with the content, can be positioned over each other using the z-index. Some of the links below describe this technique.

Unfortunately, using absolute positioning contrains a web page design to absolutes. The more absolute positions you use in your layout and design, the stricter your web page layout structure becomes and the more confined it is to one fixed width browser window, creating space at the sides of web pages viewed with high resolution screens.

Using a great technique by Ove A. Klykken, a Norwegian freelance web designer, we use the power of CSS’s relative positioning and hierarchy of parent-child, and a little creative use of CSS wildcards, we can create three containers with the following rules:

CSS Style Sheet:
/* Parent division with background image */
#backtrans {
float:left; width:161px; height:241px; padding:5px; background:url(blueeye1.jpg) no-repeat}

/* Transparent text area */
#transbox { width:130px;
margin-left:10px;
margin-top:25px;
background:#FFFFFF;
filter:alpha(opacity=50);
-moz-opacity:0.5;
opacity:0.5;
-khtml-opacity:0.5;
}

/* Asterick represents wildcard for child dependents of #transbox */
#transbox * {position: relative}

/* Text div – lacks transparency */
#transbox div {padding:10px;
color: #000;
font-weight:bold}

HTML Structure:

<div id=”backtrans”>
<div id=”transbox”>
<div>
30% opacity filter against the flower
</div>
</div>
</div>

However, this technique does not work in Firefox. I’ve poked and poked and so far have been unable to make it work. The filter works but it applies to all containers within the parent container. I’m still working on a solution, and have a bit of one found on one of our CSS test pages. View it both in Internet Explorer and Firefox to see the drastic differences as each browser interprets the CSS differently. View the source files and the CSS to see the differences in the code.

Alpha transparency filters are not all equal when it comes to various web browsers. To make sure you catch whatever browser is coming your way, you can set the alpha transparency filter to cover all the bases. If a browser doesn’t recognize the transparency filter, it will just ignore it and the containing box will become solid. Here are the differences for the different browsers for 30% opacity:

.filter {
filter:alpha (opacity=30); /* MS Internet Explorer */
filter:progid:DXImageTransform.Microsoft.Alpha
(style=0, opacity=30) /* MS Internet Explorer proprietory */
-moz-opacity: 0.3; /* Mozilla v1.6 and below */
opacity: 0.3; /* CSS-3 Standards */
-khtml-opacity:.3 /* Safari */
}

Alpha Transparency Filter – Links and Resources

Understanding CSS Selectors and Attributes

Word Games – Understanding the CSS Jargon

Understanding how CSS and HTML work together is not easy. The idea that it takes two pieces to fit together to make a web page display is a challenge. We’ve broken down the concept into simple terms and definitions, as well as simple examples to help you understand how CSS influences HTML and how they work together, and how to start to create your own web page designs. We begin with terminology and then simple application, developing into an understanding that while tables no longer shape and form web pages, the containers created with HTML and CSS not only shape but provide a new form of control over the end result.

If you are considering exploring our CSS experiments, or doing any of your own web page design, then take time to understand how CSS selectors and attributes work.

At the core of cascading style sheets are rules. The simplest kind of rule looks like this:

H1 {
color: green }

Each rule consists of a selector and a declaration such as selector {
property: value}
. In the example above, H1 is the selector. It’s the HTML tag that the style is being attached to. The declaration defines what the style actually is, and it also consists of two parts: the property (in this case, color) and the value (green). The above rule tells the web browser that all text surrounded by <H1> and the closing tag </H1> should be displayed in green.

Graphic representation of a CSS rule, declaration block and declaration, graphic by Lorelle VanFossen

Any HTML tag can be used as a selector. Thus, you can attach style sheet information to any kind of element, from normal <P>; text to <TABLE>. They are attached to HTML tags and define divisions of style in the form of classes ( <p class="green">), divisions ( <div class="green"> or <div id="menu">), and spans ( <span class="green">). Check out the above tutorials and resources below for more details explanations and information and see our article on tips and tricks from our web page design, specifically our section on the differences and similarities of divisions and classes, and CSS fun, tips and tricks. If you are ready for the “big time” in CSS design, check out our extensive CSS design examples and experiments, putting CSS designs to the test.

CSS From the Source – The World Wide Web Consortium

The Differences and Similarities
Between DIV, CLASS and SPAN

While sometimes interchangeable, divisions and classes are different and they need to be used properly. Many amateur web page designers stick only to classes to modify the HTML, thinking this is easier. It actually makes things more complicated. Let’s see if we can clear up the similarities and differences between divisions and classes and figure out when and when not to use them.

Divisions, classes and spans are similar because they modify the content. All can influence tags. All are containers, influencing every tag within their container. The differences are more important and influence the design and layout of a web page.

A div represents a division in the structure of the web page called a generic block-level element, which means that it sits within its own line or block container. There are two kinds of div selectors. One is used just as a division, which sets up a block of content, and the other is a division that sets up a block of content modified by the design elements within an ID or class rule.

A plain div would look like this:

<div>This is content within a division. </div>

A div influenced by an ID, a unique, non-repeating name, would have the characteristics of the division selector as specified within the style sheet and identified with a hash or pound sign (#), such as:

#header {
position: relative; color:blue; background: white; font-size: 120%}
<div id=”header”>This is the header</div>

A div influenced by a class, a repeating non-unique name, would have the characteristics of the class selector, designated with a period before the name ( .red):

.red {
color:red; background:transparent}
<div class=”red”>This would be a division with red text.</div>

SPAN is also a container, but while div sits within its own line or section, a span is an inline container. This means that it influences the content within its container in relationship to the division or container it sits within. It can’t influence the parent container. Spans can be set by the declarations (design elements) of its div or class. We use span in our blue box to influence the text within the box elements in relationship to the container they are in. For example:

.red {
color:red; background:transparent}

span.blue {
color:blue; background:transparent}
<div class=”red”>This would be a division with a <span>blue text span</span> inline with the red text.</div>
This would be a division with a blue text span inline with the red text.

A class is more of a description code. It can be an inline container or set to be a block ( display:block) or modified in many different ways. It “describes” the presentation characteristics. It is a code that links to the presentation style selector within the style sheet and influences any HTML or division tag. Unlike an ID tag, a class can be used over and over again on the same page.

We’ve shown how the class works in the examples above, but let’s look at one more using all the elements we’ve discussed.

#section {
position: relative; color:blue; background: yellow; width:50%; border: 1px #000099 solid; font-size: 110%}

.red {
color:red; background:transparent}

.darkgreen {
color:#006600; background:transparent}
<div id=”section”>This is text within the division with blue type and a yellow background.
<p class=”darkgreen”>This is a paragraph within the division with dark green text and a span influenced by a class which turns <span class=”red”>this section of red text </span> before returning to blue.</p>
And more text which should be in blue.</div>
This is text within the division with blue type and a yellow background.

This is a paragraph within the division with dark green text and a span influenced by a class which turns this section of red text before returning to green.

And more text which should be in blue.

Classes modify content the same way as a div ID, but classes shouldn’t be associated with the overall layout structure. Their job is to change the smaller elements.

Classes, spans, and divisions can be used in combination. The containers used for pull-quotes and highlighting tips and resources within our articles are set within layers of divisions modified by classes. These containers are not unique to the page and are often repeated on a single page. Using classes allows these containers to be repeated. In the hierarchy of CSS, the span modifies the class which modifies the division, creating a child/parent relationship. The closer a modifier is to the content, the more control the modifier has to overwrite the parent characteristics.

<div class=”boxtip”>
<div class=”tiptitle”><span>Tip Box Title </span>
</div>
<div class=”tipbody”>Tip body content here…

These boxes are divisions within the page, but they are not unique to the page. I might have two or three tip boxes within a page, so the class rule allows me more than one division container.

Understanding the ID Even More

Each div has a unique name and characteristics set up in the style sheet, called an ID, and it can only be used once per page. Divisions usually represent the layout structure such as header, sidebar, container, footer, and content. The areas they represent tend to be large rather than small lines or elements.

Divisions representing the layout of the page help the designer when they make future modifications. Suppose you want to change the font in the sidebar sections on all of your pages from Arial to Times Roman. Having all of your sidebar content in the sidebar division, a simple change to the font-family selector would modify the sidebar on every page linked to that style sheet. Simple and easy.

But ID names are not limited to divisions such as div and a division is not limited to only div selectors. Any selector that acts works as a block container is a division. These include <h1>, <h2>, <p>, <table>, and <ul>. A div is a generic block element. An HTML tag is a division that is a specific block element. All of these can be assigned a unique ID name.

Take time to seriously peruse the many web page examples at CSS Zen Garden. If you look at the HTML on every page, it is exactly the same. Word for word, division by division. The only thing that changes is its style sheet, which they provide for examination on every page. In order to create this amazing feat, each element within the HTML is designated with an ID name, such as:

<div id=”head1″>
<h1 id=”header”>This is Header Under Head1 </h1>
<p id=”p1″>This is paragraph one and it says something. </p>
<p id=”p2″>This is paragraph two and it says something else. </p>
</div>
<div id=”head2″>
<h2 id=”header”>This is Header Under Head2 </h2>
<p id=”p1″>This is paragraph one under head2 and it says something else more. </p>
</div>

This way the designers, using the same HTML structure and content, can create such diverse and creative designs because each section is clearly identified. You can also see some of this at work in our other CSS experiments and pages on web design and layouts.

There is another powerful feature to the ID name. As it is unique, only one ID name per page, it can also represent a target point or anchor to link to. We discuss the hierarchy of various links later, but in a jump-with-a-page anchor, the traditional link looks like this:

<a href=”#here”>Jump to section </a>

Landing on the target anchor which looks like this:

<h3><a name=”here”>Heading Here</a></h3>

With an ID name in the jump or target points, the visitor can click on the same link as above but it will take them to the unique ID name target reference like this:

<h3 id=”here”>Heading Here</h3>

This is another method to help streamline the code and makes the process more efficient. Since division IDs are unique, and classes and spans aren’t, this is only possible with div IDs.

The unique ID element for a division has limits. You can’t give two IDs to one division. But you can give multiple classes to a tag or division to influence its change, as you can read about in the next section on Combining Classes.

Just remember to use divisions for structure and classes for presentation elements, and it will help simplify your design.

Names for Classes and Divisions

A division ( div) must be unique within a web page, though it can be used repeatedly throughout a Website, such as #content found on every page with a consistent look reflected in the style sheet. The names for the various divisions which create the basic layout for a page are usually recognizable names: container, header, sidebar, content, column1, column2, footer, etc. Sometimes these are abbreviated to cont1, head, side, col1, col2, foot, etc. Divisions within the content usually reflect the information within the division such as intro, ads, list, info, definitions, etc.

Classes are also reflective of what they do. For example, a class called “red” would probably turn the content in the tag modified to the color red. It really doesn’t matter what they are called as long as they are consistent and clear to the designer. There are no rules regarding name choices in CSS.

There are, however, rules about how the names should be formated. The names of divisions and classes can be a combination of letters or numbers, but they must start with a letter. Acceptable is <div id="w43564"> but <id="43564w"> is unacceptable. The words or phrases may have a hypen between them, such as white-text, but they cannot have spaces in between the words. The following are some elements that division and class names cannot have, usually because they are assigned elsewhere: &, \, /, @, *, {
, }
, [, ], +, =,
and %.

DIV, ID, CLASS, and SPAN – Links and Resources

CSS Shorthand: Combining Classes

You probably noticed a technique within these pages, especially in our CSS experiments, called “combining classes”. Generally, if you wanted to assign two class selectors to a tag, you might write:

<p class=”bold” class=”small”>This is bold and small</p>

When modifying a tag or element with more than one class, you can use them in combination. The above code should read:

<p class=”bold small”>This is bold and small</p>

If I want the paragraph to be bold, small, and green, it would look like this:

<p class=”bold small green”>This is bold and small and green</p>

CSS Shorthand: Combining Declarations

The speed of a web page loading is dependent upon many factors, most importantly the size of the file. Anything that can be done to make the file size smaller speeds up the process.

One technique in CSS is to condense the code, combining similar codes together. For example:

h1 {
margin:0; font-weight:bold; font-size:130%; color:blue; padding-left:5px; padding-top:10px}

h2 {
margin:0; font-weight:bold; font-size:120%; color:navy; padding-left:5px}

h4 {
margin:0; font-weight:bold; font-size:105%; font-style:italic; color:blue; padding-top:1.5em}

CSS has a feature which permits grouping selectors together and giving them a shared declaration. Selectors are grouped on one line with commas to separate them.

h1, h2, h4 {
font-weight:bold}

h1, h4 {
color:blue}

h1, h2 {
padding-left:5px}

h1, h2, h4 {
margin:0}

h1 {
font-size:130%;padding-top:10px}

h4 {
padding-top:1.5em;font-size:105%;font-style:italic}

h2 {
font-size:120%;color:navy}

CSS Shorthand: Combining Measurements –
Margins, Padding, Borders, and More

There are also shortcuts and ways of combining measurements in declarations that will shrink down a web page’s file size, and make it easier to write the code.

Measurements for margins and padding, follow the clock in clock-wide positions: top, right, bottom, left. So a measurement for a division or class could be:

.box {
margin-top: 1em; margin-right: 1.5em; margin-bottom: .5em; margin-left: 1.25em}

Consolidate all of that into this CSS shortcut and abbreviate it to:

.box {
margin: 1em 1.5em .5em 1.25em}

Much shorter and faster to work with. There are other modifications you can do when the magins values are repeated, such as the above with the same top and bottom margins of .5em and left and right margins of 1em would be:

.box {
margin: .5em 1em}

You can also streamline your border codes. Here is a border CSS code for a box:

.box {
border-top: 1px; border-right: 2px; border-bottom: 1.5px; border-left: 2.5px; border-color: blue; border-style: solid}

This can all be consolidated down to the CSS shortcut of:

.box {
border-width: 1px 2px 1.5px 2.5px; border: blue solid}

This makes a very unusually shapped box, but for a normal box in which all sides are equal:

.box {
border: 1px blue solid}

For more information on optimizing your HTML and CSS code for faster page loading, see our article series on Website Validation and Optimizing Your Web Pages.

Combining Classes and Declarations – Optimizing – Links and Resources

CSS – The Things You Need To Know

While there is a lot of information about code styles and design layouts out on the web and throughout our CSS experiments and examples, some of the smallest details can be difficult to find. One of the little bits I needed to know was about how to layout a style sheet. Where do the spaces go? Does there need to be spaces between the codes? Does each rule need to be on its own line? And how to structure the rules, selectors, and declarations? When do I use colons and when do I use semi-colons? When do I use quote marks in CSS? Is there a reason and rhyme to naming DIVs and classes?

While HTML isn’t very forgiving when it comes to a slip of the finger or a space in a tag, CSS is a bit more forgiving. Here are a few things we learned along the way, especially while working on our CSS experiments.

Rules and Lines

There are several ways of laying out the style sheet rules and declarations. CSS ignores spaces between lines and how the rules are laid out as long as they stay within the contraints (brackets). Here are some layout forms that are all acceptable, though the ones with more spaces between lines and rules enlarge the file size, something you want to avoid.

This style keeps the whole rule on one line:

.title {
font-weight:bold; font-size:90%; text-align:center}

.heading {
color:navy; font-weight:bold; font-size:110%; padding: 0 0 5px 8px}

This style sets each declaration in the declaration block on one line:

.title {
font-weight:bold;
font-size:90%;
text-align:center}

.heading {
color:navy;
font-weight:bold;
font-size:110%;
padding: 0 0 5px 8px}

This style sets each declaration on one line and indents them for a cleaner and easier to read look:

.title {
font-weight:bold;
font-size:90%;
text-align:center}

.heading {
color:navy;
font-weight:bold;
font-size:110%;
padding: 0 0 5px 8px}

This style double spaces each declaration (or you can add space between each rule for easy reading of the layout):

.title {
font-weight:bold;

font-size:90%;

text-align:center}

.heading {
color:navy;

font-weight:bold;

font-size:110%;

padding: 0 0 5px 8px}

Remember, the more tabs and empty lines you add to your CSS file, the bigger it becomes. A fast loading web page begins with small file sizes on everything, including the style sheet, HTML, and the graphics and images.

Spaces in CSS

Spaces are another thing that can save space in your CSS sheet. That’s right. You can save space by removing space. While spaces are needed ocassionally, double spacing between lines and spaces between declarations can go. For example:

h4 {
margin: 0; font-weight: bold; font-size: 105%; font-style: italic; color: blue; padding-top: 1.5em}

Would become like this with all the spaces removed, freeing up 11 bytes – it all adds up:

h4 {
margin:0;font-weight:bold;font-size:105%;font-style:italic;color:blue;padding-top:1.5em}

Using the shorthand method discussed in the next section on Combining Measurements, you can further condense the font declaration block down from 91 to 61 characters (bytes) like this. Notice the spaces kept between the font declarations. These spaces stay.

h4 {
margin:0;font:bold 105% italic;color:blue;padding-top:1.5em}

Quote Marks

In the early days of CSS, quote marks were okay around the values of the declarations. Today, quote marks are unnecessary and they consume a lot of file space. Text surrounded by quote marks is a “string” and has different properties. Here is an example with quotes – deemed unacceptable code today:

#content {
position: “relative”; display: “block”; width: “90%”; color: “blue”}

It should look like this to comply with web standards today:

#content {
position: relative; display: block; width: 90%; color: blue}

There are exceptions to the quote marks policy. When designating a phrase which includes a space (called a “string”), such as in the font-family name for Times Roman, the phrase must be surrounded with quote marks such as:

font-family: Arial, Helvetica, “Times Roman”, sans-serif

Any references to URLs like a linked image within a style sheet used to require quote marks such as:

#header {
margin-left: 50px; background-image: url(“images/back.gif”) repeat; background: green}

Remember, HTML and CSS is fluid, changing and evolving. With the CSS-2 Revisions and the coming of CSS-3, quotes around URLs might not be required. No quotes on URLs are currently acceptable depending upon your document type. XHTML and XML are becoming stricter about the use of quotes.

#header {
margin-left: 50px; background-image: url(images/back.gif) repeat; background: green}

In HTML tags, quote marks are required for XHTML compliance to be around class and ID names.

<h2 id=”level1″>Title for <span class=”level1a”>Level One</span></h2>

Pounds, Periods, Commas, Colons, and Semi Colons

Knowing when to use the pound (crosshatch), comma, colon, and semi-colon when layout out CSS rules can get confusing at first. Here are some simple definitions for when to use which:

Pound Sign(#)
The # is used to define a division within the style sheet. Everything within that division will be modified by the declarations within the division. It is set as div#name or simply #name.

#content {
position: relative; display: block; width: 90%}

or
div#name {
position: relative; display: block; width: 90%}
Periods (.)
A period before a word designates that word as a class. Tags featuring that class are modified by the class declarations. These can also be used in combination with tags and divisions, thereby modifiying only the elements within those tags or divisions and not elsewhere.

.blue {
color: blue}

#intro.blue {
color: blue}

p .blue {
color: blue}

.blue p {
color: blue}

Commas (,)
Commas are used to distinguish different selectors or declaration values within a rule. For instance, when declaring a font-family, several fonts can be listed such as font-family: Arial, Helvetica, "Times Roman", sans-serif. When combining declarations to shrink the file size of the style sheet, multiple selectors which use the same common declaration can be grouped, separated by commons, in a line before the declaration.

p , dl , dd , li {
font-weight:normal}

#intro , .section1 , #header.p1 {
color:green}

Colons (:)
Colons are used to separate the property from its value such as:

p {
font-weight :normal}

p {
font-family : Arial, Helvetica, “Times Roman”, sans-serif}

Semi-Colons (;)
Semi-colons are used to separate declarations within the declaration block. The last code in a declaration block does not have to have a semi-colon before the end-bracket. An example is:

#content {
position: relative ; display: block ; width : 90%; color : blue}

Comments in HTML and CSS

Comments are non-publishing content in a style sheet or HTML that permit the designer to insert text to set layout clues and to provide information to help the desiger or viewer of the code. For example, comments can be used to designate that the following space is where a new article should be pasted into an HTML template web page, the following comment would be made:

<!–ENTER Article Here –>

and followed by:

<!–END Article Here –>

A comment in a style sheet to help the designer group elements together or give information about a style would look like:

/* Sidebar Elements Here */

Comments can be added after a rule and within a rule such as:

h1 {
color: red;
font-size: 120% }
/* About 18 pt equivalent */

.bluesmall {
color: blue; /* Colors it all blue */
font-transform: uppercase; /* Forces uppercase */
}

A space after and before the — in the HTML comment, and space after the /* and before the */ in the CSS comment, are required for recognition of the material inside the comment to be separate from the content. Remember comments add to the file size so when you are optimizing your HTML and CSS, keep comments to a minimum.

Links: CSS From the Source – The World Wide Web Consortium

Hierarchy in CSS

There is a lot of information at the W3.org about the hierarchy and inheritance of HTML and CSS, but here is a tip that should help you remember. The closer the tag, division, or class to the actual content you want to modify, the more likely that modifier will change the content. The general order is HMTL, CSS, tag, div, then class, but this is not strict. Just remember, the closer it is, the more influence.

<div id=”#chapter”>
<h1>Chapter One</h1>
<p>This would be a paragraph set by the paragraph design elements under the division.</p>
<p class=”para1″>This is paragraph one class style with an
<span class=”para1span”>example of a span with a
<b>bold</b> tag</span>
which modifies the span which modifies the paragraph.</p>
</div>

Simply put, in the above hierarchy example, the division ID called chapter included how the H1 tag would look and how the paragraphs would look. Enter class="para1" and the new class statement overwrites the paragraph look for paragraphs under the chapter division. Then a span comes in and changes the look of para1 and then a bold tag adds an accent of bold, modifying the span, and then slowly the modification elements close and the paragraph returns to its original intent.

This is just a glimpse into the hierarchy of CSS. The list of links below will help you understand better the parent/child relationship CSS and HTML have to each other as you design your layout.

CSS hierarchy and Inheritance – Links and Resources

Hierarchy in Website File Locations

There is a hierarchy within your Website directory, too. This one involves the way hyperlinks (links) work within your web pages, between your web pages, and between your Website folders or directories.

Hyperlinks (links) within a document consist of external links, internal links, and named anchors (jump within a page). There are two types of links: absolute and relative. An absolute link to an image or another page would be similar to a strict web page address:

<a title=”article on web page validaton” href=” http://www.cameraontheroad.com/ learn/web/validate.html“>validating your web page</a>

Clicking the link would take you, literally, out of the site and back into it, reloading the page rather than just looking for the page on your site.

The relative method uses a feature that permits the link to move within the frame of the site relative to the page.

<a title=”article on web page validaton” href=” ../validate.html“>validating your web page</a>

This would send the browser looking one folder up the site’s hierarchy to find the page. To send the browser looking two folders up the site’s hierarchy to find the page, it would look like this:

<a title=”article on web page validaton” href=” ../../validate.html“>validating your web page</a>

The following sends the browser looking down from the current page’s position within the site’s hierarchy to the learn folder and then down again to the web subfolder to find the appropriate page.

<a title=”article on web page validaton” href=” learn/web/validate.html“>validating your web page</a>

There are pros and cons to using either method. The main benefit of using the relative method is the use of less characters in the anchor reference. If file size is important to optimize your pages to their fastest loading, this is one way to cut out a few bytes.

Anchor names, links which jump within a page rather than leaving the page, can also be absolute or relative, though most are considered relative. An absolute anchor name would be:

<a title=”jump to section” href=” page.html#here“>jump to here</a> and the anchor would be <a name=”here”>here </a>.

The above link would reload the page and move to the anchor name. A relative anchor name link would be:

<a title=”jump to section” href=” #here“>jump to here</a> and the anchor would be <a name=”here”>here </a>.

This link would jump within the page without reloading it. Reloading a page, and all its attached files and graphics, takes time. Jumping within a page without reloading it is a very quick process for the user.

Remember division ID names also act as targets so the links to an ID name of “thisone” would look like this:

<div id=”thisone”>This is This One</div>

<a title=”information on this one” href=” http://www.here.com/pageone.html#thisone“>link to thisone</a>

<a title=”information on this one” href=” pageone.html#thisone“>link to thisone</a>

<a title=”information on this one” href=” #thisone“>link to thisone</a>

If at any time in its search it can’t find the page, it will return a “page not found” or Page Error 404, so take care when assigning links to pages and images to make sure they are actually where you think they are.

Link Hierarchy Within the Style Sheet

Our Website features over 500 articles within 14 folders and numerous subfolders. Our Learning Zone hosts 11 different subfolders related to our various educational subjects like basic nature photography, closeup nature photography, composition, equipment, and weather. Yet, we only use one main style sheet for the entire Website.

The links within the style sheet to the various graphic effects, such as backgrounds or embedded fonts, are called out from the style sheet and not the page in which you are viewing the content. When you view a web page, it loads the linked style sheet, and then the elements within the style sheet are loaded. Therefore, for the background image associated with our H3 header, I can use one URL reference and it will show up on every page, no matter how deep that page might be within the hierarchy of the site. Instead of providing a relative link from every page on the site to the reused graphic, the CSS style sheet does the work for me, such as:

#header {
display:block; background: url(“images/core/takelogo.jpg”) no-repeat left bottom fixed}

Our style sheet can be found in a folder called styles and the core images for our site are found in the images/core folder. Therefore, using relative anchors, the link to the background image tells the browser to go up one folder then down two subfolders to find the graphic.

Internal and External Hyperlinks (Links) – Links and Resources

CSS Style Sheet Blues: Clean House

After playing with your style sheet and filling it with wonderful design elements, and after you’ve been living with it for a month or so, having passed all the tests, it’s time to clean house.

Go through the CSS style sheet and really look closely at everything you have in there. Ah, that funky box with the neato colored background and borders. Ended up not using it, right? Toss it. Or the BIG font that reaches over 200% high. You really didn’t need that, did you? Throw that away. Look for the clunky CSS that you thought was a bright idea but never used it. Junk it.

Also take time to really streamline and optimize your style sheet. Strip it of excess spaces and lines. Group similar declarations together to save space. Look for redundancies, too. While you combined and grouped similar declarations together, did you leave any laying around in the original selectors? Look closely and see how many ways you can clean up your style sheet house so it is a thing of sleek beauty.

Valdilate and Check, Check, Check

As you are making changes, even little changes, validate your CSS and HTML codes frequently. Check them thoroughly. Even a year later, I’m still finding little bits of code I can clean up and improve, or code I simply left out somehow. It is a never ending process that is not locked in stone. Feel free to change and adjust your coding, but always check it thoroughly as you go so you can catch the little boo-boos and not be stuck searching through reams of code after two days of changes for the one little boo-boo you missed. Check as you go.

CSS Tips and Tricks

While we avoid a lot of whizbang tricks, we have used a few here and there. Most recently, we discovered some useful tricks when designing a “fancy” version of our web page layout. A major part of these we turned into our CSS Experiments.

As nature photographers and instructors, Brent likes to teach the following when dealing with the use of filters, special effects, and gimmicks in photography, and it applies to web design:

Just remember to use filters like using spices in cooking. A small amount can make the dish but too much will spoil the meal.
Brent VanFossen, nature photographer

To showcase the different techniques, tips, and tricks we’re using for these and our many CSS experiments, many of our examples feature the style codes inline, or inside the HTML tag as if this was the only tag within your website being modified like this. It is preferable to remove this style or presentation code and set it up in a style tag or linked stylesheet using divisions and classes. We only use this technique of inline styling in our own pages when a unique effect is needed. For more information on linking CSS style sheets, visit our introduction page to our style sheet design and layout.

If you are new to CSS, the following are more articles we’ve written to help you learn more about how CSS works in web page design:

CSS Simple Text-to-Boxes Fun

Before we get to the more serious fun, like our CSS Experiments, let’s look at some simple ways you can jazz up your design without a lot of special bells and whistles. One of the easiest things to do to highlight some content is to give it a background color. This can be done within the text.

This is normal text and this is highlighted text and we are back to normal.

<p>This is normal text and <span style=”background:yellow”>this is highlighted text</span> and we are back to normal.</p>

While not a filter, the background declaration can create some interesting effects with text. We can improve this by adding some space on either side of this is highlighted text with a padding declaration.

<p>We can even improve this by adding some space on either side of <span style=”background:yellow; padding-left:10px; padding-right:10px“>this is highlighted text</span> with a padding declaration.</p>

This can also be done by giving a background color to any container box such as this paragraph:

This is a simple paragraph of content set with a background color. From here, we can do a lot of interesting things to turn this into a box, pull-quote, or whatever we want, as seen in our many CSS Experiments and design element examples.

<p style=”display:block; width:50%; padding:5px; border:none; background:#99CCCC; color:#000066″>This is a simple paragraph of content set with a background color. From here, we can do a lot of interesting things to turn this into a box, pull-quote, or whatever we want.</p>

Going back to the highlighted text created by adding a background span, we can add a border to the span’s style so the highlighted text features a box effect.

…the span’s style so the <span style=”background:yellow; border:1px solid blue; padding-left:10px; padding-right:10px”>highlighted text</span> features a box effect.</p>

Let’s use the same technique on the paragraph:

This is a simple division with a background color and a border. From here, we can do a lot of interesting things to turn this into a box, pull-quote, or whatever we want.

<p style=”display:block; width:50%; padding:10px; border:1px solid blue; background:#99CCCC; color:#000066″>This is a simple division with a background color and a border. From here, we can do a lot of interesting things to turn this into a box, pull-quote, or whatever we want.</p>

We’ve moved from highlighting text with a background effect to creating boxes. Did you make the transition without trouble? Understanding that everything in CSS and HTML is “in a box” – held in check by containers – we have a sense of the possibilities. Let’s do some more CSS experiments with one of those boxes.

To introduce you to the concept of containers and divisions, let’s simply replace the paragraph tag with a division tag and change the border from a thin solid line to a double line.

This is a simple division with a background color and a double line border.
<div style=”display:block; width:50%; padding:5px; border:8px double blue; background:#99CCCC; color:#000066″>This is a simple division with a background color and a <b>double line</b> border.</div>

A border effect you see on many blogs uses dots to line its border. These are no different from the ones we’ve just been playing with, though we changed the background color to a light blue so the border is more evident.

This is a simple division as shown before but this time featuring a thin 1px dotted line border.
<div style=”display:block; width:50%; padding:5px; border:1px dotted blue; background:#CCCCFF; color:#000066″>This is a simple division as shown before but this time featuring a thin 1px <b>dotted line</b> border.</div>

Let’s keep going with some of our container experiments.

This is the same division with a thicker (3px) dotted line border.
<div style=”display:block; width:50%; padding:5px; border:3px dotted blue; background:#CCCCFF; color:#000066″>This is the same division with a thicker (3px) <b>dotted line</b> border.</div>
This is also the same division with a thicker (5px) dotted line border.
<div style=”display:block; width:50%; padding:5px; border:5px dotted blue; background:#CCCCFF; color:#000066″>This is also the same division with a thicker (5px) <b>dotted line</b> border.</div>

The dotted line and the following dashed lines are simple to create and their look can change based upon the width of the border. In the next examples, we’ve used a dashed line with different widths and changed the background color to show the effect dark blue text has on different colored backgrounds.

This division features a soft light blue background color (#ccffff) and a thin (1px) dashed line border.
<div style=”display:block; width:50%; padding:5px; border:1px dashed blue; background:#CCFFFF; color:#000066″>This division features a soft light blue background color (#ccffff) and a thin (1px) <b>dashed line</b> border.</div>
This division features a soft light yellow background color (#FFFF99) and a medium (3px) dashed line border.
<div style=”display:block; width:50%; padding:5px; border:3px dashed blue; background:#FFFF99; color:#000066″>This division features a soft light yellow background color (#FFFF99) and a medium (3px) <b>dashed line</b> border.</div>
This division features a soft light green background color (#ccff99) and a thicker (5px) dashed line border.
<div style=”display:block; width:50%; padding:5px; border:5px dashed blue; background:#CCFF99; color:#000066″>This division features a soft light green background color (#ccff99) and a thicker (5px) <b>dashed line</b> border.</div>

There are currently thousands of colors and 10 different border styles you can choose from:

  • none
  • hidden
  • outset
  • inset
  • groove
  • ridge
  • solid
  • double
  • dotted
  • dashed

The border styles “none” and “hidden” aren’t visually pleasing but they have their purposes. We’re going to continue to concentrate on the visually pleasing choices. We’ve seen a thin solid and played with dotted and dashed, so let’s see what else we can come up with.

Just as dotted and dashed are related in style, groove and ridge are related.

This is a simple division with a background color and a ridge line border.
<div style=”display:block; width:50%; padding:5px; border:8px ridge blue; background:#99CCCC; color:#000066″>This is a simple division with a background color and a <b>ridge line</b> border.</div>
This is a simple division with a background color and a groove line border.
<div style=”display:block; width:50%; padding:5px; border:8px groove blue; background:#99CCCC; color:#000066″>This is a simple division with a background color and a <b>groove line</b> border.</div>

They can also be used in combination for a different effect.

This is a simple division with a background color and a groove line and ridge line using different colored borders.
<div style=”display:block; width:50%; padding:10px; border-left:10px groove #66CCFF; border-right:10px ridge blue; border-bottom:10px groove #66CCFF; border-top:10px ridge blue; background:#99CCCC; color:#000066″>This is a simple division with a background color and a <b>groove line</b> and <b>ridge line</b> using different colored borders.</div>

Solid borders can also be interesting, if you play with complementary or contrasting colors with the background. Play with the width for more accent, too, as you move from these examples to your own CSS experiments.

This is a simple division with a contrasting background color and a 20px thick purple border.
<div style=”display:block; width:50%; padding:5px; border:20px solid #9900CC; background:#99CCCC; color:#000066″>This is a simple division with a contrasting background color and a <b>20px thick purple</b> border.</div>
 
This is a simple division with a complementary background color and a 40px thick dark blue border.
<div style=”display:block; width:50%; padding:5px; border:40px solid #6666CC; background:#99CCCC; color:#000066″>This is a simple division with a complementary background color and a <b>40px thick dark blue</b> border.</div>

Here is another CSS experiments technique that takes advantange of the background color like we tried in the beginning. It uses a paragraph inside of a container box and both the container and the paragraph have a background color. The padding declaration creates a “margin” around the paragraph allowing the background color of the parent container to be visible, appearing to look like a border.

This is the parent container with a colored border and background color.
 

This is the paragraph container that will sit inside of the parent container with no border and a background color.

Now, let’s put the two together:

The 10px padding of the parent container creates the “margin” around the paragraph allowing the background of the parent container to be visible.

<div style=”width:50%px; border:10px solid navy; background:blue; padding:10px“>
<p style=”background:lightblue“>The 10px padding of the parent container creates the “margin” around the paragraph allowing the background of the parent container to be visible.</p>
</div>

Now, let’s take this another step forward and add a border to the paragraph tag and create a “deeper” border effect.

The 10px padding of the parent container creates the “margin” around the paragraph allowing the background of the parent container to be visible. Then we added a border of medium blue around the paragraph to add depth.

<div style=”width:50%px; border:10px solid navy; background:blue; padding:10px”> <p style=” border:10px #3399FF solid; background:lightblue”>The 10px padding of the parent container creates the “margin” around the paragraph allowing the background of the parent container to be visible. Then we added a border of medium blue around the paragraph to add depth.</p></div>

There are two more border styles to play with: inset and outset.

This is a simple division with a background color and an inset line border.
<div style=”display:block; width:50%; padding:5px; border:10px inset blue; background:#99CCCC; color:#000066″>This is a simple division with a background color and an <b>inset line</b> border.</div>
This is a simple division with a background color and an outset line border.
<div style=”display:block; width:50%; padding:5px; border:10px outset blue; background:#99CCCC; color:#000066″>This is a simple division with a background color and an <b>outset line</b> border.</div>

CSS Containers and Borders – Links and Resources

CSS Border Effects

CSS Tips and Tricks – Jazzing Up the Content

We’ve show how to jazz up a web page’s content within a container or box. Now it is time to look at some tips and tricks for jazzing up the content.

CSS Text Effects

There are a variety of text characteristics you can also add to jazz up your text.

First of all, you can play with color. One of the popular effects on web pages in the early 1990s was a text rainbow of colors:

T h i s i s a R A I N B O W o f C O L O R F U L t e x t .
<div style=”text-align:center; font-family:Arial Black, Arial, Helvetica, sans-serif; font-size:110%; font-weight:bold”>

<span style=”color:blue”>T</span>
<span style=”color:aqua”>h</span>
<span style=”color:lime”>i</span>
<span style=”color:purple”>s</span>
<span style=”color:fuchsia”> </span>
<span style=”color:orange”>i</span>
<span style=”color:gold”>s</span>
<span style=”color:green”> </span>
<span style=”color:blue”>a</span>
<span style=”color:aqua”> </span>
<span style=”color:lime”>R</span>
<span style=”color:purple”>A</span>
<span style=”color:fuchsia”>I</span>
<span style=”color:orange”>N</span>
<span style=”color:gold”>B</span>
<span style=”color:green”>O</span>
<span style=”color:blue”>W</span>
<span style=”color:aqua”> </span>
<span style=”color:lime”>o</span>
<span style=”color:purple”>f</span>
<span style=”color:fuchsia”> </span>
<span style=”color:orange”>C</span>
<span style=”color:gold”>O</span>
<span style=”color:green”>L</span>
<span style=”color:blue”>O</span>
<span style=”color:aqua”>R</span>
<span style=”color:lime”>F</span>
<span style=”color:purple”>U</span>
<span style=”color:fuchsia”>L</span>
<span style=”color:orange”> </span>
<span style=”color:gold”>t</span>
<span style=”color:green”>e</span>
<span style=”color:blue”>x</span>
<span style=”color:aqua”>t</span>
<span style=”color:lime”>.</span>
</div>

You can also create the rainbow effect word by word:

This is a RAINBOW of COLORFUL text.
<div style=”text-align:center; font-family: Arial Black, Arial, Helvetica, sans-serif; font-size:110%; font-weight:bold”>

<span style=”color:green”>This</span>
<span style=”color:blue”>is</span>
<span style=”color:aqua”>a</span>
<span style=”color:lime”>RAINBOW</span>
<span style=”color:purple”>of</span>
<span style=”color:fuchsia”>COLORFUL</span>
<span style=”color:orange”>text.</span>
</div>

You can also play with text colors for headers such as this technique which highlights each word with a color and removes the space between them to look like many popular magazine headings.

RED BLUE

A similar technique uses the background to influence the color and let’s the text be white or the color of the background.

REDBLUE

Or take it a step further and reverse all the colors.

REDBLUE

We’ve grouped all three of the above examples together so you can compare the CSS construction.

Simple Text Colors:
<div style=”font-family:Arial Black, sans-serif; font-style:italic; font-size:150%; font-weight:900″>
<span style=”color:red“>RED</span>
<span style=”color:blue“>BLUE</span>
</div>

Colored Backgrounds with White (or Transparent) Text:
<div style=”margin:10px; font-family:Arial Black, sans-serif; font-style:italic; font-size:150%; font-weight:900; color:white“>
<span style=”background:red; padding:10px 0 10px 10px”>RED</span>
<span style=”background:blue; padding:10px 10px 10px 0″>BLUE</span>
</div>

Colored Backgrounds with Colored Text:
<div style=”margin:10px; font-family:Arial Black, sans-serif; font-style:italic; font-size:150%; font-weight:900″>
<span style=”background:red; color:blue; padding:10px 0 10px 10px”>RED</span>
<span style=”background:blue; color:red; padding:10px 10px 10px 0″>BLUE</span>
</div>

You can also play with the way the text looks using CSS properties like text-transform, font-variant, and letter-spacing:

this is all lowercase forced to uppercase
<div style=”text-transform:uppercase”>this is all lowercase forced to uppercase</div>
This is Font-Variant Small Caps
<div style=”font-variant:small-caps”>This is Font-Variant Small Caps</div>
This is letter-spacing at .5em
<div style=”letter-spacing: .5em”>This is letter-spacing at .5em</div>
This is letter-spacing at 1em
<div style=”letter-spacing: 1em”>This is letter-spacing at 1em</div>
This is a line of text
with the line height forced to 8px
<div style=”line-height:8px”>This is a line of text
with the line height forced to 8px</div>

Why would you want the text to overlap? Here is a design to consider:

CSS Style Sheet:
#logo {
position:relative; line-height:60%; font-family:Arial Black, sans-serif; font-weight:bold; text-align:center; padding:15px}

#logo div {
color:#66CC00; font-size:3em; letter-spacing:.1em}

#logo span {
color:#006600; font-size:1.5em; font-style:italic; letter-spacing:.6em; padding-left:15%}

HTML Structure:
<div id=”logo”>
<div>LORELLE</div>
<span>Design</span>
</div>

 

CSS Filter Fun

The use of CSS filters is another way of jazzing up your web page content and design. Filters come in different types ranging from simple shadows to eye-popping. The following are a few of the more popular, and easily attainable, filters. CSS filters are still fairly new and now all browsers recognize filters equally. Firefox is one of those which has trouble with filters, but all of these should work in the latest Microsoft Internet Explorer. Also, if you have an older browser, it’s time to update it!

Shadow Filter

Filters that create shadows on the content come in two forms: shadow and drop shadow. The Shadow filter merely shows a narrow shading behind a graphic or text. The Drop Shadow Filter shows an offset silhouette duplicate of the graphic or text behind the subject. Let’s look at their features individually.

The shadow filter creates a simple shadow behind the subject.

Shadow Filter – Gray
<div style=”font-size:1.3em; height:1%; font-weight:bold; filter:shadow(color:gray)“>Shadow Filter – Gray</div>

Notice how the left side of the S in Shadow is cut off along the left margin. The shadow effect literally casts a shadow to the left and down from the subject as the default. If there is no padding around the subject, the shadow will be cut off. Let’s add the padding.

Shadow Filter – Gray
<div style=”font-size:1.3em; height:1%; font-weight:bold; padding:10px; filter:shadow(color:gray)“>Shadow Filter – Gray</div>

Now the shadow filter is completely visible on the left. Also, almost all filters require a height, and a few require a width, to their container. Let’s look at some color effects you can do with shadow.

Shadow Filter With Light Green Shadow
<div style=”font-size:1.3em; height:1%; padding:10px; filter:shadow(color=#33CC99)“>Shadow Filter With Light Green Shadow</div>
Blue Shadow Filter With Peach-Colored Text
<div style=”font-size:1.3em; height:1%; font-weight:bold; padding:10px; color:#FF9966; filter:shadow(color=#0033FF)“>Shadow Filter With Blue Shadow and Peach-Colored Text</div>

As you can see, you can play with the colors of the shadow and the text to create different effects with the shadow filter. You can also play with the direction of the shadow by adding a directon attribute.

This is Shadow set at Direction 145
<div style=”font-size:1.3em; height:1%; padding:10px; filter: shadow( color=gray, direction=135)“>This is Shadow set at Direction 145<

Shadow filters affect more than text. They can also be used on images and graphics as well as boxes. Remember to allow enough margin and padding for the effect to be fully seen. Here are some examples:

Baby Blue Eyes Flowers, photograph by Brent VanFosssen

<div class="alignleft" style="padding:10px; height:241px; width:161px; filter:Shadow(direction=135, color=#0000ff, strength=12)">
<img src="blueeye1.jpg" width="161" height="241" alt="Baby Blue Eyes Flowers, photograph by Brent VanFosssen"></div>

 
This is Shadow set on the box at Direction 315 with the strength to 25.

<div style="width:40%; filter:shadow(color=#999900, direction=315 strength=25); padding:30px 10px 5px 30px"><div style="border:2px #006600 solid; background:#99CC66; font-size:1.1em; font-weight:bold; padding:10px; color:#006600">This is Shadow set on the box at Direction 315 with the strength to 25.</div></div>

To Make A quote diffeRENT from the rest, you can bEAT your own DRUM.

You can really have some design fun with CSS text shadows and filters. It is really up to your imagination. Here is an experiment to create a magazine style pull-quote, using many of the techniques discussed on these pages about CSS tips and tricks. There are many over-the-top ways to use the shadow filter. There are also some very subtle designs that can be used with the shadow filter that can enhance your web page. We’ve created a container box with a shadow, and then applied various font elements to the text to create a fun, magazine-style effect.

CSS Style Sheet:
#shadowbox {
width:40%; float:right; filter:shadow(color=#999999, direction=225); padding:10px}

#shadowbox div {
background:white; font: 1.5em Impact, Helvetica, sans-serif; color:#99CCFF; padding:10px 20px 10px 10px}

HTML Structure:
<div id=”shadowbox”><div>To
<span style=”color:#CC99CC; text-transform:uppercase; font-variant:small-caps; font-family:Georgia, Times, serif; font-weight:bold; font-size:1.4em”>Make</span>
A quote
<span style=”font-weight:bold; font-size:1.8em”>diffe
<span style=”color:#FF99FF”>RENT</span>
</span>
<span style=”text-transform:uppercase; font-variant:small-caps; color:#6699CC”>from the rest </span>,
you can
<span style=”color:#6699FF”>b</span>
<span style=”color:#CC99FF”>EAT</span>
your own D
<span style=”color:#FF99FF”>RUM</span>.
</div>
</div>

Drop Shadow Filter

Like the shadow filter, the drop shadow filter also casts a shadow, but this one is a duplicate of the content offset from the original.

Drop Shadow Filter
<div style=”font-size:1.3em; height:50px; filter:dropshadow(color=red)“>Drop Shadow Filter</div>

Just like the shadow filter, you can play around with the colors on the drop shadow filter.

Yellow Drop Shadow Filter with Blue Text
<div style=”color:blue; font-size:1.3em; height:50px; filter:dropshadow(color=yellow)“>Yellow Drop Shadow Filter with Blue Text</div>
Light Green Drop Shadow Filter with Dark Green Text
<div style=”color:darkgreen; font-size:1.3em; height:50px; filter:dropshadow(color=#66FF00)“>Dark Green Drop Shadow Filter with Dark Green Text</div>
Purple Drop Shadow Filter with Pink Text
<div style=”color:pink; font-size:1.3em; height:50px; filter:dropshadow(color=#9900CC)“>Purple Drop Shadow Filter with Pink Text</div>

As you can see from these examples, the dark text with a complementary lighter shadow color is a more pleasing look. But the drop shadow filter fun doesn’t stop here. As with the shadow, you can adjust the offset position with the drop shadow.

Drop Shadow offset by 3 on x and y
<div style=”padding-left:10px; font-size:1.1em; height:30px; filter: dropshadow( color=#999999, offx=3, offy=3, positive=1 )“>Drop Shadow offset by 3 on x and y</div>
Drop Shadow offset by 20 on x and y
<div style=”padding-left:10px; font-size:1.1em; height:50px; filter: dropshadow( color=#999999, offx=20, offy=20, positive=1)“>Drop Shadow offset by 20 on x and y</div>
Drop Shadow offset by minus 20 on x and plus 20 on y
<div style=” padding-left:40px; font-size:1.1em; height:50px; filter: dropshadow( color=#999999, offx=-20, offy=20, positive=1)“>Drop Shadow offset by minus 20 on x and plus 20 on y</div>

Again, watch your edges. I had to increase the left padding on the last example by 40px in order for the shadow to be entirely visible on the left size.

The drop shadow filter can also be added to images and boxes.

Baby blue eyes flower, photograph by Brent VanFossen

<div class="alignleft" style="padding:10px; filter:dropShadow( color:#6699CC, offX=-10, offY=10, positive=true); width:161px; height:241px">
<img style="margin:8px" src="/photos/flowers/blueeye1.jpg" width="161" height="241" alt="Baby blue eyes flower, photograph by Brent VanFossen">
</div>

 
Drop Shadow on a box

<div style="width:30%; filter:dropShadow(color: #999900, offX=10, offY=-10, positive=true); padding:15px">
<div style="border:2px #006600 solid; background:#99CC66; font-size:1.1em; font-weight:bold; padding:10px; color:#006600">
Drop Shadow on a box</div>
</div>

 

Shadows and Drop Shadows – Links and Resources

CSS Unleashed – Experiments with CSS Designs

99 THINGS
YOU DIDN’T
KNOW
YOU COULD
DO WITH CSS *
W3c.org's CSS Check Icon
*And How To Do Them Well!

We decided to offer up some of our own experiments for you to learn more about CSS and for us to have a little fun, too. The following designs were completely created without tables, using only Cascading Style Sheets (CSS) for positioning and presentation. You are welcome to copy anything within these pages, though we recommend you have some fun of your own and take these experiments a little further with your own colors and experiments. If you come up with something really cool based on these designs, we’d love to see it and possibly add it to our offerings. Let us know at via the comments below.

The process, as you can imagine, of creating these CSS boxes, headings, menus, table of contents, pull-quotes and blockquotes, and titles came with a serious education into how Cascading Style Sheets work. We’ve shared notes about how these were created in our comments next to the codes and the bigger lessons at the end of this series of experiments where we explain how we created these creative CSS designs so you can create your own.

HOT! | PURE CSS DESIGNS

As with all experiments, these come with some warnings. They are not perfect and not perfectly viewed on every web browser. They have been moderately tested over the years and the various browsers. If your browser sees something garbled, please let us know so we can fix it.

These do have “breaking points”, points where the design might not hold up under pressure. These points are usually based upon screen width and resolution. To see where a design might “break”, resize your browser’s window or change the font-size specifications (From Menu > View > Text-Size).

The CSS in these experiments are over-coded. There are always simplier ways to do things, so streamline the code as you see fit. We are still playing around with these, so we’ve left much of the code inline without relying upon style sheets so we can tweak at will. To use these on your page, check out our examples of how to move the inline coding to style sheets.

To maintain a consistent look with these experiments, we used generic fonts available on most computers and a relative font size. We decided to preserve the size of the examples by using font sizes in pixels. In general, the fonts should not resize with the change in font-viewing size set by the browser. We recommend you change the font and font size specifications to meet your own needs.

We hope you enjoy and use our experiments and learn a bit more about the creativity of CSS as you go.

To see how these CSS experiment and styles work, view the source code of the page. In your web browser menu, click VIEW > SOURCE or VIEW > PAGE SOURCE to view the source code. For the most part, the styles are included inline with each design.

Many magazines highlight headings, sections, or departments with a reverse solid colored background with white or complementary text.

In this series, we simply change the backgrounds and letter spacing.

 
BLUE WHITE
 
REDWHITE
 
REDBLUE
 
REDBLUE
 
HELLOTHERE
 
HELLOTHERE
 
HELLO
THERE
 
HELLO
HELLOTHERE
 
HELLO
THERE

HELLO

 

In the example below, we’ve eliminated the background color and added a border line to the bottom of each element. Watch your padding and margins to line up the borders. MSIE adds 3 pixels to containers, which makes this a challenge to reproduce on every brower perfectly.

 
HELLO
THERE
 

While this design looks different, it only features a uniform background color.

 
FLORIDA | BIRDING SPOTS
 

Using the same techniques, we can create solid lines of background colors and stack them on top of each other within a single division.

 
PHOTOGRAPHY
NATURE AND WILDLIFE
 

The two following CSS examples use the same techniques of stacking divisions in a group.

TRAVEL
TRAVEL TIPS FOR THE TRAVEL WEARY
50 Ways to Arrive Refreshed and Ready
 
TRAVEL
TRAVEL TIPS FOR THE TRAVEL WEARY
50 Ways to Arrive Refreshed and Ready
 

Magazines also graphically play with text, messing about with line-height, letter spacing, and more to create more interesting headings, sections, and department titles.

Wide letter spacing makes this one interesting.

SKIPPING ACROSS THE STONES OF LIFE
WE FIND SIMPLE THINGS ARE THE BEST
 

Line height creates this magazine look which can be changed to create some interesting overlap effects.

 
50
GREAT
IDEAS
 
50
GREAT
IDEAS
 

In this dramatic example, we’ve taken a design right off the cover of PC World computer magazine and put in our own text. It uses line height, color and font sizes in spans to create the final results. While it looks like a graphic, it is text. Try selecting the words with your mouse. Well, all is text except for the CSS verification logo, showing you how to incorporate an image into the text graphic.

 
20 THINGS
YOU DIDN’T
KNOW
YOU COULD
DO WITH
W3c.org's CSS Check IconCSS*
*And How To Do Them Well!
 

Combining some of the techniques, we used colorful spans along with one span featuring a background color which makes the text look like it is in a box. I updated the solid color background with a gradient style not an image background available with CSS3 using the technique described by WebDesignerWall.

 
The Color Balancing Act
made easy!
 

Below the CSS green graphic was inspired from an advertisement for Biolage Matrix hair products and features the effects of playing with borders and background colors. The “borders” on top are DIVs with colored backgrounds, no borders. The bottom DIV featuring “nature” has a darker top border and bottom border of yellow. I was a purist, I could have put all the background effects in divisions but I wanted to keep some of the coding simple by using a borders on one DIV. The “E” in Nature is in a span to color it yellow to match the bottom border. It makes for an interesting header effect and one that could set an entire look for a web page design.

 
NATURE

Borders around headings, sections and department titles can create dramatic attention getting results, too. Borders are more than lines around boxes. Borders are visual lines around objects created both with and without using CSS order styles. Borders aren’t limited to only one per division container. You can layer borders, use selective borders, play with colors, and create lines and geometric shapes with borders. Use your imagination with CSS borders, background colors, and more.

Lines above and below text add accent and drama to the words. These are great for headings and titles.

 
LIVINGNOW
 
 
DREAMA LITTLEDREAM
 
 
LIVINGNOW
 
 
DREAMA LITTLEDREAM
 

Going back to the basics, this simple box features a dashed border on a container inside of the parent container. The parent container features a 10px padding, which makes it appear like a border edge. Could be an interesting coupon effect.

 
Help Nature and work on with her; and Nature will regard thee as one of her creators and make obeisance. And she will open wide before thee the portals of her secret chambers, lay bare before thy gaze the treasures hidden in the depths of her pure virgin bosom.
H.P. Blavatsky (1831-1891)
 

Borders aren’t limited to one, or one color. This CSS design features three borders and plays with padding and border width to create its border effect. I’ve also used the CSS first-letter pseudo element style with the paragraph to enlarge the first letter of the first word in the sentence.

When you photograph something, don’t accept it as the end result; there’s always a next step. But repeat something only if you can improve on it. Otherwise, you must move on. A photographer must change to show change, and it is as much the photographer’s challenge to show change as it is to preserve what is. A picture must be a question as well as an answer.
Ernst Haas
 

Using the same above design, we’ve changed the colors of the borders to create a dramatic and a bit over the top border design. Use your imaginaton and use complementary or contrasting colors.

When you photograph something, don’t accept it as the end result; there’s always a next step. But repeat something only if you can improve on it. Otherwise, you must move on. A photographer must change to show change, and it is as much the photographer’s challenge to show change as it is to preserve what is. A picture must be a question as well as an answer.
Ernst Haas
 

A border doesn’t have to be on all four sides. This CSS design experiment features a top border on the inside container with a large dashed border.

The shadow’s the thing. Outside, shadows are blue, I read, because they are lighted by the blue sky and not the yellow sun. Their blueness bespeaks infinitesimal particles scattered down infinitesimal distances. Muslims, whose religion bans representational art as idolatrous, don’t observe the rule strictly; but they do forbid sculpture, because it casts a shadow. So shadows define the real.
Anne Dillard Pilgrim at Tinker Creek
 

Right out of a magazine design, the outer parts of this heading feature thin top and bottom borders. The middle section is simply a container with a border and background color. The three elements float to the left of each other to create the illusion of the two outer sections passing underneath the middle container.

 
Inside the
Camera
of Your Dreams
 

Going back to the top border only design, we’ve layered this CSS design with four colorful top borders. This is good as a blockquote or pull-quote design, too. Notice the arrows around the author at the bottom of the quote. Extended character entities were used to create these arrows.

 
Surely there is something in the unruffled calm of nature that overawes our little anxieties and doubts: the sight of the deep-blue sky, and the clustering stars above, seem to impart a quiet in the mind.
» » » Johnathan Edwards (1703-1758) « « «
 
An artist chooses which subjects to portray; this is a way of praising… ultimately, one’s work is merely a magnifying glass offered anyone looking in our direction.
Friedrich Nietzsche
 

We’ve stepped up the design by adding a left border to each of our side borders to create a frame only on the top and left sides.

An artist chooses which subjects to portray; this is a way of praising… ultimately, one’s work is merely a magnifying glass offered anyone looking in our direction.
» » » Friedrich Nietzsche « « «
 

The examples above show the use of borders to create color around the edges. By introducing a background color and padding, the background color of each division acts as another border color, adding more drama to the CSS design.

Though we travel the world over to find the beautiful, we must carry it wihin us or we find it not.
» » » Unknown Author « « «
 
Creativity is dangerous…Its pleasure is not the comfort of the safe harbor, but the thrill of the reaching sail.
» » Robert Grudin « «
 

We took away the background colors we added and kept an even 10px padding on each division container, then made the border lines 2px thick, creating a very dramatic container, good for quotes or headings.

As little children we all start out with eyes close to the ground, seeing, feeling, smelling, exploring, and learning. Seeing with a camera is the best way I have found to get close to the earth again.
» » » Earnest Braun« « «
 

The following two examples use a technique of creating geometrics with borders. This technique is explained very well by Infimum Examples of CSS Slants Using Borders.

Science tends to be more an intellectual exercise, tending to separate the observer from the observed. Art tends to intergrate the subject and the observer.
Story Musgrave
 
One of the hardest things in this world is to admit you are wrong. And nothing is more helpful in resolving a situation than its frank admission.
Benjamin Disraeli
 

These next two designs were inspired by a web page layout. I didn’t like what they did, so I played around with it until I found something I liked. This is part of the fun of experimenting and making it your own design. The blocks feature borders on the sides of different colors. Look for the style classes in the header of this page under blackblock. The first one is a very simple look that could be used as a heading and the second one uses the style as a menu with css rollover or hover colors.

TalkingListeningConversationQuestionsAnswers
Test Yourself. Are you paying attention? It is time to ask yourself. Just be.
 
Your loneliness is your Self wanting to make friends with itself. Your loneliness is your Heart wanting to sing to itself. Your loneliness is your Being wanting to dance with itself.
Rusty Berkus, Appearances
 

Another challenge in CSS designs, we found this design on a web page done with tables and wondered if we could recreate it as pure CSS. Well, we did. This is not the most user-friendly and totally accessible CSS design experiment we’ve done, but it was a serious challenge. We’ve added the white-space: nowrap to keep the whole thing together, so it won’t wrap when the screen width shrinks. If you choose to use this, change the height in the last division to accomodate the content you add, and also change the height on the other divs within that set, and add 10px for padding, or whatever your padding choice. If you change the width, since it is set in total absolutes, you have to change the widths throughout to add up appropriate. This one needs a lot of care and feeding, but it is a very cool geometric look.

An additional note. I first designed these using Internet Explorer versions that were pretty poor, but then came Internet Explorer 6 which broke all web standards conventions, and these designs. Thankfully, as I update this in 2011, the war on web standards has been won and most of these designs, including this one that relies so heavily on precision sizes and spacing, work.

 
Backgrounds & Borders Games
 

CSS Unleashed – Variations on a Theme

We’ve been looking at a variety of CSS experimental examples, and now I’d like to take you through a design journey. These ideas come from magazines and advertising material, but they also come from a simple idea that is then played with to create different effects. Play with these effects and you have variations on a theme, each one special.

To see how these CSS experimental boxes and styles work, view the source code of the page. In your web browser menu, click VIEW > SOURCE or VIEW > PAGE SOURCE to view the source code. For the most part, the styles are included inline with each design.
There is no rule that says you can only have one “look” to your page. You can have several different types of pull-quotes and boxes styles, as long as they complement each other. Sure, too many is too much, but variations on a theme can give you different options to choose from, picking the appropriate design for your content.

Some of these look the same: Some of these CSS experiments that “look” the same in your browser may look different in other browsers. Some use filters to create dropshadows and other effects which will not appear in Firefox or other browsers. Try viewing these pages with different browsers to see the different effects.

Today Thoughts

If a photographer really expects to produce great work, they must, just like musicians, be prepared to practice their craft every day. EVERY DAY. This does not mean one has to take pictures every day, but one must at least practice seeing every day.
David Bayles

Today Thoughts

If a photographer really expects to produce great work, they must, just like musicians, be prepared to practice their craft every day. EVERY DAY. This does not mean one has to take pictures every day, but one must at least practice seeing every day.
David Bayles

Today Thoughts

If a photographer really expects to produce great work, they must, just like musicians, be prepared to practice their craft every day. EVERY DAY. This does not mean one has to take pictures every day, but one must at least practice seeing every day.
David Bayles

Today Thoughts
If a photographer really expects to produce great work, they must, just like musicians, be prepared to practice their craft every day. EVERY DAY. This does not mean one has to take pictures every day, but one must at least practice seeing every day.
David Bayles
 
Today Thoughts
If a photographer really expects to produce great work, they must, just like musicians, be prepared to practice their craft every day. EVERY DAY. This does not mean one has to take pictures every day, but one must at least practice seeing every day.
David Bayles
 
Today Thoughts
If a photographer really expects to produce great work, they must, just like musicians, be prepared to practice their craft every day. EVERY DAY. This does not mean one has to take pictures every day, but one must at least practice seeing every day.
David Bayles
 
Today Thoughts
If a photographer really expects to produce great work, they must, just like musicians, be prepared to practice their craft every day. EVERY DAY. This does not mean one has to take pictures every day, but one must at least practice seeing every day.
David Bayles
 
Today Thoughts

If a photographer really expects to produce great work, they must, just like musicians, be prepared to practice their craft every day. EVERY DAY. This does not mean one has to take pictures every day, but one must at least practice seeing every day.
David Bayles

 
Today Thoughts
If a photographer really expects to produce great work, they must, just like musicians, be prepared to practice their craft every day. EVERY DAY. This does not mean one has to take pictures every day, but one must at least practice seeing every day.
David Bayles
 
Today Thoughts

If a photographer really expects to produce great work, they must, just like musicians, be prepared to practice their craft every day. EVERY DAY. This does not mean one has to take pictures every day, but one must at least practice seeing every day.
David Bayles

 
Today Thoughts
If a photographer really expects to produce great work, they must, just like musicians, be prepared to practice their craft every day. EVERY DAY. This does not mean one has to take pictures every day, but one must at least practice seeing every day.
David Bayles
 
Today Thoughts
If a photographer really expects to produce great work, they must, just like musicians, be prepared to practice their craft every day. EVERY DAY. This does not mean one has to take pictures every day, but one must at least practice seeing every day.
David Bayles

Let’s try a different type of pull-quote and see how many variations on a theme we can come up with. The first four examples play around with different fonts, most of which are found on most computers around the world. If you don’t see a change, your computer doesn’t have that font. But scroll down, the variations on the theme continue without being dependent upon the fonts.

For what has made the sage or poet write, But the fair paradise of Nature’s light.
Keats (1795-1821)
 
For what has made the sage or poet write, But the fair paradise of Nature’s light.
Keats (1795-1821)
 
For what has made the sage or poet write, But the fair paradise of Nature’s light.
Keats (1795-1821)
 
For what has made the sage or poet write, But the fair paradise of Nature’s light.
Keats (1795-1821)
 
For what has made the sage or poet write, But the fair paradise of Nature’s light.
Keats (1795-1821)
 
For what has made the sage or poet write, But the fair paradise of Nature’s light.
Keats (1795-1821)
 
For what has made the sage or poet write, But the fair paradise of Nature’s light.
Keats (1795-1821)
 
For what has made the sage or poet write, But the fair paradise of Nature’s light.
Keats (1795-1821)
 
For what has made the sage or poet write, But the fair paradise of Nature’s light.
Keats (1795-1821)
 
For what has made the sage or poet write, But the fair paradise of Nature’s light.
Keats (1795-1821)
 
For what has made the sage or poet write, But the fair paradise of Nature’s light.
Keats (1795-1821)
 
For what has made the sage or poet write, But the fair paradise of Nature’s light.
Keats (1795-1821)
 
For what has made the Sage or Poet write, But the Fair Paradise of Nature’s Light.
Keats (1795-1821)
 
For what has made the sage or poet write, But the fair paradise of Nature’s light.
Keats (1795-1821)
 
For what has made the sage or poet write, But the fair paradise of Nature’s light.
Keats (1795-1821)
 
For what has made the sage or poet write, But the fair paradise of Nature’s light.
Keats (1795-1821)
 
For what has made the sage or poet write, But the fair paradise of Nature’s light.
Keats (1795-1821)
 
For what has made the sage or poet write, But the fair paradise of Nature’s light.
Keats (1795-1821)
 

CSS Unleashed – Experiments with Quotations, Pull-quotes and Blockquotes

CSS containers and boxes can be used to create a wide range of blockquotes, pull-quotes and quotes in general, highlighting a bit of content to attract attention. These can also be used as boxes to highlight tips, advice, or sidebar information with the help of a few bullets in a list. We want to push the limits on what you can do with CSS containers and boxes with our CSS experiments.

Inspiration for our CSS experiments come from a variety of magazines and printed informational material, using their graphic use of text and color as inspiration. Remember, none of these use tables, only CSS to create the design.

Color and text style always plays an important role in creating dramatic and attention-getting blockquotes and pull-quotes, but also notice the use of space around and in-between a pull-quote. Empty space can also enhance the impact of the quote. And remember, these are CSS experiments, and they may break in different browsers, page designs and layouts, as well as column widths.

For more information on how these were done and how to use these CSS design elements and style experiments, see CSS Experiments – How They Were Done and More and CSS Experiments Putting It All Together.

To see how these CSS experimental boxes and styles work, view the source code of the page. In your web browser menu, click VIEW > SOURCE or VIEW > PAGE SOURCE to view the source code. For the most part, the styles are included inline with each design.

A photograph is a secret about a secret. The more it tells you, the less you know.
Diane Arbus (1923-1971)

A photograph is a secret about a secret. The more it tells you, the less you know.
Diane Arbus (1923-1971)
A photograph is a secret about a secret. The more it tells you, the less you know. Diane Arbus (1923-1971)
A photograph is a secret about a secret. The more it tells you, the less you know. Diane Arbus (1923-1971)
 
A photograph is a secret about a secret. The more it tells you, the less you know. Diane Arbus (1923-1971)
 

It’s an amazing thing to just talk to someone and have handprints frame the quote as if it was being held up against the wall. Who knows? Maybe it is?
Lorelle, Goofing Around
 

No Matter How Slow The Film,Spirit always stands still long enough for the photographer It has chosen. Minor White

The universe does co-operate with the photographer, when the photographer is willing in spirit and soul to take the time it takes, to have the patience, to have the courage, to wait for the moment. It is then the shutter is pressed. Not when the photographer is ready. When the moment is right.
 
No Matter How Slow The Film,Spirit always stands still long enough for the photographer It has chosen. Minor White

The universe does co-operate with the photographer, when the photographer is willing in spirit and soul to take the time it takes, to have the patience, to have the courage, to wait for the moment. It is then the shutter is pressed. Not when the photographer is ready. When the moment is right.
 

Henri Poincare: Science is facts; just as houses are made of stones, so is science made of facts; but a pile of stones is not a house and a collection of facts is not necessarily science.
 
Ernst Haas says: The less descriptive the photo, the more stimulating it is for the imagination. The less information, the more suggestion; the less prose, the more poetry.
 

I LOOK LIKE A PHOTOGRAPHER
Nevada Wier, Travel Photographer
I keep my antennae out and pay attention. I move slowly and work quickly. I want to be an active observer not a passive bystander. It breaks down the barriers because here I am, looking like I just landed from Mars with all this equipment on me, and I’m cute and funny and make them laugh as I should. I build a rapport at that moment.
 

I LOOK LIKE A PHOTOGRAPHER
Nevada Wier, Travel Photographer
I keep my antennae out and pay attention. I move slowly and work quickly. I want to be an active observer not a passive bystander. It breaks down the barriers because here I am, looking like I just landed from Mars with all this equipment on me, and I’m cute and funny and make them laugh as I should. I build a rapport at that moment.
 

5,342
THE NUMBER OF PEOPLE WHO MIGHT VISIT THIS WEB PAGE DAILY BUT ARE UNSURE OF THE PURPOSE OF IT.
Statistics are average and not based on any daily recommended allowances or dietary restrictions, if any.
 

COUPON SALE
There is no must in art because art is free. Kandinsky

Sell your cleverness and buy enchantment. Rumi

This is a coupon sale style with a dashed border around it which gives it a very newspaper feel.

 

ART DEFINED HERE
Art is unquestionably one of the purest and highest elements in human happiness. It trains the mind through the eye, and the eye through the mind. As the sun colors flowers, so does art color life.
Lubbock (1834-1913)
 
ART DEFINED HERE
Art is unquestionably one of the purest and highest elements in human happiness. It trains the mind through the eye, and the eye through the mind. As the sun colors flowers, so does art color life.
Lubbock (1834-1913)
 

» Wildlife needs clutter and chaos. It needs options and opportunities. It needs the slow centuries of growth, nurture, disturbance and decline that produces a complex and unique forest community.
David Middleton, Ancient Growth
 

For what has made the sage or poet write, But the fair paradise of Nature’s light.
Keats (1795-1821)
 
Nature, like a kind and smiling mother, lends herself to our dreams and cherishes our fancies.
Victor Hugo (1802-1885)
 

If we had something to say, it would be that this is white on rust
If we had something to say, it would be that this is rust on yellow
If we had something to say, it would be that this is yellow on orange
If we had something to say, it would be that this is orange on rust, but we don’t, so we just wander around looking cute. That’s good enough, right?
 

Go confidently in the direction of your dreams! Live the life you’ve imagined. Thoreau
 

Look Down
There Is A World Below

“Wandering through the world as I do, I often forget to watch my feet. When I stop to watch them, I often find camouflaged, wondrous things. Insects, lizards, butterflies, ants, flowers….it makes me walk a little more carefully and slowly now.”
Lorelle VanFossen, Personal Journal
 
Look Down
There Is A World Below

“Wandering through the world as I do, I often forget to watch my feet. When I stop to watch them, I often find camouflaged, wondrous things. Insects, lizards, butterflies, ants, flowers….it makes me walk a little more carefully and slowly now.”
Lorelle VanFossen, Personal Journal
 

A photographic image creates a story that was never intended to be told. It is a lie telling the truth, a yes and no at the same time, an is and an is not.

Ernst Haas, photographer and author
 

 
FULFILLING MOMENTS
One of life’s most fulfilling moments occurs in that split second when the familiar is suddenly transformed into the dazzling aura of the profoundly new…These breakthroughs are too infrequent, more uncommon than common; and we are mired most of the time in the mundane and the trivial. The shocker: what seems mundane and trivial is the very stuff that discovery is made of. The one difference is our perspective, our readiness to put the pieces together in an entirely new way and to see patterns where only shadows appeared just a moment before.
Edward B. Lindaman, Thinking in Future Tense
 

PHOTOGRAPHER’S CODE OF ETHICS
An animals wariness is it’s key to survival and critical to the protection of it’s young. The Photographer’s Code of Ethics prohibits harassing, endangering or interfering with the natural life cycle of wild animals. Therefore, we choose to work in National Parks, wildlife viewing areas and occassionaly with hand raised subjects such as this wolf. In this way, we can share the antics and spirit of relaxed, unstressed animals without endangering the animal or it’s young.
Leo Keeler, Alaska Photographer
 

 
As long as I live, I’ll hear waterfalls and birds and winds sing. I’ll interpret the rocks, learn the language of flood, storm, and avalance. Ill acquaint myself with the glaciers and wild gardens, and get as near the heart of the world as I can.
John Muir
 
 
As long as I live, I’ll hear waterfalls and birds and winds sing. I’ll interpret the rocks, learn the language of flood, storm, and avalance. Ill acquaint myself with the glaciers and wild gardens, and get as near the heart of the world as I can.

John Muir

 

Whatever you are from nature, keep to it; never desert your own line of talent.
Be what nature intended you for, and you will succeed; be anything else, and you will be ten thousand times worse than nothing.
Syndey Smith

CSS Unleashed – Experiments Playing With CSS Blocks

Think of CSS divisions and spans as children’s toy building blocks. Give them a background. Fill them with text. Flip them around and see what you can come up with through the creative use of CSS in your CSS experiments.

As with many of these CSS experiments, they don’t all work equally under different web browsers. Sideways text using the flipv and fliph filters don’t work equally across the browsers. Currently, these will only work with Microsoft Internet Explorer as they are proprietary to that browser. These can also break in various browsers and page widths. Narrow the window size or change the browser’s font size and these might fall apart. Still, they are CSS experiments and ideas worth exploring.

For more information on how these were done and how to use these CSS design elements and style experiments, see CSS Experiments – How They Were Done and More and CSS Experiments Putting It All Together.

To see how these CSS experimental boxes and styles work, view the source code of the page. In your web browser menu, click VIEW > SOURCE or VIEW > PAGE SOURCE to view the source code. For the most part, the styles are included inline with each design.

If you find a way of improving or expanding upon these CSS experiements, let us know by leaving a comment below.


This first group of examples uses the vertical flip filter found in Internet Explorer only. It should look like the words “The closer” are across the top and “one” is turned on it’s side.

THE CLOSER
ONE LOOKS
THE FARTHER ONE SEES.
David Cavagnaro
 

The above is a mess if you aren’t using Internet Explorer, but thanks to CSS3, we can use the new rotate property to tilt and flip text around.

THE CLOSER
ONE
LOOKS
THE FARTHER ONE SEES.

David Cavagnaro