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

Using a span tag to add a class and customize appearance

From: Creating a CSS Style Guide: Hands-On Training

Video: Using a span tag to add a class and customize appearance

So far all the styles that we have created are associated with an HTML tag, but what if we want to create a style that we can use throughout the page that adds emphasis or punctuates something or brings a highlight to a certain feature on the page? Can we do that? Yes, this is called a class. A class is a type of style that you can use any where on your HTML page as many times as you want. So let's try making one. Let's select the word bold right here in the body paragraph and then let's go down to the Property Inspector.

Using a span tag to add a class and customize appearance

So far all the styles that we have created are associated with an HTML tag, but what if we want to create a style that we can use throughout the page that adds emphasis or punctuates something or brings a highlight to a certain feature on the page? Can we do that? Yes, this is called a class. A class is a type of style that you can use any where on your HTML page as many times as you want. So let's try making one. Let's select the word bold right here in the body paragraph and then let's go down to the Property Inspector.

Before we start this make sure that you have the CSS button selected. Remember we are not working on structure now; we are creating styles. So this button should be selected, CSS for cascading style sheets. So I want to make something that's bold. I'm going to click on the Bold button and the instant I do that, a dialog box comes up called New CSS Rule. This is a new dialog box and a new feature inside of Dreamweaver CS4. It's a great feature. I really like it. You cannot create or change your web page without Dreamweaver asking you, is this some sort of style? It makes a guess and a good guess that this is a class and it actually defines what a class can do. It is a style that can be applied anywhere throughout your HTML page and that's exactly what we want. So let's leave it there. If you click on the dropdown menu, you'll see there is lots of other kinds of styles that we can create, but class is the one we want. Dreamweaver made the correct guess.

The second, and a really important thing, is to name the class a meaningful name. Since this is the style that I want to use to bold or emphasize words, I'm going to call this boldWord. I'm using camel humping, boldWord. The last thing and this is very important, because you could have lots of style sheets and lots of places where you could save this, is where do you want this rule to be defined? At this point all of our styles are in the styles tag inside of the head tag of this HTML document. So we will select, as Dreamweaver guessed, This document only. Let's click on the button OK. I can see that it's bold, but I'd also like to change the color.

So while I have it already targeted with this rule, I can continue to style or design this rule. Let's go back over to Color and let's type in the number 960 and click on our Tab key. Now I'm happy with this. This is a color that I have picked from my header. It goes along with my color palette. If I focus out on to the document window, I can see how that style will appear inside of my HTML page. It looks really, really good.

Let's take a look to see what has happened here, what has this meant for our page and for our code. I'm going to reselect the word bold and you'll notice that now in the Tag Inspector we have a new tag that we haven't seen before. It says span.boldWord. Let me translate that for you. This is a span tag and it has a class or a style attached to it that's called boldWord. Down in the Properties Inspector, because we've selected this word it says this word has this style attach to it. And last but not least, let's look in Code view. Let's choose the Split button. Now we get a good look at this new tag.

If we select this, we can see the span tag. The way I like to think of a span tag is sort of like parenthesis. Anything within these two tags, the opening span tag and the closing span tag, will be affected by this class or this style. So let's look at that. Here is the opening tag, here is the class and the name of this style is boldWord and this needs to be in quotation marks, and the item being affected is between the opening and closing tags. Think of span is being like something you hold between your two hands. Let's click on Design view.

The other thing we need to take note of where has that style been added in our Styles panel. Well, we are doing all of our styles embedded in this style tag, let's scroll down. Since it's the last style that we've created, it shows up at the bottom of our Style panel. It is a little different than our other styles. What's so different about it? The period. The period here indicates that this is a class. So whenever you see a period in front of the name of the style, you can know that it is a custom style or it's a class.

So can I apply it to other things? Certainly, I can use this style again and again, if I want and I can remove this style. I always think it's important to know how to undo whatever you do. We don't always do things right at the first time. So if I were not focused on this page and I wanted to remove the style, I would double-click on the word, returned down to my Property Inspector, go to Targeted Rule, and when I click on this dropdown menu a number of choices appear. First of all I see the cascade, all of the tags that I have created so far.

I could make a new rule. I could make a new inline style. I can remove and I see the class that I have created. In this case, I would say I'm not happy with what I have done, I would like to remove this class, I want it to go back to the way it was and look like the rest of the words in body text. That takes the style off and now it looks just like it did before, but please notice up in your Styles panel boldWord still exists and if I click on it, it is still a style in my embedded styles. If I click on Code view and scroll to the top of my page where my styles exist and look at the bottom of my style tag, here is my closing style tag. Since boldWord was the last style added, the last class added, it appears.

So I've removed it from my document, but it still exists in my styles. If I'm never going to use this again, a good practice would be to clean this up and delete this style. I can do it inside of Code view by selecting the name of the class and all of the attributes and values associated with it, and then click on my Delete key or we can go back to Design view, come over to our Rules right here, I can select the word right here and notice that there is a trash can. I can delete this style by clicking on this trashcan. Either one works, you just need to do figure out your flow and how it should work for you.

