Answers.Body: <p>JohnLepic is quite right that some devices ignore @page while others accept it happily. Because of this, I find it's best practice to use a small @page value if I use one at all&mdash;it doesn't make sense to design around a feature that may or may not be supported, after all. I generally go for <code>5px;</code> all around.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-05-15T06:35:43.607Z
Answers.Text: Thanks, I remember reading somewhere that the instruction !important is there to indicate to the device that this is important and must be followed . Is that true ?
Answers.UserDisplayName: QPTR
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-05-15T06:38:29.680Z
Answers.Text: That is a valid css instruction, yes. Personally, I don't bother with it in ebooks for the most part, since it takes away some of the flexibility that is so important in reflowable ebooks.
Answers.UserDisplayName: Tom
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-24T20:43:54.750Z
Answers.Text: @QPTR "!important" means that if there's conflicting CSS rules, that it should always use the one marked as "!important".
Answers.UserDisplayName: Chuck
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-05-14T17:40:28.340Z
Answers.LastActivityDate: 2014-05-14T17:40:28.340Z
Answers.UserDisplayName: Tom
Answers.Body: <p>Quite a few rendering engines are actually taking @page into account. Others like iBooks or Kindle are ignoring it <strong>and</strong> overriding the margins' values set for body with default values.</p>
  
  <p>I can confirm @page works well in Adobe Digital Editions -- and some but not all apps + devices using Adobe's RMSDK. </p>
  
  <p>To sum things up, you can use it to set a margin for each page/window/screen while top and bottom margins set for body are just applied to the first (top) and the last (bottom) page of every new (x)HTML file.</p>
  
  <p>As regarding values, don't set them in em in this reflowable world of ours. The more you will increase the font-size, the more those margins will increase as well. </p>
  
  <p>Px and pt will remain the same, whatever you do. </p>
  
  <p>% will remain the same and be interpreted as % of screen, which is the most "reflowable-compliant" choice in theory. 3% of a phone screen &lt; 3% of a tablet screen &lt; 3% of a computer screen.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-05-15T06:34:03.953Z
Answers.Text: Thanks for your answer! It explains quite well what I was looking for. But could you please explain a bit more what you mean when you say ... <<the first (top) and the last (bottom) page of every new (x)HTML file.>> ?
Answers.UserDisplayName: QPTR
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-05-14T13:46:16.587Z
Answers.LastActivityDate: 2014-05-14T13:46:16.587Z
Answers.UserDisplayName: JohnLepic
Body: <p>I am currently creating an ePUB3 file for converting it to Kindle format, and for it be compatible to other ereading devices that support epub.</p>
  
  <p>I noticed a directive in the css file of one of the DRM-free epub books that I am using to help me practice. It goes like this</p>
  
  <pre><code>@page { margin: 5px !important; }
  </code></pre>
  
  <p>After testing this it seems like this is used to add top, bottom, left and right margin spaces on the page. But it seems like (from the message I got while converting on KindleGen) that Kindle doesn't support this. Should I leave it as it is in my ePUB css file while converting to kindle hoping KindleGen to ignore it ? Also, do kindle page margins have to be specified separately or kindle devices work that out on their own with built-in settings. In addition to this, what do you think are the most optimum margins (top, bottom, left and right) values to set, in the @page directive and in the other devices.</p>
  
Tags: <kindle><epub><css>
Title: Setting up margins in ePUB and Kindle ebooks and @page rule
UserDisplayName: QPTR
ThreadText: # Setting up margins in ePUB and Kindle ebooks and @page rule
  
  (Asked by: username_0 on 2014-05-14)
  
  I am currently creating an ePUB3 file for converting it to Kindle format, and for it be compatible to other ereading devices that support epub.
  I noticed a directive in the css file of one of the DRM-free epub books that I am using to help me practice. It goes like this
  @page { margin: 5px !important; }
  
  After testing this it seems like this is used to add top, bottom, left and right margin spaces on the page. But it seems like (from the message I got while converting on KindleGen) that Kindle doesn't support this. Should I leave it as it is in my ePUB css file while converting to kindle hoping KindleGen to ignore it ? Also, do kindle page margins have to be specified separately or kindle devices work that out on their own with built-in settings. In addition to this, what do you think are the most optimum margins (top, bottom, left and right) values to set, in the @page directive and in the other devices.
  
  **Tags:** kindle, epub, css
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_3 on 2014-05-14. Score: 8 | Accepted answer
  
  Quite a few rendering engines are actually taking @page into account. Others like iBooks or Kindle are ignoring it **and** overriding the margins' values set for body with default values.
  
  I can confirm @page works well in Adobe Digital Editions -- and some but not all apps + devices using Adobe's RMSDK.
  
  To sum things up, you can use it to set a margin for each page/window/screen while top and bottom margins set for body are just applied to the first (top) and the last (bottom) page of every new (x)HTML file.
  
  As regarding values, don't set them in em in this reflowable world of ours. The more you will increase the font-size, the more those margins will increase as well.
  
  Px and pt will remain the same, whatever you do.
  
  % will remain the same and be interpreted as % of screen, which is the most "reflowable-compliant" choice in theory. 3% of a phone screen < 3% of a tablet screen < 3% of a computer screen.
  
  > **Comments:**
  > **username_0**: Thanks for your answer! It explains quite well what I was looking for. But could you please explain a bit more what you mean when you say ... <<the first (top) and the last (bottom) page of every new (x)HTML file.>> ?  
  
  ---
  
  ### Answer by username_1 on 2014-05-14. Score: 1
  
  username_3 is quite right that some devices ignore @page while others accept it happily. Because of this, I find it's best practice to use a small @page value if I use one at all—it doesn't make sense to design around a feature that may or may not be supported, after all. I generally go for `5px;` all around.
  
  > **Comments:**
  > **username_0**: Thanks, I remember reading somewhere that the instruction !important is there to indicate to the device that this is important and must be followed . Is that true ?  
  > **username_1**: That is a valid css instruction, yes. Personally, I don't bother with it in ebooks for the most part, since it takes away some of the flexibility that is so important in reflowable ebooks.  
  > **username_2**: @username_0 "!important" means that if there's conflicting CSS rules, that it should always use the one marked as "!important".  
  
  ---
  
  