The CSS margin properties define the space around elements.
Questions tagged [margin]
3723 questions
1
vote
4 answers
margin:auto doesn't seem to work, can't figure it out
I'm trying to horizontally center the red "countdown" div, but it's not going my way. Have been stuck for hours but haven't yet found a single solution.
http://jsfiddle.net/737tM/
HTML:

user3716760
- 25
- 1
- 4
1
vote
1 answer
Margin-top not working on div
I'm so confused by why margin-top will not work. Here is my code:
HTML:
offers for this week
Lorem ipsum dolor sit…

user3541921
- 105
- 1
- 3
- 13
1
vote
4 answers
All elements with margin 0 look different then * selector with margin 0
can anyone explain why putting margins in each tag still leaves a space inbetween the article and header tag but when I use the * selector the space gets removed. I don't necessarily want all elements with a margin of zero. I would rather set each…

chuckd
- 13,460
- 29
- 152
- 331
1
vote
1 answer
@media print margin/padding-top not working
I would like to have some spacing between the top of my page and my logo. However, when I use the print preview in Chrome, no space is showing up at all.
This is my HTML:


2339870
- 1,317
- 3
- 15
- 23
1
vote
4 answers
IMG default padding/margin
I have a problem with the padding or margin of images. I use a lot of images on my site and they are fill a div element so that there are like 8 in a line and in the next line 8 again.
Now I always get a weird spacing between them and I cant figure…

gempir
- 1,791
- 4
- 22
- 46
1
vote
3 answers
Padding extends div off screen
I have a page with a footer on it that is defined as such in the html:
1
vote
3 answers
Downside of inline-block
Imagine h1 is inside a div:
Compare two styles: What is the problem with inline-block?
h1 {
display: block;
Width: 150px;
margin: 0 auto
}
h1 {
display: inline-block;
Width: 150px;
margin: 0 auto
}

Sir Meysam Ferguson
- 193
- 1
- 9
1
vote
1 answer
Displaying Unordered list with div background coloured box to be in the middle
I'm in a tight situation now. I want to align the unordered list box to be in the middle but failed. Tried all means but just didn't manage to solve it. It's somehow in the centre region but not dead center. I believed there's something wrong I did…

Reza San
- 220
- 5
- 13
1
vote
4 answers
Why are there margins around my header when I've set width: 100%?
First timer here. Could someone please tell me why there are margins around the header? How can I fix it?
jsfiddle: http://jsfiddle.net/lauriecai/39J2B/3/
header {
width: 100%;
height: 100px;
background-color: #fff;
}

lolrie
- 79
- 5
1
vote
2 answers
Background hidden when overlaying header with negative top margins
I am trying to overlay a header onto an image. However the background is hidden under the image.
Why is this happening?
http://jsfiddle.net/YRDFB/

Header…

slickrickulous
- 43
- 6
1
vote
2 answers
Change img margin when text is wrapped
I have a textblock and an image inside a stackpanel like this:
…

TheMauritsD
- 41
- 3
1
vote
3 answers
How to use margin/padding on text-align centered element
HTML
Test
CSS
div {
text-align: center;
width:200px;
margin-left:20px;
}
I don't want to have the text at center but pushed slightly right/left. Is this possible?

123321123321
- 81
- 1
- 3
- 10
1
vote
6 answers
Unable to set div margin-top
I tried the following html code (an example from w3schools site):
Nick
- 10,309
- 21
- 97
- 201

Nick
- 10,309
- 21
- 97
- 201
1
vote
1 answer
Methods to add top space to elements in Bootstrap
I am wondering if there is a preferred method to add top-space to shift things down in BS.
My 2 thoughts were using something similar to this
http://pdenya.com/2013/08/08/vertical-space-in-bootstrap/
or creating blank space holders
.
I need to…

Clam
- 935
- 1
- 12
- 24
1
vote
1 answer
Pyqt4: how to add Margins in Qscintilla properly
I want to make my margin look like this:-
and i have made like this till now:-
with the following code:-
self.setMarginType(1,Qsci.QsciScintilla.NumberMargin)
self.setMarginWidth(1,40)
self.setMarginsForegroundColor(QtGui.QColor(120, 128,…

rock
- 167
- 9