Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Designing type gradients

From: Typography with CSS in Dreamweaver

Video: Designing type gradients

Gradients are often used as web page and element backgrounds to provide a sense of depth and flair. Experienced graphic designers are also able to combine gradients and text, typically large-sized fonts to better show off the color transitions. While you can create gradients in CSS3, you can't yet, with the exception of the latest Safari browsers, integrate those gradients in text. However, there's a very clever simple technique that works cross-browser even with IE 6. Let me show you the final result of our work with gradients and text.

Designing type gradients

Gradients are often used as web page and element backgrounds to provide a sense of depth and flair. Experienced graphic designers are also able to combine gradients and text, typically large-sized fonts to better show off the color transitions. While you can create gradients in CSS3, you can't yet, with the exception of the latest Safari browsers, integrate those gradients in text. However, there's a very clever simple technique that works cross-browser even with IE 6. Let me show you the final result of our work with gradients and text.

I'll switch over to my final page here where you can see the Taste of California title has a nice background gradient fading to white. Looks good. Alright, let's go build it. So I have open the tour_detail.htm file found in the Chapter 6 > 06_02 folder and I'm in Live View. Now before we get to the CSS, we'll need to put in just a little bit of additional HTML markup. We'll need to add an empty span tag within the h1 tag.

So to do that I'll go to Split View and so I can quickly find that h1 tag, I'll just highlight it over here in Live View, and there it is, so I'll put in span, close off the tag, and then use Dreamweaver's code completion to actually finish that off. Notice it's just an empty tag, but this is very important because we're going to use this span tag and place a background image in it, that will give the gradient effect. Now the next thing I want to do is just identify this h1 tag a bit.

So I'm going to give it a class of gradientText, because we might want to use this effect elsewhere on the page. Now the reason we need to add a class is because we're going to have to set up a new CSS Rule that includes the position relative property, and that is done because the span tag which is inside of the h1 with a class of gradientText, will need to be positioned absolutely. So now we're ready to go back over to our CSS panel and create a few rules.

So to write my new CSS Rule, I'm going to go ahead and select the h1.gradientText that you see here from the Tag Selector and then at the bottom of the CSS Styles panel choose New CSS Rule. I'm going to make this a little bit less specific and you'll notice that unfortunately Dreamweaver did not pick up the h1, so we'll add that in manually. So we have h1.gradientText and I'll click OK. Now we go to the Positioning category and just add the one property we need, which is Position relative.

I'll click OK, and now we're ready to create the Rule for the span tag, and if I wanted to find that quickly, I could open up into Split View, put my code into the empty span. You won't be able to choose it in Live View or Display View, because it is empty, but now that I have it identified, I can go to New CSS Rule and there you see my gradientText span there. I'm going to go ahead and add in that h1 again, just so that we know that we're targeting that properly.

Click OK, and first I'm going to bring in the background image. I'll go to the Background category and then click Browse next to the Background-image property and you'll find this image in the 06_02 folder in _images and it's called text_ gradient.png. Click Choose. Now this gradient is only about 10 pixels wide, so we'll need to repeat it along the x axis.

So under Background-repeat we'll choose repeat-x, and then we need to move to the Positioning category, where we can set the Position to absolute. Now we need to set the size, so we can do that in the Box category, and the Width that we're going to set is 50% and I'll show you why in just a moment. We'll make it the same height as the text itself which is 36 pixels. Now because this is a span, which is normally in line, we want to instead make sure that it displays as a block element, so that it goes directly over that.

So we'll switch to the Block category and from the Display property, choose block. We're good to go here. So I'll go ahead and click OK, and there you see the gradient instantly applied. Now let me go to Full Design View so I can show you the reason that we went to 50%. As you can see here there is on the same line an orange tab that says, TAKE AN ONLINE TOUR. If we had the width set at 100%, which I can demonstrate right here, you can see that it would overlap that.

So we'll just set it to 50 so that it covers just the text. This effect works fine in all modern browsers as is. In fact, I can even drop out of Live View and you can see it in Dreamweaver's Design View. However, for it to work in Internet Explorer 6, you'll have to add in a conditional comment with a IE-specific filter. So let's go back to our Source Code and I'll go right to Code View and scroll up to the bottom of the head tag, and now I want to put in a conditional comment.

