Start learning with our library of video tutorials taught by experts. Get started

CSS: Core Concepts

Creating rounded corners


From:

CSS: Core Concepts

with James Williamson

Video: Creating rounded corners

CSS continues to evolve and as it does, capabilities that were either impossible or very difficult to do in the past have suddenly become relatively simple. Such is the case with rounded corners and in the past creating a rounded corners relied on adding additional markup to your HTML, using images to simulate the effect of rounded corners and all sorts of crazy jump into the hoops kind of things. Well now it's as simple as declaring a single property and I want to show you that by using the rounded-corners file, which is found in the 05_07 directory.
Expand all | Collapse all
  1. 4m 57s
    1. Welcome
      55s
    2. Using the exercise files
      4m 2s
  2. 1h 7m
    1. Exploring default styling
      4m 56s
    2. CSS authoring tools
      2m 29s
    3. CSS syntax
      4m 45s
    4. Writing a selector
      4m 10s
    5. Setting properties
      8m 40s
    6. Common units of measurement
      7m 47s
    7. Inline styles
      5m 1s
    8. Embedded styles
      5m 19s
    9. Using external style sheets
      10m 34s
    10. Checking for browser support
      8m 48s
    11. Dealing with browser inconsistencies
      5m 30s
  3. 2h 15m
    1. Structuring HTML correctly
      2m 51s
    2. Element selectors
      4m 52s
    3. Class selectors
      6m 4s
    4. ID selectors
      3m 27s
    5. Using classes and IDs
      10m 7s
    6. Element-specific selectors
      4m 35s
    7. The universal selector
      5m 42s
    8. Grouping selectors
      4m 49s
    9. Descendent selectors
      7m 32s
    10. Child selectors
      5m 7s
    11. Adjacent selectors
      5m 30s
    12. Attribute selectors
      12m 43s
    13. Pseudo-class selectors
      3m 54s
    14. Dynamic pseudo-class selectors
      8m 29s
    15. Structural pseudo-class selectors
      6m 45s
    16. Nth-child selectors
      13m 10s
    17. Pseudo-element selectors
      12m 40s
    18. Targeting page content: Lab
      8m 56s
    19. Targeting page content: Solution
      7m 59s
  4. 42m 39s
    1. What happens when styles conflict?
      4m 0s
    2. Understanding the cascade
      5m 47s
    3. Using inheritance
      6m 11s
    4. Selector specificity
      6m 55s
    5. The !important declaration
      4m 5s
    6. Reducing conflicts through planning
      3m 33s
    7. Resolving conflicts: Lab
      6m 45s
    8. Resolving conflicts: Solution
      5m 23s
  5. 1h 47m
    1. Setting a font family
      7m 10s
    2. Using @font-face
      9m 18s
    3. Setting font size
      7m 35s
    4. Font style and font weight
      6m 52s
    5. Transforming text
      3m 58s
    6. Using text variants
      2m 49s
    7. Text decoration options
      4m 26s
    8. Setting text color
      3m 2s
    9. Writing font shorthand notation
      8m 49s
    10. Controlling text alignment
      6m 33s
    11. Letter and word spacing
      9m 11s
    12. Indenting text
      4m 30s
    13. Adjusting paragraph line height
      10m 30s
    14. Controlling the space between elements
      6m 41s
    15. Basic text formatting: Lab
      8m 45s
    16. Basic text formatting: Solution
      7m 14s
  6. 2h 1m
    1. Understanding the box model
      16m 53s
    2. Controlling element spacing
      14m 29s
    3. Controlling interior spacing
      10m 49s
    4. Margin and padding shorthand notation
      6m 27s
    5. Adding borders
      8m 57s
    6. Defining element size
      10m 7s
    7. Creating rounded corners
      6m 58s
    8. Background properties
      2m 51s
    9. Using background images
      5m 10s
    10. Controlling image positioning
      10m 25s
    11. Using multiple backgrounds
      7m 5s
    12. Background shorthand notation
      5m 25s
    13. Styling container elements: Lab
      7m 55s
    14. Styling container elements: Solution
      8m 17s
  7. 47m 51s
    1. Color keyword definitions
      5m 4s
    2. Understanding hexadecimal notation
      6m 5s
    3. Using RGB values
      4m 58s
    4. Using HSL values
      5m 17s
    5. Working with opacity
      2m 23s
    6. Using RGBa and HSLa
      3m 8s
    7. Styling drop shadows
      5m 38s
    8. CSS gradients
      6m 32s
    9. Working with color: Lab
      4m 26s
    10. Working with color: Solution
      4m 20s
  8. 1m 58s
    1. Additional resources
      1m 58s

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
Please wait...
CSS: Core Concepts
8h 49m Beginner Nov 22, 2011

Viewers: in countries Watching now:

In this hands-on course, James Williamson demonstrates the concepts that form the foundation of Cascading Style Sheets (CSS), including styling text, adding margins and padding, and controlling how images display. The course also explores the tools needed to work with CSS, the differences between embedded and external styles, how to use selectors to target elements, and what to do when styles conflict.

Topics include:
  • Exploring default styling
  • Writing a selector
  • Setting properties
  • Working with common units of measurement, including ems and pixels
  • Structuring HTML correctly
  • Understanding the cascade and inheritance
  • Setting a font family, font size, text color, and more
  • Understanding the box model
  • Styling container elements
  • Working with RGB vs. HSL values
  • Styling drop shadows
Subject:
Web
Software:
CSS
Author:
James Williamson

Creating rounded corners

