Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 12-19-2015, 04:10 AM   #1
ProDigit
Karmaniac
ProDigit ought to be getting tired of karma fortunes by now.ProDigit ought to be getting tired of karma fortunes by now.ProDigit ought to be getting tired of karma fortunes by now.ProDigit ought to be getting tired of karma fortunes by now.ProDigit ought to be getting tired of karma fortunes by now.ProDigit ought to be getting tired of karma fortunes by now.ProDigit ought to be getting tired of karma fortunes by now.ProDigit ought to be getting tired of karma fortunes by now.ProDigit ought to be getting tired of karma fortunes by now.ProDigit ought to be getting tired of karma fortunes by now.ProDigit ought to be getting tired of karma fortunes by now.
 
Posts: 2,553
Karma: 11499146
Join Date: Oct 2008
Location: Miami FL
Device: PRS-505, Jetbook, + Mini, +Color, Astak Ez Reader Pro, PPW1, Aura H2O
stylesheet.CSS anyone?

Ok,
Great strides have been made on my first EPuB book.
Just 4 days ago, I knew only how to do basic programming in HTML0, and now I'm processing an EPuB file.


So far, I've managed to learn, understand, and create my own:

mimetype file,
META-INF\container.xml file,
OEBPS\content.opf file,
OEBPS\Text\*.html files (my book files)
OEBPS\IMG\*.jpg files (my illustrations and images)

The last two are still in the making, but are not hard to due to past experience...

I think I will understand toc.xml just fine, with a little more research,
The Wiki has been a great help, as well as seeing other published books, and comparing them to my own creation.

But I don't get the stylesheet.CSS file at all yet.

It appears different from HTML and XML programming.

Is stylesheet.css absolutely necessary?

Like, it appears to me to be a document describing margins, fonts and sizes, and more other primary data for the garbage collection.
If I would remove the file from an ebook, would it default to some default setting somehow?

I understand that a stylesheet.css could make an ebook appear unique, and allows it to stand out from other ebooks,
but what if I'm perfectly happy with the fonts available in most ebook readers?

Tell me if I'm not getting something!
ProDigit is offline   Reply With Quote
Old 12-19-2015, 05:08 AM   #2
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,549
Karma: 19500001
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
No, CSS files are not compulsory. You can have XHTML without any styling, and the reader will apply some default one. But you shouldn't rely on any default, it could be "everything looks the same" (and that includes, headings, italics, etc.).
Jellby is offline   Reply With Quote
Advert
Old 12-19-2015, 05:46 AM   #3
doubleshuffle
Unicycle Daredevil
doubleshuffle ought to be getting tired of karma fortunes by now.doubleshuffle ought to be getting tired of karma fortunes by now.doubleshuffle ought to be getting tired of karma fortunes by now.doubleshuffle ought to be getting tired of karma fortunes by now.doubleshuffle ought to be getting tired of karma fortunes by now.doubleshuffle ought to be getting tired of karma fortunes by now.doubleshuffle ought to be getting tired of karma fortunes by now.doubleshuffle ought to be getting tired of karma fortunes by now.doubleshuffle ought to be getting tired of karma fortunes by now.doubleshuffle ought to be getting tired of karma fortunes by now.doubleshuffle ought to be getting tired of karma fortunes by now.
 
doubleshuffle's Avatar
 
Posts: 13,944
Karma: 185432100
Join Date: Jan 2011
Location: Planet of the Pudding Brains
Device: Aura HD (R.I.P. After six years the USB socket died.) tolino shine 3
Quote:
Originally Posted by Jellby View Post
No, CSS files are not compulsory. You can have XHTML without any styling, and the reader will apply some default one. But you shouldn't rely on any default, it could be "everything looks the same" (and that includes, headings, italics, etc.).
And it will most definitely be "everything looks quite ugly."
doubleshuffle is offline   Reply With Quote
Old 12-19-2015, 05:47 AM   #4
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 79,748
Karma: 145864619
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by doubleshuffle View Post
And it will most definitely be "everything looks quite ugly."
Nah! It won't look that good.
JSWolf is online now   Reply With Quote
Old 12-19-2015, 06:51 AM   #5
Notjohn
mostly an observer
Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.
 
Posts: 1,519
Karma: 987654
Join Date: Dec 2012
Device: Kindle
>Tell me if I'm not getting something!

You're not getting something!

