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

Letting users set page type size

From: Typography with CSS in Dreamweaver

Video: Letting users set page type size

While every designer generally does his or her level best to make their sites legible, there's no way you can please everyone. One option is to let the users of your site set the size of the type themselves, as you'll see in this example. So I'm in Live view and if I move over the larger A and click once, the type gets bigger. I'll click again and it gets even bigger still. I can go to the smaller A, click again to make it smaller one more time, so that it is back to the original size and then let's click one last time to make it even smaller.

Letting users set page type size

While every designer generally does his or her level best to make their sites legible, there's no way you can please everyone. One option is to let the users of your site set the size of the type themselves, as you'll see in this example. So I'm in Live view and if I move over the larger A and click once, the type gets bigger. I'll click again and it gets even bigger still. I can go to the smaller A, click again to make it smaller one more time, so that it is back to the original size and then let's click one last time to make it even smaller.

To create this interaction, all you need is a little HTML and JavaScript. Let's take a look at how it's done. I'll close out my example file, which you can find in the Final folder, by the way and now I have resources.htm from the Chapter 2>02_04 folder open, and we're here in Split view because we're going to need to add in some HTML elements and we want to do it as a span tag following resources, so that the two images will appear on the same line. So I'll put my cursor in Code View right after the word Resources, and I'm going to put in a and I want this to have a particular ID.

So I'll give it an ID of typeSize. Now I already have a CSS rule that will float these to the right for this particular ID. So it's important to get that right, and I'll close out the span tag and let Dreamweaver's auto-complete do its magic for me. Now we're going to put in the two images, so I'll put my cursor between the opening and closing of the span tag and go up to the menu and choose Insert > Image and I'm here in my _images folder of Chapter 2 > 02_04 > _images and let's put in the small one first.

So this is a_small.gif. I'll click Choose, and now in the Alt text, instead of just typing in A, I'm going to use it to pass along some helpful information. So I'll enter in Make text smaller, and then click OK, and I also want to make this a link. So I'm going to go ahead with my cursor in the Link field of my Property Inspector, just enter in the pound sign or hash mark or whatever you'd like to call it, that will allow us to use JavaScript to trigger some reactions.

And I also need to put an ID for this particular anchor tag that is surrounding this small image, so that the JavaScript can target it correctly. So this will be id="smallerType". Now let's do the same thing and add in the larger image. I'll position my cursor right after the anchor tag that surrounds the image and then go back up to Insert > Image, pick a_large.gif, our Alt text will be, Make text larger, and again, we'll need to make this into a link.

So with it selected, we'll put in a hash mark in the Link field of the Property Inspector and I'll press Tab there. Dreamweaver will write out the anchor tag and my last step then is to just put in the proper ID here. So it's id="largerType". Okay, so let's take a look at that to make sure that it is floating correctly. So I'll go back to Design view and then enter into Live view and you can see that it floats along on the same line. Now we're ready to bring in the JavaScript.

So I'm going to go code view and then scroll up a bit so that I'm right at the very end of the head tag, and make an extra line, and type in the code to link to the jQuery library. Now you could either bring jQuery in and store it locally, or you can link to the latest library, which is what we're doing here. So I'll open up with the script tag and the type of script that I'm running is a text/javascript.

I'll let code hints help me out there. And next we're going to give it the source attribute, and then you pass in an absolute URL, http://code.jquery.com/ jquery-latest.min, for minified, .js.

http://code.jquery.com/jquery-latest.min .js, and let's close out the script tag and then put in the closing script tag and now that script line is ready to go and we're importing the library. Now I already have a script with this jQuery function set up. So let's link to that now. Create a new line, and we'll type in a new script tag also with the type="text/javascript" and also with the source attribute.

And now I can just press Return, because I have the code hint "browse" available to me, and that will open up the Select File dialog box, and we'll go to Chapter 2 > 02_04 folder, and there you'll see a _scripts folder, open that up, and there's fontSize.js. Choose that. So now I'll just finish out the script tag, closing out the opening tag, and then putting in the closing tag. So now if I refresh the code, you'll see that all of my JavaScript files are listed here.

Let's go to fontSize.js, and I'll go to Code View, so that you can see the code itself. Now explaining it fully is really beyond the scope of this course, but I'll definitely give you the high points here. So first, after setting up the click method that indicates what should happen when each image is clicked. So the first line in the actual code function is an array that holds all the elements I want to modify. You can include or exclude whatever you'd like. Next, I set up another variable that will save the reference for the clicked element as we go through the loop, which is established next with the keyword "each" and this will be applied to each of the array elements: h1, h2, h3, and so on.

So in the primary function, I get the current size, change it to a number, and then get the measurement unit with the slice function. Next, there are two if statements that increase or decrease the font size, depending on which of the two images are clicked, and here is where those IDs come into play. Finally, we put it all together and create a new font size. Okay, let's try this out and see how it works.

So I'll go back to Design view, make sure that you're in Live view, and move your mouse over the larger A and give it a click, and I do have larger text here. Everything is looking pretty good. What about going smaller? Yes, I'm definitely going smaller. Everything seems to be working and the design is basically expanding smoothly to compensate for larger text. Feel free to incorporate this code and technique into your own sites.

Show transcript

This video is part of

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

36 video lessons · 8014 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 preferencesfrom 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.