{"id":2930,"date":"2013-08-30T17:12:26","date_gmt":"2013-08-30T23:12:26","guid":{"rendered":"http:\/\/bililite.com\/blog\/?p=2930"},"modified":"2013-08-30T17:12:26","modified_gmt":"2013-08-30T23:12:26","slug":"writing-and-the-web","status":"publish","type":"post","link":"https:\/\/bililite.com\/blog\/2013\/08\/30\/writing-and-the-web\/","title":{"rendered":"Writing and the Web"},"content":{"rendered":"<p>I haven't been blogging or programming a whole lot over the past year, since I started teaching two Tanach (Bible) classes. Even two hours a week, irregularly, represents a <em>lot<\/em> of work, and pretty much has sucked up all my intellectual free time. So not much Javascript. But I have been recording the notes (sort of condensed essays, 1000&ndash;2000 words) online so I could refer to them, and I've learned something about creating a website that is text, not data or doing-stuff, oriented. The site is <a href=\"http:\/\/kavanot.me\">kavanot.me<\/a>; the classes are <a href=\"http:\/\/kavanot.me\/Shiurim\">Shiurim<\/a> and <a href=\"http:\/\/kavanot.me\/Parasha\">Parasha<\/a>.<\/p>\r\n\r\n<p>I don't expect any reader of this blog to understand the Hebrew or the details of Biblical exegesis, but these notes are more about design issues and resources that would be relevant to almost anyone.<\/p>\r\n<!--more-->\r\n\r\n<h3>Structure<\/h3>\r\n<p>HTML5 makes the basic structure easy:<\/p>\r\n<pre><code class=\"language-html\" >&lt;body&gt;\r\n  &lt;header&gt;\r\n    &lt;h1&gt;&lt;\/h1&gt;\r\n    &lt;nav&gt;&lt;\/nav&gt;\r\n  &lt;\/header&gt;\r\n  &lt;article&gt;\r\n    &lt;section&gt;&lt;\/section&gt;\r\n  &lt;article&gt;\r\n  &lt;footer&gt;\r\n  &lt;\/footer&gt;\r\n&lt;\/body&gt;<\/code><\/pre>\r\n<p>I'm not a believer in side bars (unless I can get some money out of advertising!)<\/p>\r\n\r\n\r\n<h3>Words<\/h3>\r\n<p>People have been printing books for 500 years, and lots of rules and traditions have developed. Treat them like rules of grammar: you can violate them, but violate them intentionally, not out of ignorance. My source for those rules is <a href=\"http:\/\/practicaltypography.com\/\">Matthew Butterick<\/a>, especially his <a href=\"http:\/\/practicaltypography.com\/summary-of-key-rules.html\">summary<\/a> (and it's worth <a href=\"http:\/\/practicaltypography.com\/how-to-pay-for-this-book.html\">paying for the book<\/a>).\r\n<p>As he points out, websites tend to try to be efficient and cram as many letters into as little space as possible, which makes no sense (people do know how to scroll) and just makes the text hard to read.<\/p>\r\n<p>So my CSS follows (the source file is <a href=\"http:\/\/kavanot.me\/css\/stye.scss\">kavanot.me\/css\/stye.scss<\/a>). I use <a href=\"http:\/\/sass-lang.com\/\">SCSS<\/a> (actually <a href=\"http:\/\/leafo.net\/scssphp\/\">scssphp<\/a>) so I can use variables and calculations; I can't imagine going without it now.<\/p>\r\n\r\n<h4>Point Size<\/h4>\r\n<p>Butterick recommends 15-25 pixels for the font size; I use <pre><code class=\"language-css\" >$fontsize: 18px;\r\nbody { font-size: $fontsize; }\r\nheader { font-size: 120%; } \/* 21.5px *\/\r\nnav {font-size: 85%; } \/* 15px *\/\r\nfooter { font-size: 75%; } \/* 13.5px; this is a little small but seems appropriate\r\n                             for the \"fine print\" part of the site *\/<\/code><\/pre>\r\n\r\n<h4>Line Spacing<\/h4>\r\n<p>Butterick recommends 120-145% of the point size. I use<\/p>\r\n<pre><code class=\"language-css\" >$linespacing: 1.35;\r\nbody, h1, h2, h3, h4 { line-height: $linespacing; }\r\n\/* Need to set the line height for each header since they have different\r\n   font sizes and the line spacing has to be proportionate *\/<\/code><\/pre>\r\n\r\n<h4>Line Length<\/h4>\r\n<p>This was the hardest for me to acknowledge, but long lines make for hard-to-read text. Lines should be 45-90 characters long. That's less than 650 pixels for 18px type. It makes for lots of whitespace around the text; if I want my \"page\" to be 850px, I use:<\/p>\r\n<pre><code class=\"language-css\" >$linewidth: $fontsize * 35; \/* found empirically *\/\r\n$width: 850px;\r\n$linepadding:($width - $linewidth) \/ 2;\r\narticle { width: $width; }\r\nsection { padding: 0 $linepadding; }<\/code><\/pre>\r\n<p>Note that since the standard <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/box-sizing\">box model<\/a> calculates the width without including the padding, we set the padding on the child of the <code class=\"language-html\" >&lt;article&gt;<\/code>.<\/p>\r\n\r\n<h4>Fonts<\/h4>\r\n<p>Butterick advises against \"goofy\" fonts, though I couldn't resist and used <a href=\"http:\/\/www.myfonts.com\/fonts\/glc\/1543-humane-jenson\/\">1543 Humane Jenson<\/a> (licensed for non-commericial use) for the \"display\" font (for headers). He also advises against using common fonts for esthetic reasons; you want your text to stand out. I'm not a typography guru and really couldn't tell the difference. I would have no problems with <code class=\"language-css\" >font-family: sans-serif<\/code> and living with whatever your browser came up with.<\/p>\r\n<p>But I need fonts with the full gamut of Hebrew glyphs, including properly placed diacritics. The only choices are those listed by <a href=\"http:\/\/mechon-mamre.org\/c\/c.htm\">Mechon Mamre<\/a>, and I think the nicest by far is the <a href=\"http:\/\/www.sbl-site.org\/educational\/BiblicalFonts_SBLHebrew.aspx\">SBL Hebrew<\/a> font, with nice English glyphs as well, and very legible on screen and on paper.<\/p>\r\n<p>To generate webfonts, I use <a href=\"http:\/\/www.fontsquirrel.com\/tools\/webfont-generator\">FontSquirrel<\/a>. But there are a few caveats. You have to select the Expert mode and select No Subsetting (or Custom Subsetting if you really want to limit the glyphs) to get all the foreign language glyphs. For the professional fonts with their own TrueType hinting, make sure to keep it (don't use the Font Squirrel hinting; it messed up the Hebrew badly).<\/p>\r\n\r\n<h4>Curly Quotes<\/h4>\r\n<p>I know I should use real quotes and apostrophes (<span style=\"font-family: serif\">&ldquo; &rdquo; &rsquo;<\/span>) rather than the typewriter straight ones (\" '), but who wants to keep typing &amp;ldquo;&amp;rdquo; all the time? I could use a PHP version of <a href=\"http:\/\/daringfireball.net\/projects\/markdown\/\">Markdown<\/a>\r\nbut I decided it would be more educational to write my own; I don't mind writing out straight HTML for most of the formatting.<\/p>\r\n<p>The only trick is that you don't want to convert quotes <em>inside<\/em> tags: <span style=\"font-family: serif\">&lt;a href=\"http:\/\/example.com\"&gt;<\/span> should not become\r\n<span style=\"font-family: serif\">&lt;a href=&ldquo;http:\/\/example.com&rdquo;&gt;<\/span>. But I solved <a href=\"\/blog\/2012\/07\/31\/replace-text-not-in-tags\/\">that problem<\/a> already. So all I need is this on the server side:<\/p>\r\n<pre><code class=\"language-php\" >$text = preg_replace_text ('\/\"(.+?)\"\/', '&ldquo;$1&rdquo;', $text);\r\n$text = preg_replace_text ('\/\\'(.+?)\\'(\\W)\/', '&lsquo;$1&rsquo;$2', $text);\r\n$text = preg_replace_text ('\/\\'(\\w)\/', '&rsquo;$1', $text);\r\n$text = preg_replace_text ('\/\\.\\.\\.\/', '&hellip;', $text);\r\n$text = preg_replace_text ('\/--\/', '&mdash;', $text);<\/code><\/pre>\r\n<p>to handle curly quotes, apostrophes, ellipses and em-dashes. It's not perfect; if the quote contains tags it will fail, and the quotes come out the wrong way for Hebrew, but those are rare and I can hand-correct them.<\/p>\r\n\r\n<h4>Paragraphs<\/h4>\r\n<p>Butterick recommends 1&ndash;4 ems of space for first-line indents, or 4&ndash;10 points between paragraphs. I go for the latter: <code class=\"language-css\" >p { margin-bottom: 5px; }<\/code>.<\/p>\r\n\r\n\r\n<h3>Design<\/h3>\r\n<p>All websites look the same, if you stand far away. Butterick has an <a href=\"http:\/\/unitscale.com\/mb\/bomb-in-the-garden\/\">essay<\/a> decrying that, saying we need better, more innovative design. But he contradicts himself: all books look the same as well, if you stand far enough away. He argues that 500 years of print design experience have led to a set of common standards; I think 20 years of web design, while not quite 500 years,  has led to a set of common standards that everyone expects when reading. When you see a site with a big graphic header, tabs\/navigation bar under that, real text and pictures in the middle, ads and some more navigation on one or both sides, and fine print and fine navigation after scrolling all the way down, you're home. You know what to do, what to look for. Butterick has a <a href=\"http:\/\/concoursefont.com\/\">lovely site<\/a> for his Concourse font but it's unreadable; you can edit the type samples and download a PDF specimen file but that information is lost among all the pretty examples.<\/p>\r\n<p>Enough screed. I want my site design to get out of the way; <a href=\"http:\/\/kavanot.me\">kavanot.me<\/a> is probably less minimalist than I would create now but I've grown to like it. I need five colors: the main text contrasting with the background (a pale neutral) and another color for display text. I want a fixed page width (as above, 850px seems to work well) so I need an unobtrusive deep background color for the page outside that. And some kind of border\/shadow between the page and the deep background.<\/p>\r\n<p>I have no design or color sense, so I browse <a href=\"http:\/\/colourlovers.com\">colourlovers.com<\/a> palettes (which conveniently have five colors each) until I find something I like; kavanot.me uses <a href=\"http:\/\/www.colourlovers.com\/palette\/1252920\/Published_in_1932\">Published in 1932<\/a>.<\/p>\r\n<p>So the CSS is:<\/p>\r\n<pre><code class=\"language-css\" >body {\r\n  background-color: $deepbackgroundcolor;\r\n}\r\nheader {\r\n  color: $displaycolor;\r\n}\r\narticle {\r\n  background-color: $backgroundcolor;\r\n  color: $textcolor;\r\n}<\/code><\/pre>\r\n<p>Prior to CSS3, I would have use images created in Photoshop for a soft border; something like <code>top.png<\/code>: <img decoding=\"async\" src=\"http:\/\/ohrpesia.com\/images\/top.png\" alt=\"header background\" \/>, <code>middle.png<\/code>: <img decoding=\"async\" src=\"http:\/\/ohrpesia.com\/images\/middle.png\" alt=\"article background\" \/> and <code>bottom.png<\/code>: <img decoding=\"async\" src=\"http:\/\/ohrpesia.com\/images\/bottom.png\" alt=\"footer background\" \/>, with CSS like:<\/p>\r\n<pre><code class=\"language-css\" >header {\r\n  background: url('\/images\/top.png') no-repeat bottom;\r\n}\r\narticle {\r\n  background: url('\/images\/middle.png') repeat-y center;\r\n}\r\nfooter {\r\n  background: url('\/images\/bottom.png') no-repeat top;\r\n}<\/code><\/pre>\r\n\r\n<p>But now I can use the incredibly complicated <a href=\"http:\/\/www.css3.info\/preview\/box-shadow\/\"><code class=\"language-css\" >box-shadow<\/code><\/a> to create the border. box-shadow allows you to build up multiple shadows, so I can use a centered external shadow and an inset one. A straight centered shadow (<code class=\"language-css\" >box-shadow: 0 0;<\/code>) would be hidden behind the element, so you have to use the spread value to make the shadow bigger, then adjust the blur to smooth out the edge into the deep background. I used:<\/p>\r\n<pre><code class=\"language-css\" >article {\r\n  box-shadow: \r\n    inset 0px 0px 30px 30px $bordercolor, \/* fade on the inside *\/\r\n    0px 0px 10px 10px $bordercolor; \/* fade on the outside *\/\r\n  ;\r\n}<\/code><\/pre>\r\n<p>And that gives me my subtle border with no images, easy-to-modify CSS, and degrades cleanly for browsers that don't support <code class=\"language-css\" >box-shadow<\/code>.<\/p>\r\n\r\n<p>More thoughts on web design as I get around to documenting them.<\/p>","protected":false},"excerpt":{"rendered":"I haven't been blogging or programming a whole lot over the past year, since I started teaching two Tanach (Bible) classes. Even two hours a week, irregularly, represents a lot of work, and pretty much has sucked up all my intellectual free time. So not much Javascript. But I have been recording the notes (sort [&hellip;]","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"_links":{"self":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts\/2930"}],"collection":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/comments?post=2930"}],"version-history":[{"count":28,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts\/2930\/revisions"}],"predecessor-version":[{"id":2960,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts\/2930\/revisions\/2960"}],"wp:attachment":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/media?parent=2930"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/categories?post=2930"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/tags?post=2930"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}