views:

43

answers:

3
<html>
<body>

sdadfasdf a
<ol>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol>
asfdasdfasdfadf

</body>
</html>

Output is

sdadfasdf a

  1. Coffee
  2. Tea
  3. Milk

asfdasdfasdfadf

How to remove above and below spaces in Order list

+3  A: 

remove the padding and margin:

ol {
  margin: 0;
}
KARASZI István
I'm sure you wanted to say: ol, ol li{ [...] :)
methode
yes, I noticed and fixed it, thanks :)
KARASZI István
That will also remove the indentation, which is not what the OP asked.
FreekOne
okay, second fix
KARASZI István
+1  A: 

Hi

Because each browser usually adds paddings, border and margins as a default to all tags, try this css:

html,body,div,p,h1,h2,h3,h4,h5,h6,address,blockquote,code,
ul,ol,li,dt,dl,dd,form,fieldset,hr,table,caption,tr,tbody,
td,tfoot,th,thead,img,object,sub,sup,big,small {
margin: 0;
padding: 0;
border: 0;
}

This should reset everything to 0, including white spaces. And you can move and place your elements with your own rules and laws.

Shaoz
btw, isn't it easier to write : `* { margin: 0; padding: 0; border: 0; outline: 0; }`
KARASZI István
Yeah you can do that too. Forgot to mention it. But just in case you didn't want everything to be reset...
Shaoz
@KARASZI István You can but it's considered a bad practice. Instead use eric meyer's css reset http://meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded/
krike
@krike Why is it a bad practice?
Justin Johnson
because you are going to reset every element even those you don't need to reset, eric meyer's reset gives you more control to what should be reset. most people also add list-style-type:none; which makes it even worse because only list-items use that property. If you do a reset let's do it the right way
krike
yes, but this css snippet is not the same as you linked
KARASZI István
+3  A: 

Using css:

ol  {
  margin-top: 0px;
  margin-bottom: 0px;
  padding-top: 0px;
  padding-bottom: 0px;
}
dark_charlie
The margin attributes should be enough. +1 though for not resetting *everything*.
FreekOne