By Robert Sedovšek (@sedovsek)
Choosing the right type, size, height, space etc.
You might learn that here:
<head>
<link rel="fontdef" src="./path/to/portable_font_resources.pfr">
</head>
<body>
<font face="portable font resources">huray!</font>
</body>
Also possible in Internet Explorer via plugin.
Core Fonts for the Web (Project begun by MS in 1996 to make a standard pack of fonts for the internet):
Web-Safe fonts!
@font-face {
font-family: 'my-awesome-font';
src: url('my-awesome-font.pft') format(truedoc),
url('my-awesome-font.ttf') format(truetype);
}
p {
font-family: 'my-awesome-font';
}
:((
@font-face {
font-family: 'MyFontFamily';
src: local('MyFontFamily'),
url('myfont-webfont.eot?#iefix') format('embedded-opentype'),
url('myfont-webfont.woff') format('woff'),
url('myfont-webfont.ttf') format('truetype'),
url('myfont-webfont.svg#svgFontName') format('svg');
}
SMACK! MEGA MESS!
sIFR — scalable Inman Flash Replacement
Cufón
BINGO!
EULA — End User License Agreements
@font-face {
font-family: 'MyFontFamily';
src: url('myfont-webfont.eot?#iefix') format('embedded-opentype'),
url('myfont-webfont.woff') format('woff'),
url('myfont-webfont.ttf') format('truetype'),
url('myfont-webfont.svg#svgFontName') format('svg');
}
@font-face { font-family: 'MyFontFamily'; src: url('
myfont-webfont.eot') format('embedded-opentype'), url('myfont-webfont.woff') format('woff'), url('myfont-webfont.ttf') format('truetype'), url('myfont-webfont.svg#svgFontName') format('svg'); }
@font-face { font-family: 'MyFontFamily'; src: url('myfont-webfont.eot') format('embedded-opentype'), url('
myfont-webfont.woff') format('woff'), url('myfont-webfont.ttf') format('truetype'), url('myfont-webfont.svg#svgFontName') format('svg'); }
@font-face { font-family: 'MyFontFamily'; src: url('myfont-webfont.eot') format('embedded-opentype'), url('myfont-webfont.woff') format('woff'), url('
myfont-webfont.ttf') format('truetype'), url('myfont-webfont.svg#svgFontName') format('svg'); }
@font-face { font-family: 'MyFontFamily'; src: url('myfont-webfont.eot') format('embedded-opentype'), url('myfont-webfont.woff') format('woff'), url('myfont-webfont.ttf') format('truetype'), url('
myfont-webfont.svg#svgFontName') format('svg'); }
@font-face { font-family: 'MyFontFamily'; src: url('
myfont-webfont.eot') format('embedded-opentype'), url('myfont-webfont.woff') format('woff'), url('myfont-webfont.ttf') format('truetype'), url('myfont-webfont.svg#svgFontName') format('svg'); }
SMACK! NOT GOOD!
@font-face { font-family: 'MyFontFamily'; src: url('myfont-webfont.eot
#iefix') format('embedded-opentype'), url('myfont-webfont.woff') format('woff'), url('myfont-webfont.ttf') format('truetype'), url('myfont-webfont.svg#svgFontName') format('svg'); }
Internet Explorer fix
Chrome renders the rest of the page, but until the web font has loaded, it displays a blank space in place of the text that uses the font.
Firefox first displays the text in the default font, and then re-renders text in the web font once it has loaded. (This behavior is known as a "flash of unstyled text.")
Safari renders the rest of the page, but until the web font has loaded, it displays a blank space in place of the text that uses the font.
Internet Explorer renders the rest of the page, but until the web font has loaded, it displays a blank space in place of the text that uses the font.
Note: For best display in IE, make the stylesheet <link> tag the first element in the HTML <head> section. In IE, if the link is placed after <script> tags, the entire page will block and not display anything until the web font is loaded.
Blank space in place of the styled text while the web font is loading:
Default font, which switches over when the web font has loaded.
Result: so-called Flash of Unstyled Text (aka FOUT).
WebFont Loader
http://code.google.com/apis/webfonts/docs/webfont_loader.html
Changing styles when fonts finish loading
.wf-loading p { // Show paragraphs in serif font until fonts have loaded.
font-family: serif; //or
visibility: hidden;
}
.wf-inactive p { // Show paragraphs in serif font if fonts have failed to load.
font-family: serif;
}
.wf-active p { // Show paragraphs in Tangerine when the fonts have loaded.
font-family: 'Tangerine', serif;
}
.wf-loading p { font-family: serif; font-size: 16px; }
.wf-inactive h1 { font-family: serif; font-size: 16px; }
.wf-active h1 { font-family: 'Cantarell', serif; font-size: 16px; }
Note: If all requested fonts fail to load, wf-inactive is applied.
<html>
<head>
<script type="text/javascript">
WebFontConfig = {
google: { families: [ 'Tangerine', 'Cantarell' ] }
};
(function() {
var wf = document.createElement('script');
wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
'://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
wf.type = 'text/javascript';
wf.async = 'true';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(wf, s);
})();
</script>
...
This code reproduces Firefox's default behavior in all other modern browsers.
<html> <head> <script type="text/javascript"> WebFontConfig = {
google: { families: [ 'Tangerine', 'Cantarell' ] }}; (function() { var wf = document.createElement('script'); wf.src = ('https:' == document.location.protocol ? 'https' : 'http') + '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js'; wf.type = 'text/javascript'; wf.async = 'true'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(wf, s); })(); </script> ...
This code reproduces Firefox's default behavior in all other modern browsers.
You can choose from specified providers:
In addition to options above, there is also a custom module that can load a stylesheet from any web-font provider:
WebFontConfig = {
custom: { families: ['OneFont', 'AnotherFont'],
urls: [ 'http://myotherwebfontprovider.com/stylesheet1.css',
'http://yetanotherwebfontprovider.com/stylesheet2.css' ] }
};
...
CSS text-shadow is a simple technique of adding a shadow to the text. Doh?
element {
text-shadow: x-offset y-offset blur-radius #000;
}
I am the paragraph that can haz shadow. Adjust me, please!
I am the paragraph that can haz multiple shadow. Adjust me, please!
Allowing long chunks of text to wrap to multiple columns. This technique is widely popular in editorial design of magazines and newspapers.
element {
(-prefix-)column-width: <length unit> | auto; // or
(-prefix-)column-count: <integer> | auto;
(-prefix-)column-gap: <length unit> | normal;
(-prefix-)column-rule-color: <color>;
(-prefix-)column-rule-style: <border-style>;
(-prefix-)column-rule-width: <border-width>;
}
h1 {
/* Control how the content displays within each column. */
break-before: always | auto | avoid | inherit;
break-after: always | auto | avoid | inherit;
break-inside: always | auto | avoid | inherit;
}
element {
/* none: The element does not span multiple columns. */
/* all: The element spans across all columns. */
column-span: none | all;
/* balance: Balance content equally between columns, if possible. */
/* auto: Fills columns sequentially. */
column-fill: auto | balance;
}
Source: W3C Editor’s Draft — CSS Multi-column Layout Module.
Source: Smashing Magazine — Six CSS Layout Features To Look Forward To.
Source: Smashing Magazine — Six CSS Layout Features To Look Forward To.
The CSS regions module allows content to flow across multiple areas called regions. It provides an advanced content flow mechanism.
The following HTML code snippet shows the content to flow between the regions 1, 2, 3 and 4. Region A represents an image.
<article id="article">
<h1>Introduction</h1>
<p>This is an example ...</p>
<h1>More Details</h1>
<p>This illustrates ...</p>
<p>Then, the example ...</p>
<p>Finally, this ...</p>
</article>
Examples of HTML elements, used as regions.
<div id="region1"></div>
<div id="region2"></div>
<div id="region3"></div>
<div id="region4"></div>
The following HTML code snippet shows the content to flow between the regions 1, 2, 3 and 4. Region A represents an image.
#article {
(-prefix-)flow: foo;
(-prefix-)flow-into: foo;
}
#region1, #region2, #region3, #region4 {
content: (-prefix-)from-flow('foo');
(-prefix-)flow-from: foo;
}
Source: Adobe: CSS3 regions: Rich page layout with HTML and CSS3.
An element becomes an "exclusion element" when wrap-flow is set to a value that is not auto. The following values are avaliable:
#exclusion {
wrap-flow: auto | both | start | end | maximum | clear;
}
Other avaliable properties:
#exclusion {
shape-image-threshold: <alphavalue>;
shape-inside: outside-shape | auto | <shape> | <uri>;
shape-outside: auto | <shape> | <uri>;
wrap: <wrap-flow> || <wrap-margin> [ / <wrap-padding>];
wrap-flow: auto | both | start | end | maximum | clear;
wrap-margin: <length>;
wrap-padding: <length>;
wrap-through: wrap | none;
}
The following CSS code snipplet shows the use of exclusions.
#exclusion {
position: absolute;
background: lightblue;
wrap-flow: auto | both | start | end | maximum | clear;
}
The example of HTML to form the following examples.
<article>
<section id="exclusion">Donec metus messa, mollis...</section>
Lorem ipsum dolor sit amet...
</article>
Source: W3C Working Draft — CSS Exclusions and Shapes Module.
Source: W3C Working Draft — CSS Exclusions and Shapes Module.
Source: W3C Working Draft — CSS Exclusions and Shapes Module.
Source: W3C Working Draft — CSS Exclusions and Shapes Module.
Source: W3C Working Draft — CSS Exclusions and Shapes Module.
Source: W3C Working Draft — CSS Exclusions and Shapes Module.
Source: W3C Working Draft — CSS Exclusions and Shapes Module.
Source: Smashing Magazine — Six CSS Layout Features To Look Forward To.
body {
display: grid;
grid-columns: 150px 1fr;
grid-rows: 50px 1fr 50px
}
Once the grid is created, we can position content (HTML5 sectioning elements) on it.
#header { grid-column: 1; grid-row: 1; }
#nav { grid-column: 1; grid-row: 3; }
#article { grid-column: 2; grid-row: 1; grid-row-span: 2; }
#aside { grid-column: 1; grid-row: 2; grid-row-align: start; }
#footer { grid-column: 2; grid-row: 2; grid-column-align: center; }