Home arrow HTML arrow Engaging HTML and CSS3 Background Effects
HTML

Engaging HTML and CSS3 Background Effects


In this first part of a two-part tutorial, I develop a pair of examples to demonstrate how to use the “background” CSS3 property to create attractive background effects. We'll render these effects without relying on background images or dealing with the complexities of JavaScript.

Author Info:
By: Alejandro Gervasio
Rating: 5 stars5 stars5 stars5 stars5 stars / 5
November 08, 2011
TABLE OF CONTENTS:
  1. · Engaging HTML and CSS3 Background Effects
  2. · Building a CSS3-based Background Effect

print this article
SEARCH DEVARTICLES

Engaging HTML and CSS3 Background Effects
(Page 1 of 2 )

As one of the oldest CSS properties, the “background” property (or the “background” shorthand, to express it a bit more correctly) is a venerable feature of the specification. As you know, it allows you to decorate HTML elements with background colors and images, which can be easily positioned via a standard set of coordinates (yes, the classic top-center-bottom and left-right tandems, or by directly specifying X and Y pairs).

The release of CSS3 has taken “background's” functionality to new and exciting levels. Now it’s feasible to use the shorthand in more creative and useful ways. These include adding up to eight background images to the same web page element, or even spicing things up with some eye-catching gradients.

If you’re wondering why adding a few gradients to your HTML elements is a big deal, don’t let the simplicity of the phrase fool you; the process can yield quite impressive results. Moreover, with a bit of patience, it’s possible to create a huge variety of engaging background effects, pretty similar to those that you can achieve with Photoshop. In this case, though, you won’t have to deal with the burdens of a layer styles palette.

In the next few lines I’ll be setting up a couple of easy-to-follow examples to show you how to improve the visual presentation of your web pages with some appealing background effects, thanks to the CSS3 “background” shorthand.       

Taking the First Step: Building a Basic Web Page

The first thing we need to do is create a sample web page. We'll use the page as our backdrop for creating background effects. To keep all the code examples understandable and uncluttered, the page I plan to use is trivial. Its structure looks like this: 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Cool backgrounds with CSS3</title>
</head>
<body>
<div id="wrapper">
    <h1>Cool backgrounds with CSS3 (horizontal lines)</h1>
    <div class="lines">This is a sample element</div>
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse auctor commodo risus, et ultrices sapien vestibulum non. Maecenas scelerisque quam a nulla mattis tincidunt. Etiam massa libero, pharetra vel laoreet et, ultrices non leo. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed posuere ullamcorper lacus et sollicitudin. Morbi ultrices condimentum lacus, sit amet venenatis purus bibendum sit amet.</p>
</div>
</body>
</html>

To be frank, there’s not much that can be said about the above (X)HTML document. Its skeleton is extremely basic. You should notice, however, that it contains a div, which has been assigned a class called “lines.” I decided to include this undefined class because I’ll be using it in a moment to decorate the element with a background effect comprised of a set of horizontal lines.

Actually, I’m getting ahead of myself. The details concerning the definition of this class will be discussed in the next section. Thus, click on the link below and keep reading.


blog comments powered by Disqus
HTML ARTICLES

- Does HTML5 Need a Main Element?
- Revisiting the HTML5 vs. Native Debate
- HTML5: Not for Phone Apps?
- HTML5 or Native?
- Job Hunting? Freelancer.com Lists This Quart...
- HTML5 in the News
- Report: HTML5 Mobile Performance Lags
- The Top HTML5 Audio Players
- Top HTML5 Video Tutorials
- HTML5: Reasons to Learn and Use It
- More of the Top Tutorials for HTML5 Forms
- MobileAppWizard Releases HTML5 App Builder
- HTML5 Boilerplate: Working with jQuery and M...
- HTML5 Boilerplate Introduction
- New API Platform for HTML5

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials