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

Controlling shorthand notation

From: Managing CSS in Dreamweaver

Video: Controlling shorthand notation

One of the most efficient practices in CSS is the use of shorthand notation for certain properties. Rather than writing four separate properties for top, right, bottom, and left margin, for example, you can write a single margin property and cut down the code required throughout your CSS, considerably. If you hand-code, you're likely to handle the creation of shorthand notation yourself; however, if you use Dreamweaver's Visual CSS tools, you can control how Dreamweaver handles shorthand notation by setting some quick CSS preferences.

Controlling shorthand notation

One of the most efficient practices in CSS is the use of shorthand notation for certain properties. Rather than writing four separate properties for top, right, bottom, and left margin, for example, you can write a single margin property and cut down the code required throughout your CSS, considerably. If you hand-code, you're likely to handle the creation of shorthand notation yourself; however, if you use Dreamweaver's Visual CSS tools, you can control how Dreamweaver handles shorthand notation by setting some quick CSS preferences.

And you can see that we have a rule on our style sheet, a list item selector. It's written incredibly and efficiently, as you can see as I scroll through this. So, we have padding all the way around. We have margin all the way around, and we have font-family and font-size, and we have a lot of borders going on here. We have borders top, right, bottom, and left, background color, image, position, repeat. Okay, so anybody that would create code by hand understands that this is incredibly inefficient. This is not the way that you would probably want to write this code.

Well, if you're creating your CSS through Dreamweaver visually, you'll likely use shorthand notation, so that instead of say five separate properties, you're really only writing one. Well, if you're going to create styles through Dreamweaver's Visual tools, you can control how the shorthand notation is written and when it's written. All you really have to do is set one simple property. So, what I'm going to do is go up again to Edit and choose Preferences. Again, if you're on the Mac, you're going to go to Dreamweaver > Preferences, and I'm going to click on the CSS Styles Category.

Now you can see the main focus of the CSS Styles Preferences is on shorthand notation. I can see here that I don't have any of these items selected. Now if you're opening up this dialog box for the first time, chances are you'd probably see a few of those checked, because Dreamweaver, by default, will go ahead and try to write the most efficient styles possible for you, but you are able to go in here and control this yourself. Now what I'm going to do is I'm going to go ahead and choose using shorthand notation for Background, Margin and padding, Border and border width, and List-Style, but I'm going to leave Font off.

Now the reason I'm going to that is because if you use the shorthand notation for the Font selector, you generally have to pass a lot of information into it: font-weight, font-style, font-size, the font-family that you're looking for. You're free to leave all that off. In fact, for a font shorthand notation, you really only need to pass in size and the font-family itself, but all the things that you leave off it goes ahead and defaults to the default value. Now if you have a style in the cascade above this that has a font-weight bold on a paragraph, and then later on you write another style for paragraph where you just pass in size and font family, well, your paragraph is going to reset from bold, because it will overwrite the earlier style.

So I really don't like Dreamweaver controlling that. If I use shorthand property for the font notation, I'll go ahead and do that myself. So I've got those four selected, and you'll notice it has a choice here for when editing CSS rules. So after the rule has been written, if you edit it, you know when should shorthand be used? Notice that I'm going to go ahead and leave the default according to the settings above. That means that whenever a rule is edited, regardless of its current state, it's going to look at these rules above to determine whether it should convert it to shorthand notation or not. We also have an Open CSS files when modified.

That means if you modify a rule, and the CSS file itself was not already opened, it would go ahead and open that up. Now, since we have related files in Dreamweaver, that's not as important as it used to be, but it's still nice to leave that checked. Now, in the CSS Styles panel, which we're going to be using in just a moment, when you double-click a style to edit it, it's going to do one of three things. It's either going to edit it using the Visual CSS dialog box which is the default, it's either going to edit it through the Properties pane which the Properties Inspector would change to reflect that particular selector, or edit using Code View which would switch you over to Code View, jump to that style and let you edit it.

So, you could sort of choose your own personal preference for that ,as well. For the moment, I'm just going to leave it as Edit using CSS dialog. All right. I'm going to go ahead and click OK, and now we've reset our Preferences. Now, speaking of the CSS Styles panel, I'm going to go over to that and then click on All. So even though we are looking at our CSS in Code View, I can still access and control things through the CSS Styles panel. I'm just going to come right over here to my shorthand.css, double-click the li and notice that based on our preferences, it goes ahead and opens up the CSS Rule definition dialog box.

