Documentation
CSS Tutorials
Zero CSS
0
, 0em
and 0px
all represent zero and have no effect on the styling in XHTML documents and the only effect you'll notice is a larger CSS file. Since we want to make sure our customers are getting the best performance when they read their digital content, in the future, please make sure to code all 0em
or 0px
to 0
. You could work on your D.R.Y. and help reduce unnecessary file size by coding:
css1margin: 0 0 0 0;2padding: 0 0 0 0;
to the simple approach of:
css1margin: 0;2padding: 0;
If you wanted you could script this in AppleScript with:
applescript1tell application "BBEdit"2activate3set cssFile to name of active document of project window 14set searchOptions to {search mode:grep, starting at top:true, wrap around:false}5set srcLocate to find "^\\tmargin:(| )0 0 0 0;.*$" searching in text 1 of text document cssFile options searchOptions6if found of srcLocate = true then replace (found text of srcLocate) as text using "\\tmargin:0;" searching in text 1 of text document cssFile options searchOptions saving no7end tell
Since the above just handles margin
we could add padding
but our replace will change:
applescript1tell application "BBEdit"2activate3set cssFile to name of active document of project window 14set searchOptions to {search mode:grep, starting at top:true, wrap around:false}5set srcLocate to find "^\\t(margin|padding):(| )0 0 0 0;.*$" searching in text 1 of text document cssFile options searchOptions6if found of srcLocate = true then replace "^\\t(margin|padding):(| )0 0 0 0;.*$" using "\\t\\1:0;" searching in text 1 of text document cssFile options searchOptions saving no7end tell
given that the above only targets margin
and padding
with a single zero and doesn't check for px
or em
we can target that with a change to our find:
bash1^\t(margin|padding):(| )0(|em|px) 0(|em|px) 0(|em|px) 0(|em|px);.*$
Amazon CSS
This is to help address the reported Amazon Reworks issue of the dropcap. Because we do not have every device to test every Mobi and CSS issues can be tracked back to how the font is designed the following is a correction for the reported error.
You will need to isolate the applied class and it's CSS for the <p>
tag and apply it to the dropcap's span, example:
XHTML file:
xhtml1<p class="first">2<span class="_idGenDropcap-1">M</span>ost every mother remembers an incident beyond the “It’s a3boy!”4</p>
CSS from file:
css1.first {2font-family: 'Berling LT Std Roman', serif;3font-size: 0.917em;4font-style: normal;5font-variant: normal;6font-weight: normal;7line-height: 1.636;8margin: 0 0 0 0;9orphans: 2;10page-break-after: auto;11page-break-before: auto;12text-align: justify;13text-decoration: none;14text-indent: 0;15text-transform: none;16widows: 2;17}18._idGenDropcap-1 {19float: left;20font-family: 'Avenir LT Std 35 Light', sans-serif;21font-size: 3.311em;22font-style: normal;23font-weight: 300;24line-height: 1;25margin-bottom: -0.244em;26margin-right: 0.05em;27margin-top: -0.039em;28}
In the CSS file the following media queries will need to be added:
css1@media amzn-kf8 {2}3@media amzn-mobi {4}
The CSS from the para will need to override the drop cap for Amazon only, example:
css1@media amzn-kf8 {2._idGenDropcap-1 {3font-family: 'Berling LT Std Roman', serif;4font-size: 0.917em;5font-style: normal;6font-variant: normal;7font-weight: normal;8line-height: 1.636;9margin: 0 0 0 0;10orphans: 2;11page-break-after: auto;12page-break-before: auto;13text-align: justify;14text-decoration: none;15text-indent: 0;16text-transform: none;17widows: 2;18}19}20@media amzn-mobi {21._idGenDropcap-1 {22font-family: 'Berling LT Std Roman', serif;23font-size: 0.917em;24font-style: normal;25font-variant: normal;26font-weight: normal;27line-height: 1.636;28margin: 0 0 0 0;29orphans: 2;30page-break-after: auto;31page-break-before: auto;32text-align: justify;33text-decoration: none;34text-indent: 0;35text-transform: none;36widows: 2;37}38}
Missing colon check
Here is a tutorial on how to check for missing colons in a CSS file. This helps to check your work since the W3C validator doesn't catch this currently.
Open a CSS file in a BBEdit Project
Remove blank lines in the file: ^[[:blank:]]*$\r
, breakdown how:
In BBEdit open Find Panel
- menu bar:
Search > Find
- shorthand: ⌘+F
bash1## Find:2^[[:blank:]]*$\r34## Replace:
Grep should be checked, wrap around is optional but suggested
Click Next
If space was found it should go to it then click Replace All
Check for missing colons:
bash1## Find:2(?<!;|{|}|\*/)$
In BBEdit open Find Panel
- menu bar:
Search > Find
- shorthand: ⌘+F
bash1## Find:2(?<!;|{|}|\*/)$34## Replace:
Grep should be checked, wrap around is optional but suggested
Click Next
If any are found they should be highlighted. If semi-colons are not found the application will beep. To help expedite the checking process you can save the Find and Replace as a Pattern then access it through the dropdown:
At the right of where the buttons are in BBEdit's Find Panel there will be two dropdowns sitting left of the buttons:
- clock symbol▼
- g▼
Click the drop down
for g▼
Scroll to the very end of the drop down and click Save...
A dialog will appear with an input field asking for the Pattern name
After adding a Pattern name click Add
Once the pattern is saved you can access the grep pattern from the g▼ drop down.