|  08-04-2012, 05:10 AM | #1 | 
| Connoisseur          Posts: 61 Karma: 1234 Join Date: Jun 2012 Device: none | 
				
				How do you center text vertically?
			 
			
			How do you center text on a page, like in the attached image? I am a complete novice at html but I guess it would involve tags like this: <p class="P-P5">MY CENTERED TEXT</p> and then setting top and bottom margins in the stylesheet. Here is an entry from my current stylesheet. Can you tell me how to adjust it to get the text centred vertically as well as horizontally please? P-P5 { border-bottom: 0; border-top: 0; display: block; font-family: "Times New Roman", serif; font-size: 1.83333em; font-weight: bold; line-height: 1.2; margin-bottom: 0; margin-left: 0; margin-right: 0; margin-top: 0; padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 0; text-align: center } | 
|   |   | 
|  08-04-2012, 06:12 AM | #2 | 
| frumious Bandersnatch            Posts: 7,570 Karma: 20150435 Join Date: Jan 2008 Location: Spaniard in Sweden Device: Cybook Orizon, Kobo Aura | 
			
			There's no way to center vertically, because there's no way to access the page's height (there's no "page", actually). However, some tricks that assume "height: 100%" means the full screen height might work is some readers (and fail in others). | 
|   |   | 
|  08-04-2012, 09:03 AM | #3 | 
| Connoisseur          Posts: 61 Karma: 1234 Join Date: Jun 2012 Device: none | 
			
			OK, thanks, Jellby. So it's probably best if I don't try and center my text, just drop it down from the top of the page a bit using a top margin. Should I specify that in ems? I'm sure that's better than using fixed dimensions e.g. inches. But can you specify a margin as a percent of the page or something? I can only play with my results on my tiny phone and calibre's reader - otherwise I wouldn't ask and just play around with it. Thanks. By the way, I see in one of your books you use "vertical-align: text-top". What does vertical-align do? | 
|   |   | 
|  08-04-2012, 10:55 AM | #4 | |
| Well trained by Cats            Posts: 31,251 Karma: 61360164 Join Date: Aug 2009 Location: The Central Coast of California Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A | Quote: 
 for all attribute definitions (straight from the source) : http://www.w3.org/TR/1999/REC-html40...ttributes.html | |
|   |   | 
|  08-04-2012, 11:00 AM | #5 | 
| Resident Curmudgeon            Posts: 80,746 Karma: 150249619 Join Date: Nov 2006 Location: Roslindale, Massachusetts Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3 | 
			
			You can use a percent like 48% to have a top margin of 48% from the top of the page.  That would work for what you want. Another thing, your CSS code looks like. It came from Word. If so, do yourself a favor and keep your book out of Word. You will save yourself a lot of grief. | 
|   |   | 
|  08-04-2012, 11:12 AM | #6 | 
| Well trained by Cats            Posts: 31,251 Karma: 61360164 Join Date: Aug 2009 Location: The Central Coast of California Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A | 
			
			I have been using JSWOLF's method on books for my PEz. My current method is Trial and error to get the percentage.  Is there a calculated (forward referenced? ) way to arrive at a value? top-margin = 50 - (.5*<the vertical size of the containing block>)% | 
|   |   | 
|  08-04-2012, 11:13 AM | #7 | |
| frumious Bandersnatch            Posts: 7,570 Karma: 20150435 Join Date: Jan 2008 Location: Spaniard in Sweden Device: Cybook Orizon, Kobo Aura | Quote: 
 | |
|   |   | 
|  08-04-2012, 11:23 AM | #8 | 
| Connoisseur          Posts: 61 Karma: 1234 Join Date: Jun 2012 Device: none | 
			
			Thanks, Jellby. If the three lines of text are slightly higher up the page than the center, that will still look good. So I'll probably just stick with 49% and even if it's 49% of the width (rather than the height) I'm sure it'll be fine. I'm PMing you now about the whole Word issue. Then afterwards, depending on what you say, I can start or join another thread to sort myself out. PM on its way now. | 
|   |   | 
|  08-06-2012, 01:52 PM | #9 | 
| Resident Curmudgeon            Posts: 80,746 Karma: 150249619 Join Date: Nov 2006 Location: Roslindale, Massachusetts Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3 | 
			
			But I've used and seen % in the top margin and I've seen it work the way it was intended.
		 | 
|   |   | 
|  | 
| 
 | 
|  Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post | 
| How to center an image vertically | GBAV | ePub | 31 | 08-01-2018 01:57 PM | 
| Authors vertically | jfbok | Library Management | 4 | 05-30-2012 12:31 PM | 
| Center align text in epub | virtual_ink | ePub | 23 | 08-31-2011 06:27 AM | 
| Can you center vertically? | bfollowell | ePub | 10 | 07-07-2011 03:19 AM | 
| Text becomes center-aligned when converting | Alfy | Calibre | 12 | 01-19-2009 12:41 AM |