473,386 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

padding-left, padding-right..

hi,

I recently discovered the hard way that when you had padding-right or
padding-left to a div it increases the with of the div... how do you
add left-padding or right-padding to a div w/o changing the width of it?

(for example: I have a div that's 320px wide, content inside is 300px
and I added padding-left:10px but it increased with of div to 330px.. I
want width of it to remain 320px but I need a padding on the left of 10px..)

thank you..
Mar 31 '08 #1
6 4695
maya wrote:
hi,

I recently discovered the hard way that when you had padding-right or
padding-left to a div it increases the with of the div... how do you
add left-padding or right-padding to a div w/o changing the width of it?

(for example: I have a div that's 320px wide, content inside is 300px
and I added padding-left:10px but it increased with of div to 330px.. I
want width of it to remain 320px but I need a padding on the left of
10px..)

thank you..

I vaguely recall something from school - I think it was called
"arithmetic" :-)

<div style="width: 300px; padding: 10px"></div>

300 + 2 * 10 = 320
All kidding aside, if for some reason you can't just subtract the
padding from the width of the box (i.e. if you're using different units
for the width and the padding) then you can just add a second box inside
the first, with no defined width and the padding you want:

<div style="width: 60%">
<div style="padding: 2em">
<p>Content</p>
</div>
</div>
Note: inline styles are for easy demonstration purposes. You shouldn't
actually use them.

Jeremy
Mar 31 '08 #2
In article <47********@news.x-privat.org>, maya <ma********@yahoo.com>
wrote:
hi,

I recently discovered the hard way that when you had padding-right or
padding-left to a div it increases the with of the div... how do you
add left-padding or right-padding to a div w/o changing the width of it?

(for example: I have a div that's 320px wide, content inside is 300px
and I added padding-left:10px but it increased with of div to 330px.. I
want width of it to remain 320px but I need a padding on the left of 10px..)

thank you..
Would this example help you:

<http://netweaver.com.au/alt/widthPadding.html>

(the padding left is exaggerated to demonstrate. The url will not be for
the world long.)

--
dorayme
Mar 31 '08 #3
In article <Qs******************************@earthlink.com> ,
Jeff <jeff@spam_me_not.comwrote:
dorayme wrote:
In article <47********@news.x-privat.org>, maya <ma********@yahoo.com>
wrote:
hi,

I recently discovered the hard way that when you had padding-right or
padding-left to a div it increases the with of the div... how do you
add left-padding or right-padding to a div w/o changing the width of it?

(for example: I have a div that's 320px wide, content inside is 300px
and I added padding-left:10px but it increased with of div to 330px.. I
want width of it to remain 320px but I need a padding on the left of
10px..)

thank you..
Would this example help you:

<http://netweaver.com.au/alt/widthPadding.html>

(the padding left is exaggerated to demonstrate. The url will not be for
the world long.)


I think it's been a while since Dorayme wrote that, as she would not
use a transitional doc-type now!
Well, "she" (and much more correctly "it") should have been changed by
me to Strict and it - no, not me! the other it, the html doc it - is now
Strict. So thanks Jeff.

I just grab whatever html file is lying around and throw something in it
that is to some current need. On this occasion, I seemed to have grabbed
something old or something used to discuss some difference between
strict and not strict. <g>

--
dorayme
Apr 1 '08 #4
In article
<do**********************************@news-vip.optusnet.com.au>,
dorayme <do************@optusnet.com.auwrote:
Well, "she" (and much more correctly "it") should have been changed by
me to Strict and it - no, not me! the other it, the html doc it - is now
Strict. So thanks Jeff.
should really read

Well, "she" (and much more correctly "it") should have changed it - no,
not me! the other it, the html doc it. It is now Strict. So thanks Jeff.

--
dorayme
Apr 1 '08 #5
dorayme wrote:
In article
<do**********************************@news-vip.optusnet.com.au>,
dorayme <do************@optusnet.com.auwrote:
>Well, "she" (and much more correctly "it") should have been changed by
me to Strict and it - no, not me! the other it, the html doc it - is now
Strict. So thanks Jeff.

should really read

Well, "she" (and much more correctly "it") should have changed it - no,
not me! the other it, the html doc it. It is now Strict. So thanks Jeff.
I see....:) thank you all very much for your responses...
Apr 3 '08 #6
dorayme wrote:
In article
<do**********************************@news-vip.optusnet.com.au>,
dorayme <do************@optusnet.com.auwrote:
>Well, "she" (and much more correctly "it") should have been changed by
me to Strict and it - no, not me! the other it, the html doc it - is now
Strict. So thanks Jeff.

should really read

Well, "she" (and much more correctly "it") should have changed it - no,
not me! the other it, the html doc it. It is now Strict. So thanks Jeff.
Hmm, I don't think we've discussed the gender of html docs before.
Although I can certainly understand the confusion behind what gender a
transitional page is!

Jeff
>
Apr 3 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: MichaelY | last post by:
Anyone figure out a workaround for setting the width on labels in 2.0??? I know width is no longer a valid property on inline text elements (per W3C), so what are the other options??? I have many...
6
by: Chris Botha | last post by:
I am porting an existing 2003 project to 2005. Yesterday I found that some of my Java script did not want to work. After eventually examining the HTML view of the new and old form for differences,...
5
by: gimme_this_gimme_that | last post by:
I'd like to create my own version of google suggest GS. If you haven't seen GS check it out at : http://www.google.com/webhp?complete=1&hl=en I've reviewed several AJAX write-ups on the...
3
by: Roy Reed | last post by:
I found a script that converts image alt text to a caption which I've tried to modify for my needs: function addCaption(imgElem) { var captionElem = document.createElement("div");...
6
ak1dnar
by: ak1dnar | last post by:
Hi, I am developing a web site that displays Products, and along with each products there is a Button.There is a <DIV> in my page to display Number of Products Added to the Basket. Items : 0 ...
2
by: jmatos | last post by:
I need to change the style of an element changing its padding-left property (got it in firefox but IE is a different battle..). I can use document.getElementById().style.XX to everything i need,...
3
by: suganya | last post by:
Hi Some professionals already has developed the project using menu. In my company, they have given me task to clear the error in that. It is a script file named as "menubarAPI4.js" which is kept...
1
by: gandhi.vishal | last post by:
Hello, I have an issue. I'm not seeing the reportviewer data at all. The column names come up fine but there is no data in the report table. Here is what I'm doing I created a dataset with the...
6
Claus Mygind
by: Claus Mygind | last post by:
I would like for the two child nodes in the code below to appear side by side. But in all my attempts they are stacked on top of each other. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.