Questions tagged [padding]

Extra space inserted into memory structures to achieve address alignment -or- extra space between the frame and the content of an HTML element -or- extra spaces or zeros when printing out values using formatting print commands like, in C, the printf*-family of functions.

Padding in memory structures is the insertion of additional bytes of unused space to make the internal fields of a structure align to desirable address boundaries.

Padding in HTML layout is extra space inserted between the content of the element and its border or frame. Padding is space added to the interior of the element; margin is space around the exterior of the element.

In arrays, padding is addition of extra 0's (zeros) in one or more dimension of the array in a symmetric, circular or replicating manner. This is important for signal and image processing, in the context of and convolution.

3517 questions
2455
votes
16 answers

When to use margin vs padding in CSS

When writing CSS, is there a particular rule or guideline that should be used in deciding when to use margin and when to use padding?
Alex Angas
  • 56,458
  • 39
  • 130
  • 203
576
votes
15 answers

Difference between a View's Padding and Margin

What is the difference between a View's Margin and Padding?
Ragunath Jawahar
  • 18,666
  • 20
  • 102
  • 154
489
votes
13 answers

How to zero pad a sequence of integers in bash so that all have the same width?

I need to loop some values, for i in $(seq $first $last) do does something here done For $first and $last, i need it to be of fixed length 5. So if the input is 1, i need to add zeros in front such that it becomes 00001. It loops till 99999 for…
John Marston
  • 9,869
  • 6
  • 20
  • 17
462
votes
30 answers

How can I pad a String in Java?

Is there some easy way to pad Strings in Java? Seems like something that should be in some StringUtil-like API, but I can't find anything that does this.
pvgoddijn
  • 11,653
  • 14
  • 43
  • 54
408
votes
32 answers

Set padding for UITextField with UITextBorderStyleNone

I wanted to use a custom background for my UITextFields. This works fine except for the fact that I have to use UITextBorderStyleNone to make it look pretty. This forces the text to stick to the left without any padding. Can I set a padding manually…
Sebastian Wramba
  • 9,837
  • 8
  • 36
  • 56
322
votes
18 answers

Python strftime - date without leading 0?

When using Python strftime, is there a way to remove the first 0 of the date if it's before the 10th, ie. so 01 is 1? Can't find a %thingy for that? Thanks!
Solihull
  • 5,299
  • 5
  • 20
  • 12
314
votes
6 answers

Why is there an unexplainable gap between these inline-block div elements?

I have two inline-block div elements, that are the same, positioned next to eachother. However there seems to be a mysterious space of 4 pixels between the two divs despite the margin being set to 0. There are no parent divs effecting them - What is…
Legatro
  • 3,472
  • 4
  • 13
  • 19
310
votes
7 answers

Add leading zeroes/0's to existing Excel values to certain length

There are many, many questions and quality answers on SO regarding how to prevent leading zeroes from getting stripped when importing to or exporting from Excel. However, I already have a spreadsheet that has values in it that were truncated as…
Mark A
  • 5,521
  • 5
  • 23
  • 34
273
votes
29 answers

Android - Spacing between CheckBox and text

Is there an easy way to add padding between the checkbox in a CheckBox control, and the associated text? I cannot just add leading spaces, because my label is multi-line. As-is, the text is way too close to the checkbox:
DougW
  • 25,384
  • 18
  • 76
  • 106
264
votes
20 answers

Left padding a String with Zeros

I've seen similar questions here and here. But am not getting how to left pad a String with Zero. input: "129018" output: "0000129018" The total output length should be TEN.
jai
  • 19,731
  • 28
  • 83
  • 116
262
votes
12 answers

Add padding on view programmatically

I am developing Android v2.2 app. I have a Fragment. In the onCreateView(...) callback of my fragment class, I inflate an layout to the fragment like below: @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle…
Leem.fin
  • 35,699
  • 70
  • 166
  • 297
243
votes
11 answers

Structure padding and packing

Consider: struct mystruct_A { char a; int b; char c; } x; struct mystruct_B { int b; char a; } y; The sizes of the structures are 12 and 8 respectively. Are these structures padded or packed? When does padding or packing take place?
Manu
  • 4,584
  • 6
  • 27
  • 37
237
votes
7 answers

How do I prevent the padding property from changing width or height in CSS?

I am creating a site with DIVs. Everything's working out except when I create a DIV. I create them like this (example): newdiv { width: 200px; height: 60px; padding-left: 20px; text-align: left; } When I add the padding-left…
Sam
  • 16,299
  • 5
  • 20
  • 11
231
votes
20 answers

Android: TextView: Remove spacing and padding on top and bottom

When I have a TextView with a \n in the text,, on the right I have two singleLine TextViews, one below the other with no spacing in between. I have set the following for all three TextViews. android:lineSpacingMultiplier="1"…
700 Software
  • 77,509
  • 74
  • 213
  • 324
208
votes
37 answers

Adding space/padding to a UILabel

I have a UILabel where I want to add space in the top and in the bottom. With minimun height in constrainst I've modified it to: EDIT: To do this I've used: override func drawTextInRect(rect: CGRect) { var insets: UIEdgeInsets =…
Annachiara
  • 2,107
  • 2
  • 11
  • 10
1
2 3
99 100