Everything we write is formatted (badly, very often). The stylesheet (it doesn't have to be named stylesheet -- you have can several stylesheets if you write/publish books in different styles.)

I have been slow to move away from inline styles, because I began writing web pages in 1992 or 1993, just making it up as I went along. I don't think anyone used stylesheets twenty years ago. A stylesheet makes life easier, that's all. I now have a couple or three for my websites (some are mobile-friendly; the old ones are not) and another, called epub.css, for my books. You can see (and borrow, if you like) the last on my blog at notjohnkdp.blogspot.com
Notjohn is offline   Reply With Quote
Advert
Old 12-19-2015, 05:12 PM   #6
ProDigit
Karmaniac
ProDigit ought to be getting tired of karma fortunes by now.ProDigit ought to be getting tired of karma fortunes by now.ProDigit ought to be getting tired of karma fortunes by now.ProDigit ought to be getting tired of karma fortunes by now.ProDigit ought to be getting tired of karma fortunes by now.ProDigit ought to be getting tired of karma fortunes by now.ProDigit ought to be getting tired of karma fortunes by now.ProDigit ought to be getting tired of karma fortunes by now.ProDigit ought to be getting tired of karma fortunes by now.ProDigit ought to be getting tired of karma fortunes by now.ProDigit ought to be getting tired of karma fortunes by now.
 
Posts: 2,553
Karma: 11499146
Join Date: Oct 2008
Location: Miami FL
Device: PRS-505, Jetbook, + Mini, +Color, Astak Ez Reader Pro, PPW1, Aura H2O
I presume without stylesheet, you can still select between heading <h1> to <h4> or so, and between <b>, <i> and <u>,
And presume that you can write the book in one font specified at the top of the html, right?

I still need to learn how the .css file connects to xml and html, probably my next project. Html without this was so much easier!
ProDigit is offline   Reply With Quote
Old 12-19-2015, 05:54 PM   #7
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 79,748
Karma: 145864619
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by ProDigit View Post
I presume without stylesheet, you can still select between heading <h1> to <h4> or so, and between <b>, <i> and <u>,
And presume that you can write the book in one font specified at the top of the html, right?

I still need to learn how the .css file connects to xml and html, probably my next project. Html without this was so much easier!
You can put in <h1> to <h4> and <b>, & <i>. I'm not sure about <u>. You might need to do underlining via CSS.

CSS allows you do define how the ePub looks. You cannot do some things without CSS like embed fonts, smallcaps (even if simulated), and other things. Also, you make it hard to edit it just for yourself.
JSWolf is online now   Reply With Quote
Old 12-19-2015, 09:24 PM   #8
Turtle91
A Hairy Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 3,348
Karma: 20171571
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
The main idea to keep in mind is that any tags you use in your html file should be structural in nature: <h1-6> for headers, <p> for paragraphs, <div> for non-paragraphs or other structural divisions, <blockquote> around block quotes, and <em> or <strong> to identify words or phrases that should be emphasized or prominent. Keep 99.99% all styling in your style sheet.

Devices/apps usually have a default styling, but as mentioned above, it will not look good. You should always tell the device how you want the book to look - even if some devices ignore your wishes.

The way you tell it how you want it to look is using the css stylesheet. You link the stylesheet to your html file by including:

<link href="../Styles/styles.css" type="text/css" rel="stylesheet"/>

in the head of the html file...just replace "../Styles/styles.css" with the path and file name of your css file.

Here is a great resource to help teach yourself (or just reference) all the things you can do with CSS: W3Schools

Cheers,
Turtle91 is online now   Reply With Quote
Old 12-20-2015, 06:13 AM   #9
Notjohn
mostly an observer
Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.
 
Posts: 1,519
Karma: 987654
Join Date: Dec 2012
Device: Kindle
Quote:
Originally Posted by JSWolf View Post
You can put in <h1> to <h4> and <b>, & <i>. I'm not sure about <u>. You might need to do underlining via CSS.
I found that to be the case, and I wound up with the following style in my css:

span.underline {
text-decoration:underline;
}

I don't remember adding it, but I must have done (perhaps with advice received on MB forums) because it's not Sigil-created as sometimes happens.
Notjohn is offline   Reply With Quote
Old 12-20-2015, 06:26 AM   #10
pdurrant
The Grand Mouse 高貴的老鼠
pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.
 
pdurrant's Avatar
 
Posts: 73,941
Karma: 315160596
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Oasis
Quote:
Originally Posted by ProDigit View Post
I still need to learn how the .css file connects to xml and html, probably my next project. Html without this was so much easier!
CSS connects to HTML via tags and classes and ids, and lots of other ways. See CSS Selectors.

e.g.

Code:
body {
   font-family: "Times New Roman:, Times, serif;
}
will apply Times New Roman, or Times, or a serif font to the body of the HTML.

Code:
p {
   text-indent: 1em;
}
will indent the first line of all paragraphs by 1em.

Code:
p.first {
   text-indent: 0em;
}
will set the indent of any paragraph of class first to zero. So that

Code:
<p class="first">In a hole in the ground there lived a hobbit.</p>
won't have an indent.
pdurrant is offline   Reply With Quote
Old 12-20-2015, 06:42 PM   #11
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 79,748
Karma: 145864619
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by pdurrant View Post
Code:
p.first {
   text-indent: 0em;
}
That sort f thing bugs me as it's useless code bloat. Get rid of em and p.

Code:
.first {
text-indent: 0;
}
That's better. Keep it minimalist and that is minimalist.
JSWolf is online now   Reply With Quote
Old 12-21-2015, 12:28 AM   #12
Turtle91
A Hairy Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 3,348
Karma: 20171571
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
Unless, of course, they wanted to differentiate between a p.first and a div.first or somesuch...

You are absolutely correct that you shouldn't need to put units on a value of zero...zero anything is zero - and devices/apps (all of them??) know that.

I would also remove the extra white space and the trailing semi-colon to be ocd-minimalist:
Code:
.first{text-indent:0}
Turtle91 is online now   Reply With Quote
Old 12-21-2015, 04:24 AM   #13
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 79,748
Karma: 145864619
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by Turtle91 View Post
Unless, of course, they wanted to differentiate between a p.first and a div.first or somesuch...

You are absolutely correct that you shouldn't need to put units on a value of zero...zero anything is zero - and devices/apps (all of them??) know that.

I would also remove the extra white space and the trailing semi-colon to be ocd-minimalist:
Code:
.first{text-indent:0}
I did leave in the semi-colon. Thanks for catching that.
JSWolf is online now   Reply With Quote
Old 12-21-2015, 04:53 AM   #14
pdurrant
The Grand Mouse 高貴的老鼠
pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.
 
pdurrant's Avatar
 
Posts: 73,941
Karma: 315160596
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Oasis
Quote:
Originally Posted by JSWolf View Post
That sort f thing bugs me as it's useless code bloat. Get rid of em and p.
You can't get rid of the p without changing the meaning. You can discard the em, which works great until you copy/paste this and want to change the zero to something else.

The two bytes saved in the size of the CSS stylesheet are completely insignificant.

The loss of utility is significant.

Do not over-optimise.


Your comment was also completely off-topic and irrelevant. ProDigit is asking about how and why to use CSS, not how best to optimise it down to the last byte. Sheesh.
pdurrant is offline   Reply With Quote
Old 12-21-2015, 04:54 AM   #15
ProDigit
Karmaniac
ProDigit ought to be getting tired of karma fortunes by now.ProDigit ought to be getting tired of karma fortunes by now.ProDigit ought to be getting tired of karma fortunes by now.ProDigit ought to be getting tired of karma fortunes by now.ProDigit ought to be getting tired of karma fortunes by now.ProDigit ought to be getting tired of karma fortunes by now.ProDigit ought to be getting tired of karma fortunes by now.ProDigit ought to be getting tired of karma fortunes by now.ProDigit ought to be getting tired of karma fortunes by now.ProDigit ought to be getting tired of karma fortunes by now.ProDigit ought to be getting tired of karma fortunes by now.
 
Posts: 2,553
Karma: 11499146
Join Date: Oct 2008
Location: Miami FL
Device: PRS-505, Jetbook, + Mini, +Color, Astak Ez Reader Pro, PPW1, Aura H2O
So, if you have absolutely nothing to add in a css, what would you say, would be the utter minimum that a css file should exist out of?
Can you leave a css fine empty (zero bytes)?
ProDigit is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting cm to em in css stylesheet roger64 ePub 41 06-13-2014 01:00 PM
Question: Find/Replace in css stylesheet ElMiko Sigil 12 12-25-2011 06:29 AM
ePub margins : @page vs stylesheet.css Agama Calibre 1 08-16-2010 04:37 PM
How to maintain a global CSS stylesheet amoroso Sigil 7 07-18-2010 08:37 PM
Where is the stylesheet.css? roger64 Sigil 4 03-23-2010 02:12 PM


All times are GMT -4. The time now is 03:35 PM.


MobileRead.com is a privately owned, operated and funded community.