Okay, so we're going to make a couple of changes here. I'm going to click on the Background Category, and I'm just going to go ahead and change my Background repeat to no-repeat. I'm going to go to my Box Category, and I'm going to change Padding, Same for all to 20 pixels. I'm going to do Margin. I'll leave everybody the same, except for, let's see, the Left Padding. We're going to take the Left Padding, and we're going to change it to 15 pixels as well. Then finally, I'm going to go to my Border Category, and I'm going to change that to 2 pixels.

Now, we do have some font information here, too. So let's make sure that it's not going to rewrite the font selector as shorthand notation. I'm going to go ahead and change the Font -size to 0.9 ems, and I'm just going to go ahead and click OK. Now as soon as I do that, look at how Dreamweaver changed the code. It listened exactly to my Preferences, and it left the font alone. So I still have a font- family and a font-size selector. It did not go ahead and convert that to shorthand notation. Background, Margin, Padding and Border, on the other hand, now I have shorthand notation for those, and look how many fewer lines of code we have here.

We went from 20 something lines of code, I think, to around 7 lines of code for the same selector. So, that's really, really impressive. Now, one of the main objections that I've heard from those that prefer to hand-code over letting Dreamweaver automate some of that process is they feared giving up control of exactly how the code is written. They just preferred to do it the way that they want to do it. However, if you access the CSS Style Preferences, like we just did, you can control when and how Dreamweaver handles the creation of shorthand notation. Now, that alone can go a long way towards making sure your styles remain consistent, whether you or Dreamweaver is writing them.

Show transcript

This video is part of

Image for Managing CSS in Dreamweaver
Managing CSS in Dreamweaver

41 video lessons · 20804 viewers

James Williamson
Author

 
Expand all | Collapse all
  1. 4m 12s
    1. Welcome
      1m 10s
    2. Who is this course for?
      1m 5s
    3. Using the exercise files
      1m 57s
  2. 1h 21m
    1. Controlling CSS in Dreamweaver
      2m 34s
    2. Style formatting options
      4m 59s
    3. Controlling shorthand notation
      6m 9s
    4. Building a style-focused workspace
      6m 10s
    5. CSS Styles panel overview
      8m 18s
    6. The Properties Inspector
      6m 39s
    7. Creating styles visually
      11m 32s
    8. Hand-coding styles
      8m 15s
    9. Code hinting and code completion
      7m 11s
    10. Modifying styles visually
      5m 24s
    11. Using the Code Navigator
      4m 47s
    12. Using CSS Inspect
      9m 52s
  3. 1h 14m
    1. Structuring style sheets
      4m 52s
    2. Writing a style header
      2m 40s
    3. Building a color guide
      6m 5s
    4. Writing a style sheet table of contents
      8m 46s
    5. Creating sections for styles
      9m 10s
    6. Using the CSS Styles panel to organize styles
      10m 29s
    7. Resolving conflicts
      7m 3s
    8. Organizing style properties
      9m 33s
    9. Writing a CSS reset
      5m 20s
    10. Writing global classes
      3m 57s
    11. Creating a style guide
      6m 6s
  4. 1h 7m
    1. Preparing custom starter pages
      11m 32s
    2. Building custom starter pages
      10m 8s
    3. Working with code snippets
      9m 54s
    4. Writing snippets
      11m 30s
    5. Importing snippets
      6m 3s
    6. Understanding snippets libraries
      8m 11s
    7. Building a CSS framework using snippets libraries
      10m 36s
  5. 52m 15s
    1. Writing a print style sheet
      10m 3s
    2. Creating print-specific styles
      10m 45s
    3. Preparing modular styles
      4m 33s
    4. Creating modular style sheets
      7m 9s
    5. Checking browser compatibility
      6m 25s
    6. Using conditional comments for Internet Explorer
      6m 58s
    7. Optimizing CSS with Dreamweaver
      6m 22s
  6. 38s
    1. Goodbye
      38s

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 Managing 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.