Conditional comments are only visible to Internet Explorer and you can even target them for specific versions. Dreamweaver actually has a couple of snippets built-in to help get you started. So let's go to Window>Snippets and I'll bring that up some, so we can see it more fully, and then open up the Comments category and here we see, If IE 6 Conditional Comment. I'll just double-click on that to insert it, and there you can see the syntax for the conditional comment. Other browsers just recognize it as a comment itself.

So now we'll put in a style tag and I'll close that off. You'll note that Dreamweaver's tag completion doesn't work within conditional comments. You'll have to enter in the closing style tag manually. So let me get rid of that little white space. So now I'm going to write out a CSS Rule for the span tag with a couple of different properties. So you remember that it's h1. gradientText span, and then I'll open and close my CSS, and in the middle we'll put in a background of none.

And that's to make sure that in Internet Explorer 6, the background image is not reproduced. Instead, what we'll need to do is put in what's called a Filter. So you type in the word filter, with a colon, and then the first term is called progid:, and then you put in which one that is, and in this case, it's the DXImageTransform.Microsoft.AlphaImageLoader.

Okay, that's quite a mouthful. DXImageTransform.Microsoft. AlphaImageLoader, and you follow that with an open paren ( and you put in the source for the file. So src=' and now we put in the path to the image itself: _images/text_gradient.png. Close off the single quote and add a comma for the final property which is sizing method.

So sizingMethod= and in single quotes the keyword scale. Close off that parenthesis and close off the whole thing with a semicolon. Alright, that's the full code for the IE 6 workaround, and now your gradientText is good to go across browsers. This technique also works really well when you have a light text against a solid background and a similarly colored gradient.

Experiment away!

Show transcript

This video is part of

Image for Typography with CSS in Dreamweaver
Typography with CSS in Dreamweaver

36 video lessons · 8073 viewers

Joseph Lowery
Author

 
Expand all | Collapse all
  1. 3m 52s
    1. Welcome
      1m 19s
    2. Using the exercise files
      2m 33s
  2. 19m 16s
    1. Working with the Property inspector's HTML tab
      2m 0s
    2. Making the most of the Property inspector's CSS tab
      4m 57s
    3. Defining and changing type with the CSS Rule Definition dialog
      6m 16s
    4. Modifying type directly in the CSS Styles panel
      6m 3s
  3. 19m 45s
    1. Understanding type measurement unit options
      2m 50s
    2. Working with pixels
      2m 34s
    3. Defining a percentage-based page with ems
      6m 51s
    4. Letting users set page type size
      7m 30s
  4. 17m 36s
    1. Getting to know the basic font categories
      1m 32s
    2. Employing web-safe fonts
      3m 20s
    3. Defining new font families
      3m 22s
    4. Exploring CSS3 typeface options
      3m 9s
    5. Setting up @font-face
      6m 13s
  5. 9m 39s
    1. Dispelling the myth of web-safe colors
      1m 13s
    2. Applying color to type
      4m 52s
    3. Incorporating semi-transparent type
      3m 34s
  6. 19m 46s
    1. Setting the font-weight
      3m 48s
    2. Mandating font case
      2m 25s
    3. Exploring font variants
      1m 50s
    4. Utilizing white space effectively
      3m 40s
    5. Changing letter and word spacing
      2m 20s
    6. Defining first-line variations
      2m 19s
    7. Inserting drop caps
      3m 24s
  7. 20m 17s
    1. Applying CSS3 text effects
      5m 26s
    2. Designing type gradients
      8m 27s
    3. Rotating text with CSS transform
      6m 24s
  8. 15m 21s
    1. Implementing advanced headings with HTML5
      3m 11s
    2. Preparing CSS3 multiple-column layout
      4m 50s
    3. Future type: Defining CSS Regions
      7m 20s
  9. 24m 51s
    1. Styling unordered lists
      6m 51s
    2. Specifying a sequence with ordered lists
      5m 14s
    3. Applying definition lists
      7m 19s
    4. Targeting list items with CSS3 nth child
      5m 27s
  10. 20s
    1. Next steps
      20s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Typography with CSS in Dreamweaver.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member ?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferences from the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.