So now I would like to reapply this style, because I know it still part of my styles and I can use it again. That's the whole point of classes that you can use them again and again to add an effect on your webpage and to accentuate some element. I am going to select the word bold, go over to my Properties Inspector, click on the dropdown menu for Targeted Rule, scroll all the way to the bottom and choose boldWord. As I have been saying all along, we can use a class style again and again.

So let's select another word. Let's select the word emphasis. It's up in our body paragraph. Go down to my Property Inspector. It says there is nothing attached to this, no style applied. Click on the dropdown menu, scroll all the way to the bottom where our classes appear and let's choose boldWord. Let's click anywhere outside of the word, and now you can see that we can apply this style or this class throughout this webpage as many times as we want.

It's really fun and it makes for an interesting page, especially if we use it effectively and sparingly. Now I have a quotation and I have some other areas that I really want to emphasize, but I want to style them in a different way. So I'm going to select the span tag right here and I would like this to be italicized and red. So I'm going down to my Property Inspector, keeping in mind that my CSS button is still selected. Click on the eye for Italic, it says no, no, no you can't do anything without telling us what you are doing and what kind of style this is.

Again, Dreamweaver guesses correctly. This is a class, something I'll apply more than one time. I'm going to put my I-beam into the Selector Name and I'm going to type hiLite using camel humping again. I want it to define in this document, because I'm using embedded styles and then I'll click OK. So as it's selected I can click out and see did the italicize style apply. Yes, it did, but it's not the correct color. So can I go back and change my mind and edit? Yes.

Let's select that again. And while it is selected and while we see the name of the style in the Targeted Rule, we can come over to the color and change that. Let's pick a nice red color, I'll pick this color right here C30, and deselect that selection. That looks good. I am using this hiLite to emphasize certain things like code in this page.

So I'm going to select class as well, because it's a piece of code and I have a real reason to use hLite. I want to draw your attention to the fact that these are tags or code for styling a page. Go down to the Targeted Rule, click on my dropdown menu and choose hiLite. Notice I have two choices now: boldWord or hiLite. Classes are great styles to use throughout your page to bring attention to certain features and to emphasize certain kinds of things going on in your page.

For bold and emphasis, I want to really be emphatic, but with the red italicized I want to use that wherever there are special code or special kinds of quotations inside my page. Now that we've made two class styles, let's take a look at how we can edit those and use those in other places in our web page.

Show transcript

This video is part of

Image for Creating a CSS Style Guide: Hands-On Training
Creating a CSS Style Guide: Hands-On Training

35 video lessons · 28026 viewers

Laurie Burruss
Author

 
Expand all | Collapse all
  1. 6m 58s
    1. Welcome
      1m 9s
    2. Objective of this course
      3m 38s
    3. Using the exercise files
      2m 11s
  2. 28m 26s
    1. Starting Dreamweaver for the first time
      3m 38s
    2. Defining a website
      4m 3s
    3. Understanding the Dreamweaver interface
      9m 43s
    4. Setting up a custom workspace
      4m 10s
    5. Setting essential preferences
      6m 52s
  3. 56m 54s
    1. Laying out a page in a text document
      3m 40s
    2. Creating and saving a new document
      3m 27s
    3. Inserting an image
      8m 22s
    4. Marking up text using the Property Inspector
      6m 48s
    5. Marking up text by hand
      9m 21s
    6. Inserting, formatting, and selecting a table
      8m 16s
    7. Creating links
      12m 26s
    8. Styling a footer
      4m 34s
  4. 22m 15s
    1. Using Modify Page Properties to create embedded styles
      12m 22s
    2. Creating links with CSS
      4m 55s
    3. Working with Code, Split, and Design views
      4m 58s
  5. 8m 52s
    1. Defining browsers to test a web page
      2m 24s
    2. Previewing a web page in a browser
      6m 28s
  6. 16m 44s
    1. Using a span tag to add a class and customize appearance
      10m 34s
    2. Using the Tag Inspector to create and edit additional styles
      6m 10s
  7. 48m 42s
    1. Exporting existing styles into an external style sheet
      7m 0s
    2. Using the CSS Styles panel to add a new style
      5m 43s
    3. Using the div tag to create a content container
      11m 8s
    4. Overriding the default browser styles
      2m 46s
    5. Applying padding and margins
      4m 57s
    6. Styling header tags
      5m 34s
    7. Creating and styling compound tags
      5m 12s
    8. Editing preexisting rules
      6m 22s
  8. 19m 36s
    1. Improving the Footer
      5m 12s
    2. Commenting a CSS style sheet
      7m 0s
    3. Creating a custom color palette
      7m 24s
  9. 3m 6s
    1. Style sheet final review
      3m 6s

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.

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 Creating a CSS Style Guide: Hands-On Training.

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.