🚨 Heads up! This course is no longer supported. We recommend checking out our Webflow Essentials course.
How to add padding to a DIV
Questions
Student Gallery
Be the first to share something.
Course info
Overview
- You'll need a laptop (Mac or PC)
- Dreamweaver CC installed. Dreamweaver can be downloaded from theAdobe website here.
Can I use this tutorial with Adobe Dreamweaver CS4, CS5 or CS6?
Daniel Walter Scott
Founder of Bring Your Own Laptop & Chief Instructor
I discovered the world of design as an art student when I stumbled upon a lab full of green & blue iMac G3’s. My initial curiosity around using the computer to create ‘art’ developed into a full-blown passion, eventually leading me to become a digital designer and founder of Bring Your Own Laptop.
Sharing and teaching are a huge part of who I am. As a certified Adobe instructor, I've had the honor of winning multiple Adobe teaching awards at their annual MAX conference. I see Bring Your Own Laptop as the supportive community I wished for when I was first starting out and intimidated by design. Through teaching, I hope to bring others along for the ride and empower my students to bring their stories, labors of love, and art into the world.
True to my Kiwi roots, I've lived in many places, and currently, I reside in Ireland with my wife and kids.
Downloads & Exercise files
Transcript
We're gonna use the text div tag. In this case, I'm gonna down my breadcrumbs click text. Okay, so it's selected. You can see it's selected here in my selectors panel. And I'd like to scroll down in the properties panel until we find padding. Okay, so what I'd like to do is I'd like to add 40 pixels.
So I've just typed in 40 and hit enter. And on the left and on the right hand side I'd like to enter 20 and hit enter. You can see it's added the padding. You can see this kind of, uh, if I click the div tag down here, the frosty stuff on the left and the frosty stuff on the right means it's 40 on left, 20 on the right. The problem with it though is that it's pushed its neighbor down, which was our image div tag. It's pushed it below it because there's not enough room.
Now it's basically expanded the box by an extra 60 pixels. So what we have to do when we're adding padding, it's a bit weird that Dreamweaver doesn't know that you want to, um, substitute padding for the size. So it's 70, um, 700 pixels wide, plus the padding. So when we need to do is go and find the width of this box. So make sure you've selected text in the text of tag down the breadcrumbs and instead of it being 700, okay, I want it now to be what, six 40 And okay, so six 40 plus the padding equals 700. So whenever you add padding to any boxes, you may have to go and remove it off the width.
Okay. In terms of the height, this case wouldn't matter because we have no height set. You can see height set to auto, which means it'll expand and contract depending on what's in the box. So if we add a padding to the top or the bottom, it wouldn't matter. Great. Let's do it one more time.
Let's do it for the footer down here. Okay. So you can see the copyright is sitting right next to the edge. So I'd like it to push over the exact same. I'd like to push over, uh, 40 pixels. So I'm clicking inside the footer.
I'm gonna click the diviv footer in the breadcrumbs and I'm gonna slide down on my properties panel. And the padding here is going to be 40. Okay. And you can see it hasn't really made any difference 'cause the foot is at the end. Uh, it's our last div tag inside the container. So it's not gonna really cause us like that many problems 'cause nothing afterwards.
But you can kind of see in the right hand side here, it's pushed itself over 40 pixels. So let's do it properly. Let's minus the 40 pixels off this 1024. Okay. So that gets us down to nine hundred, nine hundred and eighty four. Alright, great.
So that's how you add padding to a div tag so that you can get things to line up. Alright, that's of the tutorial. See you in the next one.
How do I add padding to a div tag in Dreamweaver without breaking the layout?
Select the div using the breadcrumbs, then enter the spacing you want in the Properties panel’s padding controls. In the fixed-width layout used here, padding adds to the box’s width, so subtract the total left and right padding from its existing width to keep neighbouring elements in place.
How to Add Padding to Div Tags in Dreamweaver
Key Takeaways
Add space between your content and the edges of a div.
Use the breadcrumbs to select the correct container before changing its properties.
Fix an image dropping below a text box after adding padding.
Keep footer content aligned without making the footer too wide.
Give Your Content Some Breathing Room
When text sits flush against the edge of a div, the layout feels cramped. In our example, the text needs more room on the left and a little more space between it and the neighbouring image on the right.
Padding creates that space inside the div. We’ll add 40 pixels on the left and 20 pixels on the right, then adjust the width so everything still fits.
1. Select the Text Div and Add Padding
Start by selecting the container itself, rather than just placing your cursor in a paragraph.
Click inside the text area you want to adjust.
In the breadcrumbs at the bottom of the document window, click the text div.
Check that the corresponding selector is selected in the Selectors panel.
Scroll through the Properties panel until you find the padding controls.
Enter 40 pixels for the left padding and press Enter.
Enter 20 pixels for the right padding and press Enter.
The text now sits away from the edges. When the div is selected, Dreamweaver’s shaded padding areas help you see the space added on either side.
Great, except there’s a small problem: the image that used to sit beside the text has dropped underneath it.
The extra padding makes the text box too wide for the image to remain alongside it.
2. Fix the Width So the Image Fits Again
The image has moved because the text box now takes up more horizontal space. In this layout, the specified width applies to the content area, with padding added outside that measurement.
Our text div started at 700 pixels wide. Adding 40 pixels on the left and 20 pixels on the right makes it occupy 760 pixels, before accounting for any other spacing. There’s no longer enough room for its neighbour.
To keep the original 700-pixel footprint, subtract the combined horizontal padding from the width:
Original width: 700 pixels.
Left and right padding: 40 + 20 = 60 pixels.
New content width: 700 − 60 = 640 pixels.
Select the text div again using the breadcrumbs. Find its width in the Properties panel, change it from 700 to 640 pixels, and press Enter.
Now the calculation is 640 + 40 + 20 = 700 pixels. The text has its breathing room, and the image fits beside it again.
Reducing the content width restores the side-by-side layout while keeping the new padding.
The important habit: when adding horizontal padding to a fixed-width box like this one, check whether you also need to reduce its width.
3. Check Whether the Height Needs Adjusting
The text div’s height is set to auto. That means it can grow or shrink according to its contents rather than being held to a fixed pixel height.
For this example, there’s no fixed height to reduce when adding top or bottom padding. The box can expand vertically to accommodate the extra space. That’s different from the horizontal constraint we’ve just corrected.
4. Add Matching Padding to the Footer
The copyright text in the footer is also sitting too close to the left edge. We’ll move it inward by the same 40 pixels so it lines up neatly with the text above.
Click inside the footer.
Select the footer div in the breadcrumbs.
Find the padding controls in the Properties panel.
Set the left padding to 40 pixels.
This change may look less disruptive. The footer is the last div inside the container, so there isn’t another neighbouring element being pushed below it. But the added padding still makes the footer wider than intended.
Its original width is 1,024 pixels. Subtract the 40 pixels of left padding and set the width to 984 pixels.
That gives us 984 + 40 = 1,024 pixels overall. The footer content moves inward, while the box stays within its intended width.
Keep the Spacing and the Layout Working Together
Adding padding is straightforward once you keep track of the box’s total size. Select the correct div, add the internal spacing, then check its width and its neighbours. A quick width adjustment can give your content room to breathe without throwing the rest of the page out of alignment.
Key Terms
Div
An HTML container used to group content. Here, separate divs hold the text, image and footer content.
Padding
Space inside a box between its content and its edges. In this example, horizontal padding adds to the specified content width.
Breadcrumbs
The element-selection trail at the bottom of Dreamweaver’s document window. It helps you select the containing div rather than an element inside it.
Auto height
A height setting that allows a box to expand or contract with its content instead of using a fixed height.
FAQs
Why does my image drop below the text after I add padding?
In this layout, padding increases the text div’s total width. If the text and image no longer fit alongside one another, the image drops below. Reduce the text div’s width by the combined left and right padding to preserve its original footprint.
What width should I use for a 700-pixel div with 40 pixels of left padding and 20 pixels of right padding?
Set the content width to 640 pixels. Together with the 60 pixels of horizontal padding, it occupies the original 700 pixels in this example.
Does the footer width need adjusting even if nothing moves below it?
Yes, in this fixed-width example. Adding 40 pixels of left padding to a 1,024-pixel footer increases its total width, so reducing the content width to 984 pixels keeps it within the intended space.
Written by Daniel Walter Scott — Founder of Bring Your Own Laptop & Chief Instructor