![]() |
#1 |
Karmaniac
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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! ![]() |
![]() |
![]() |
![]() |
#2 |
frumious Bandersnatch
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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.).
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Unicycle Daredevil
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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
|
And it will most definitely be "everything looks quite ugly."
|
![]() |
![]() |
![]() |
#4 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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
|
|
![]() |
![]() |
![]() |
#5 |
mostly an observer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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 |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Karmaniac
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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! ![]() |
![]() |
![]() |
![]() |
#7 | |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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:
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. |
|
![]() |
![]() |
![]() |
#8 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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, |
![]() |
![]() |
![]() |
#9 | |
mostly an observer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,519
Karma: 987654
Join Date: Dec 2012
Device: Kindle
|
Quote:
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. |
|
![]() |
![]() |
![]() |
#10 | |
The Grand Mouse 高貴的老鼠
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 73,941
Karma: 315160596
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Oasis
|
Quote:
e.g. Code:
body { font-family: "Times New Roman:, Times, serif; } Code:
p { text-indent: 1em; } Code:
p.first { text-indent: 0em; } Code:
<p class="first">In a hole in the ground there lived a hobbit.</p> |
|
![]() |
![]() |
![]() |
#11 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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
|
|
![]() |
![]() |
![]() |
#12 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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} |
![]() |
![]() |
![]() |
#13 | |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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:
|
|
![]() |
![]() |
![]() |
#14 | |
The Grand Mouse 高貴的老鼠
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 73,941
Karma: 315160596
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Oasis
|
Quote:
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. |
|
![]() |
![]() |
![]() |
#15 |
Karmaniac
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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)? |
![]() |
![]() |
![]() |
|
![]() |
||||
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 |