HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<article role="article">
<h1>Introduction to web typography</h1>
<p class="character-count">Web typography refers to the use of fonts on the World Wide Web. When HTML was first created, font faces and styles were controlled exclusively by the settings of each Web browser. There was no mechanism for individual Web pages to control font display until Netscape introduced the <code><font></code> tag in 1995, which was then standardized in the HTML 2 specification. However, the font specified by the tag had to be installed on the user's computer or a fallback font, such as a browser's default sans-serif or monospace font, would be used. The first <i>Cascading Style Sheets</i> specification was published in <b>1996</b> and provided the same capabilities.</p>
<p>The CSS2 specification was released in 1998 and attempted to improve the font selection process by adding font matching, synthesis and download. These techniques did not gain much use, and were removed in the CSS2.1 specification. However, Internet Explorer added support for the font downloading feature in version 4.0, released in 1997.<sup>1</sup> Font downloading was later included in the CSS3 fonts module, and has since been implemented in Safari 3.1, Opera 10 and Mozilla Firefox 3.5. This has subsequently increased interest in Web typography, as well as the usage of font downloading.</p>
<h2>CSS1</h2>
<p>In the first CSS specification,<sup>2</sup> authors specified font characteristics via a series of properties:</p>
<ul>
<li>font-family</li>
<li>font-style</li>
<li>font-variant</li>
<li>font-weight</li>
<li>font-size</li>
</ul>
<p>All fonts were identified solely by name. Beyond the properties mentioned above, designers had no way to style fonts, and no mechanism existed to select fonts not present on the client system.</p>
<h3>Web-safe fonts</h3>
<p class="character-count">Web-safe fonts are fonts likely to be present on a wide range of computer systems, and used by Web content authors to increase the likelihood that content displays in their chosen font. If a visitor to a Web site does not have the specified font, their browser tries to select a similar alternative, based on the author-specified fallback fonts and generic families or it uses font substitution defined in the visitor's operating system.</p>
<h3>Microsoft’s Core fonts for the Web</h3>
<p>To ensure that all Web users had a basic set of fonts, Microsoft started the Core fonts for the Web initiative in 1996 (terminated in 2002). Released fonts include Arial, Courier New, Times New Roman, Comic Sans, Impact, Georgia, Trebuchet, Webdings and Verdana—under an EULA that made them freely distributable but also limited some usage rights. Their high penetration rate has made them a staple for Web designers. However, most linux distributions don't include these fonts by default.</p>
<p>CSS2 attempted to increase the tools available to Web developers by adding font synthesis, improved font matching and the ability to download remote fonts.<sup>3</sup></p>
<p>Some CSS2 font properties were removed from CSS2.1 and later included in CSS3.<sup>4</sup> <sup>5</sup></p>
<h3>Fallback fonts</h3>
<p>The CSS specification allows for multiple fonts to be listed as fallback fonts.<sup>6</sup> In CSS, the font-family property accepts a list of comma-separated font faces to use, like so:</p>
<p><code>font-family: Helvetica, "Nimbus Sans L", "Liberation Sans", Arial, sans-serif;</code></p>
<p>The first font specified is the preferred font. If this font is not available, the Web browser attempts to use the next font in the list. If none of the fonts specified are found, the browser displays its default font. This same process also happens on a per-character basis if the browser tries to display a character not present in the specified font.</p>
<h3>Generic font families</h3>
<p>To give Web designers some control over the appearance of fonts on their Web pages, even when the specified fonts are not available, the CSS specification allows the use of several generic font families. These families are designed to split fonts into several categories based on their general appearance. They are commonly specified as the last in a series of fallback fonts, as a last resort in the event that none of the fonts specified by the author are available. There are five generic families:<sup>6</sup></p>
<dl>
<dt>Sans-serif</dt>
<dd>Fonts that do not have decorative markings, or serifs, on their letters. These fonts are often considered easier to read on screens.<sup>7</sup></dd>
<dt>Serif</dt>
<dd>Fonts that have decorative markings, or serifs, present on their characters.</dd>
<dt>Monospace</dt>
<dd>Fonts in which all characters are equally wide.</dd>
<dt>Cursive</dt>
<dd>Fonts that resemble cursive writing. These fonts may have a decorative appearance, but they can be difficult to read at small sizes, so they are generally used sparingly.</dd>
<dt>Fantasy</dt>
<dd>Fonts that may contain symbols or other decorative properties, but still represent the specified character.</dd>
</dl>
<h2>Web fonts</h2>
<h3>History</h3>
<p>A technique to download remote fonts was first specified in the CSS2 specification, which introduced the <a href="http://css-tricks.com/snippets/css/using-font-face/" target="_blank"><code>@font-face</code></a> rule.</p>
<p>It was (and remains<sup>8</sup>) controversial because using a remote font as part of a Web page allows the font to be freely downloaded. This could result in fonts being used against the terms of their license or illegally spread through the Web. TrueDoc (PFR), Embedded OpenType (EOT) and Web Open Font Format (WOFF) are formats designed to address these issues.</p>
<p>Since the introduction of Internet Explorer 4, font embedding employing EOT has been used mainly for displaying characters in writing systems that are not supported by default fonts. Use on English-language Web sites was virtually non-existent. With the releases of Firefox 3.5, Opera 10 and Safari 3.1, usage employing other formats is expected to increase.</p>
<h3>File formats</h3>
<p>By using a specific CSS @font-face embedding technique<sup>9</sup> it is possible to embed fonts such that they work with IE4+, Firefox 3.5+, Safari 3.1+, Opera 10+ and Chrome 4.0+. This allows the vast majority of Web users to access this functionality. Some commercial foundries object to the redistribution of their fonts. For example, Hoefler & Frere-Jones says that, while they “…enthusiastically [support] the emergence of a more expressive Web in which designers can safely and reliably use high-quality fonts online,” the current delivery of fonts using @font-face is considered “illegal distribution” by the foundry and is not permitted.<sup>10</sup></p>
<p>Naturally this does not interfere with fonts and foundries under free licenses.</p>
<h4>TrueDoc</h4>
<a href="http://www.monotype.com/libraries/bitstream" target="_blank">Bitstream</a> developed TrueDoc, the first standard for embedding fonts. TrueDoc was natively supported in Netscape Navigator 4, but was discontinued in Netscape Navigator 6 and Mozilla, because Netscape could not release Bitstream's source code. A WebFont Player plugin was available for Internet Explorer, but the technology had to compete against Microsoft's Embedded OpenType fonts, natively supported since version 4.0.
<h4>Embedded OpenType</h4>
<p>Internet Explorer has supported font embedding through the proprietary Embedded OpenType standard since version 4.0. It uses digital rights management techniques to help prevent fonts from being copied and used without a license. A simplified subset of EOT has been formalized under the name of CWT Compatibility Web Type, formerly EOT-Lite<sup>11</sup></p>
<h4>Scalable Vector Graphics</h4>
<p>Web typography applies to SVG in two ways:</p>
<ol>
<li>All versions of the SVG 1.1 specification, including the SVGT subset, define a font module allowing the creation of fonts within an SVG document. Safari introduced support for many of these properties in version 3. Opera added preliminary support in version 8.0, with support for more properties in 9.0.</li>
<li>The SVG specification lets CSS apply to SVG documents in a similar manner to HTML documents, and the @font-face rule can be applied to text in SVG documents. Opera added support for this in version 10 <sup>12</sup>, and WebKit since version 325 also supports this method using SVG fonts only.</li>
</ol>
<h4>TrueType/OpenType</h4>
<p>Linking to industry-standard TrueType (TTF) and OpenType (TTF/OTF) fonts are supported by Mozilla Firefox 3.5+, Opera 10+,<sup>13</sup> Safari 3.1+,<sup>14</sup> Google Chrome 4.0+.<sup>15</sup> Internet Explorer 9+ supports only those fonts with embedding permissions set to installable.</p>
<h4>Web Open Font Format</h4>
<p>WOFF has been supported by Mozilla Firefox 3.6+, Google Chrome 5+, Opera Presto, and is supported by Internet Explorer 9 (since March 14, 2011). Support is available on Mac OS X Lion's Safari from release 5.1.</p>
<h4>An example of a CSS @font-face setup:</h4>
<p><code>@font-face {<br>
font-family: 'Journal'; src:url('http://your-own.site/fonts/journal/journal.woff') format('woff'),<br>
url('http://your-own.site/fonts/journal/journal.svg#Journal') format('svg'),<br>
url('http://your-own.site/fonts/journal/journal.ttf') format('truetype'),<br>
url('http://your-own.site/fonts/journal/journal.eot'),<br>
url('http://your-own.site/fonts/journal/journal.eot?#iefix') format('embedded-opentype');<br>
font-weight: normal;<br>
font-style: normal;<br>
}<br>
</code></p>
<footer>
<h2>References</h2>
<ol>
<li>
<cite>Garaffa, Dave (2 September 1997). <a rel="nofollow" href="http://web.archive.org/web/19980708194539/browserwatch.internet.com/news/story/microsoft265.html">"Embedded Fonts In Microsoft IE4pr2"</a>. <a href="/wiki/Internet.com" title="Internet.com" >Internet.com</a>. Archived from <a rel="nofollow" href="http://browserwatch.internet.com/news/story/microsoft265.html">the original</a> on 8 July 1998.</cite>
</li>
<li><cite><a rel="nofollow" href="http://www.w3.org/TR/CSS1/"><i>Cascading Style Sheets, level 1</i></a>, W3C, 1996-12-17</cite></li>
<li><cite><a rel="nofollow" href="http://www.w3.org/TR/2008/REC-CSS2-20080411/fonts.html">"Fonts"</a>, <i>Cascading Style Sheets, level 2:CSS2 Specification</i> (<a href="/wiki/World_Wide_Web_Consortium" title="World Wide Web Consortium">World Wide Web Consortium</a>), 1998-05-12, retrieved 2009-07-28</cite></li>
<li><cite><a rel="nofollow" href="http://www.w3.org/TR/CSS21/changes.html#q104"><i>CSS2.1 Changes —C.2.97 Chapter 15 Fonts</i></a>, <a href="/wiki/World_Wide_Web_Consortium" title="World Wide Web Consortium">World Wide Web Consortium</a>, retrieved 2010-01-30</cite></li>
<li><cite><a rel="nofollow" href="http://www.w3.org/TR/css3-webfonts"><i>CSS3 module: Web Fonts</i></a>, <a href="/wiki/World_Wide_Web_Consortium" title="World Wide Web Consortium">World Wide Web Consortium</a>, retrieved 2010-01-30</cite></li>
<li><cite><a rel="nofollow" href="http://www.w3.org/TR/CSS2/fonts.html">"CSS2 specification"</a>, <i>Fonts</i> (<a href="/wiki/World_Wide_Web_Consortium" title="World Wide Web Consortium">World Wide Web Consortium</a>)</cite></li>
<li><cite>Poole, Alex (2005-04-07), <a rel="nofollow" href="http://www.alexpoole.info/academic/literaturereview.html"><i>Which Are More Legible: Serif or Sans Serif Typefaces?</i></a>, retrieved 2010-01-30</cite></li>
<li><cite>Hill, Bill (2008-07-21), <a rel="nofollow" href="http://blogs.msdn.com/ie/archive/2008/07/21/font-embedding-on-the-web.aspx"><i>Font Embedding on the Web</i></a>, Microsoft</cite></li>
<li><cite>Kimler, Scott Thomas (2009-07-04), <a rel="nofollow" href="http://randsco.com/index.php/2009/07/04/cross_browser_font_embedding"><i>xBrowser Fonts — Expand Your Font Palette Using CSS3</i></a>, retrieved 2010-02-05</cite></li>
<li><cite>Wubben, Mark (February 27, 2009). <a rel="nofollow" class="external text" href="http://www.slideshare.net/novemberborn/geek-meet-web-typography-and-sifr-3#15">"Geek Meet: Web Typography and sIFR 3 - Slide 15 and 16"</a>. <a href="/wiki/SlideShare" title="SlideShare">SlideShare</a><span class="reference-accessdate">. Retrieved <span class="nowrap">17 March</span> 2010</span>.</cite></li>
<li><cite>Daggett, John (2009-07-31), <a rel="nofollow" href="http://lists.w3.org/Archives/Public/www-font/2009JulSep/0969.html"><i>EOT-Lite File Format v.1.1</i></a>, <a href="/wiki/World_Wide_Web_Consortium" title="World Wide Web Consortium">World Wide Web Consortium</a>, retrieved 2010-01-30</cite></li>
<li><cite>Mills, Chris (2008-12-04), <a rel="nofollow" href="http://dev.opera.com/articles/view/presto-2-2-and-opera-10-a-first-look/#webfontssvg"><i>Opera Presto 2.2 and Opera 10 — a first look</i></a>, <a href="/wiki/Opera_Software" title="Opera Software">Opera Software</a>, retrieved 2010-01-30</cite></li>
<li><cite>Mills, Chris (2008-12-04), <a rel="nofollow" href="http://www.opera.com/docs/specs/presto22/#css"><i>Opera Presto 2.2 and Opera 10 — a first look</i></a>, Opera Developer Community, retrieved 2010-01-29</cite></li>
<li><cite>Marsal, Katie (2008-02-07), <a rel="nofollow" href="http://www.appleinsider.com/articles/08/02/07/apples_safari_3_1_to_support_downloadable_web_fonts_more.html"><i>Apple's Safari 3.1 to support downloadable web fonts, more</i></a>, <a href="/wiki/AppleInsider" title="AppleInsider">AppleInsider</a>, retrieved 2010-02-05</cite></li>
<li><cite>Irish, Paul (2010-01-25), <a rel="nofollow" href="http://paulirish.com/2009/chrome-and-font-face-a-summary/"><i>Chrome and @font-face: It's here!</i></a></cite></li>
</ol>
</footer>
<div id="element"><span id="w2"></span>px<span id="h2"></span></div>
</article>
/* THIS IS WHERE YOU WILL MAKE YOUR CHANGES */
html {
}
@media screen and (min-width: 600px) {
html {
}
}
body {
}
i, em {
}
b, strong {
}
a {
}
a:hover {
}
code {
}
h1 {
}
h1 + p {
}
h2 {
}
h2 + p {
}
h3 {
}
h3 + p {
}
h4 {
}
h4 + p {
}
h5 {
}
h5 + p {
}
h6 {
}
h6 + p {
}
sup, sub {
}
ul {
}
ul li {
}
ol {
}
ol li {
}
p + ul, p + ol {
}
dt {
}
dd {
}
/* STOP!!!!!!! DO NOT DELETE OR CHANGE ANYTHING BELOW THIS LINE!!!!!!! */
body {
background-color: #fff;
box-sizing: border-box;
margin: 20px auto;
max-width: 1280px;
padding: 0 20px;
width: 100%;
}
#element {
background-color: rgba(194, 240, 177, 0.5);
color: #262626;
font-family: 'Courier New', Courier, monospace;
padding: 3px 5px 2px 5px;
position: fixed;
max-width: calc(1280px - 40px);
top: 0;
width: 100%;
z-index: 1000;
}
#h2 {
display: none;
}
.highlight {
background-color: rgba(194, 240, 177, 0.35);
}
function getViewPort(){
$w2 = document.getElementById('w2');
$h2 = document.getElementById('h2');
viewPortHeight = document.documentElement.clientHeight;
viewPortWidth = document.documentElement.clientWidth;
elementHeight = document.getElementById('element').clientHeight;
elementtWidth = document.getElementById('element').clientWidth;
$w2.innerHTML = elementtWidth;
$h2.innerHTML = elementHeight;
window.onresize = function(event) {
elementHeight = document.getElementById('element').clientHeight;
elementtWidth = document.getElementById('element').clientWidth;
viewPortHeight = document.documentElement.clientHeight;
viewPortWidth = document.documentElement.clientWidth;
$w2.innerHTML = elementtWidth;
$h2.innerHTML = elementHeight;
};
}getViewPort();
(function() {
var eles = document.getElementsByClassName("character-count");
for (var i = 0; i < eles.length; i++) {
highlight(eles[i]);
}
})();
function highlight(ele) {
var str= ele.innerHTML;
var str1 = "";
for(var i = 45; i < 75; i++) {
str1 += str[i];
}
var n=str.replace(str1,'<span class="highlight">' + str1 + '</span>');
ele.innerHTML=n;
}
function togglehighlight() {
if (!document.body.classList.contains('highlight-off'))
document.body.classList.add('highlight-off');
else
document.body.classList.remove('highlight-off');
}
document.getElementById("toggle").addEventListener("click", togglehighlight);
Also see: Tab Triggers