CSS continues to evolve and as it does, capabilities that were either impossible or very difficult to do in the past have suddenly become relatively simple. Such is the case with rounded corners and in the past creating a rounded corners relied on adding additional markup to your HTML, using images to simulate the effect of rounded corners and all sorts of crazy jump into the hoops kind of things. Well now it's as simple as declaring a single property and I want to show you that by using the rounded-corners file, which is found in the 05_07 directory.

So here we have a very simple structure we have just a little heading one, so it's creating around the corners, and then we have a paragraph on which we are going to round corners. If I preview this in the browser, I can see that we just have an element defined here as a box and I have got a background color applied to it so that we can see kind of how these rounded corners are going to work. Okay now, the syntax for this is relatively simple, I am going to scroll up and find my paragraph rule here and on a line just below that I am going to type in border-radius and give it a border-radius: 25px; If I save this and preview this in the browser you can see right there rounded corners, voila.

You know that's not going to be that big of a deal to a lot of you guys out there, but if any of you have tried to do that prior to this capability you will be jumping for joy the way that I am. The syntax can get a little more complex than this, so let's go back and take a look at some of the options that we have with the syntax. So if I go again back into border- radius, after 25px I am going to do a space there and I am going to do 10px. So essentially, when you pass one value much like the margin and padding shorthand notation when you pass one value, its given to all sides equally, but when you pass multiple values now you're changing some of these corners independently to one another.

When you pass two values like this, the first value indicates the top left and bottom right-hand corner so they are kind of opposite corners. The second value indicates the bottom left and top right-hand corner. So if I say this, preview it you can see what I am talking about. Here we have very round corners on the top left and bottom right and on the opposite corners we are using the smaller value. Now you can also do three values. So after the 10px I am going to do a space here and I will do 5px so we can really kind of see the difference here. And when you use three values the first value is going to be top left, the second value is going to be bottom left top right and the third value is going to be bottom right.

So its kind of splitting those first two values if you will. So if I save this and preview it, you can see what I am talking about, the last value there is now that bottom right-hand corner, the first value is this one and then these guys have an equal radius or radii. And then finally after the last one I am just going to type in zero to give all four, now if you're doing for, its sort of that same trouble thing if you will, top left, top right, bottom left, bottom right. So if I save this and preview it you can see what I am talking about, it just starts to the top left and it just kind of goes all the way around very-very lovely.

Now you also can define the radius individually if you would like, I am now going to get rid of these multiple values. And I could also say border-top-left-radius; So I could do the same thing, top right, bottom left bottom right, just go ahead and place those guys in the middle like this, if I save this and test it, you will notice that the only corner that's getting any type of border radius is the top left. Now the values themselves, you can do some pretty interesting things with these as well.

Whenever you are looking at a rounded corner radius, you basically have two values here, you have the horizontal and you have the vertical radius to this and you can change those two values. Let me show you what I mean by that. So let me modify this syntax yet again I'm a basically reduce it down to border radius, save it, and then I am going to do 25px/15px. I am going to save that, test it, and now what you're seeing is, you are seeing kind of a flattening on the bottom hand sides of this whereas the horizontal radius is still quite robust.

And you can experiment with these values a little bit. So let's go down to like 5px and let's go up to 30px, if I save this, you can see exactly what I'm talking about. Typically when you give it just one value without the forward slash between the two of them its used for both of them, but if you'd like to tweak that a little bit, you can certainly do that and you can actually create some pretty interesting effects this way, I had seen people create cigar like shapes and all sorts of fun stuff with this. So play around those values little bit and see if can come up with any of those special effects on your own.

Now I want to mention a couple sites for you because while simply declaring border radius is fairly simple, the syntax can be a little bit more complex. So I am going to recommend that you go out and read to the CSS backgrounds and borders module level 3 you can find a w3.org/css3-background and if I scroll down little bit here, I can find this rounded corners section and this is going to give you a lot of diagrams to explain to you what the horizontal and vertical radius are in terms of the curve. It's going to give you a lot of different examples of syntax, let's if I can show you how to do things like corner shaping based on the padding.

So there is some really neat stuff here where you can read up on border radius and really customize what you're doing with a particular property. Now the syntax itself can be a bit of a pain because it's relatively new meaning it's not is evenly implemented across browsers yet as may be some of the older properties. It has been around and it has been implemented much longer than a lot of the CSS3 properties, so, for the most part you can use it without fear, but so if you go to a site like css3generator.com these site can help you generate the syntax necessary to get the rounded corners that you are looking for.

So if I go down and choose Border Radius, it's asked me if other border is going to be running equally if I say, no I can come in and just plug in the values that I want. And as I start plugging in some of these values you are going to notice something about the code that is generating down below that, it's adding a lot of vendor prefixes both WebKit and Mozilla, essentially older versions of Firefox and older versions of Chrome and older versions of Safari really relied on these particular vendor prefixes in order to apply the property because they were still sort of playing around with the implementation.

So you may want to make sure that those are in your code, if you are going to support older versions of Firefox, Chrome and Safari as well, it won't be too long before we can just drop those vendor prefixes, but I don't know that we are quite there yet. So regardless of which path you take I very strongly recommend testing border radius thoroughly before you use it, since it since it's a relatively new property and occasionally new properties like this will still some changes in how its adopted and implemented within the browsers. So you want to make sure you are testing for that.

There are currently no FAQs about CSS: Core Concepts.

Share a link to this course
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.
Upgrade now


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.

Upgrade now

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 CSS: Core Concepts.

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
Welcome to the redesigned course page.

We’ve moved some things around, and now you can



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.

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