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.
<main class="main">
<header class="page-header">
<h1 class="pageTitle">Web Typography Basics</h1>
<p class="intro">This is an introduction to web typography that covers some basic concepts and shows how you might use and adapt a base typography styles. <a href="https://codepen.io/profstein/pen/gGKRGL">Click here for the styles on their own</a>.</p>
</header>
<section class="example default">
<h3>Default</h3>
<p class="section-description">This is how typography looks in your browser with no styling</p>
<section class="terminology">
<h4>Terminology</h4>
<p class="sub-head">The language of typography</p>
<p>In order to style type it's good to learn the names and definitions of typographical terms.</p>
<p class="read-more"><a href="https://www.supremo.co.uk/typeterms/">View article <span class="title">Type Terms</span> </a>
</p>
<p class="read-more"><a href="http://typedia.com/learn/only/typeface-classifications/">View article <span class="title">Typeface Classifications</span></a></p>
</section>
<section class="Hierarchy">
<h4>Hierarchy</h4>
<p class="sub-head">Organizing the importance of the content.</p>
<p>A core job of typography is to convey the text content of a page, including allowing the reader to quickly scan the page, see titles, know where sections begin and end and what content is similar an different.</p>
<p class="read-more"><a href="https://webdesign.tutsplus.com/articles/understanding-typographic-hierarchy--webdesign-11636">View article <span class="title">Understanding Typographic Hierarchy</span> </a></p>
</section>
<section class="readability">
<h4>Accessible and Readable</h4>
<p class="sub-head">Making sure everyone can read the text.</p>
<p>More than just the font, its the color, spacing and styling that determines accessibility and readability.</p>
<p class="read-more"><a href="https://webdesign.tutsplus.com/articles/designing-accessible-content-typography-font-styling-and-structure--cms-31934">View <span class="title">Designing Accessible Content</span> article</a></p>
</section>
<section class="overall">
<h4>Overall Feel</h4>
<p class="sub-head">What does the typography say about the site?</p>
<p>More than the text on the page, how you style typography creates a mood and has an impact on how people feel about your site.</p>
<p class="read-more"><a href="https://www.smashingmagazine.com/2013/08/beautiful-typography-web-design/">View article<span class="title">A Journey Through Beautiful Typography In Web Design</span> </a></p>
</section>
</section>
<section class="example reset">
<h3>Reset</h3>
<p class="section-description">This is a CSS Reset that removes all styling. The point is not to end like this but to remove browser styling so you add your own in.</p>
<section class="terminology">
<h4>Terminology</h4>
<p class="sub-head">The language of typography</p>
<p>In order to style type it's good to learn the names and definitions of typographical terms.</p>
<p class="read-more"><a href="https://www.supremo.co.uk/typeterms/">View article <span class="title">Type Terms</span> </a>
</p>
<p class="read-more"><a href="http://typedia.com/learn/only/typeface-classifications/">View article <span class="title">Typeface Classifications</span></a></p>
</section>
<section class="Hierarchy">
<h4>Hierarchy</h4>
<p class="sub-head">Organizing the importance of the content.</p>
<p>A core job of typography is to convey the text content of a page, including allowing the reader to quickly scan the page, see titles, know where sections begin and end and what content is similar an different.</p>
<p class="read-more"><a href="https://webdesign.tutsplus.com/articles/understanding-typographic-hierarchy--webdesign-11636">View article <span class="title">Understanding Typographic Hierarchy</span> </a></p>
</section>
<section class="readability">
<h4>Accessible and Readable</h4>
<p class="sub-head">Making sure everyone can read the text.</p>
<p>More than just the font, its the color, spacing and styling that determines accessibility and readability.</p>
<p class="read-more"><a href="https://webdesign.tutsplus.com/articles/designing-accessible-content-typography-font-styling-and-structure--cms-31934">View <span class="title">Designing Accessible Content</span> article</a></p>
</section>
<section class="overall">
<h4>Overall Feel</h4>
<p class="sub-head">What does the typography say about the site?</p>
<p>More than the text on the page, how you style typography creates a mood and has an impact on how people feel about your site.</p>
<p class="read-more"><a href="https://www.smashingmagazine.com/2013/08/beautiful-typography-web-design/">View article<span class="title">A Journey Through Beautiful Typography In Web Design</span> </a></p>
</section>
</section>
<section class="example base-styles">
<h3>Base CSS Styles</h3>
<p class="section-description">This is a set of base styles applied that you're free to use and modify in your projects. To get a fully designed site that fits your content, you'll need to change it.</p>
<section class="terminology">
<h4>Terminology</h4>
<p class="sub-head">The language of typography</p>
<p>In order to style type it's good to learn the names and definitions of typographical terms.</p>
<p class="read-more"><a href="https://www.supremo.co.uk/typeterms/">View article <span class="title">Type Terms</span> </a>
</p>
<p class="read-more"><a href="http://typedia.com/learn/only/typeface-classifications/">View article <span class="title">Typeface Classifications</span></a></p>
</section>
<section class="Hierarchy">
<h4>Hierarchy</h4>
<p class="sub-head">Organizing the importance of the content.</p>
<p>A core job of typography is to convey the text content of a page, including allowing the reader to quickly scan the page, see titles, know where sections begin and end and what content is similar an different.</p>
<p class="read-more"><a href="https://webdesign.tutsplus.com/articles/understanding-typographic-hierarchy--webdesign-11636">View article <span class="title">Understanding Typographic Hierarchy</span> </a></p>
</section>
<section class="readability">
<h4>Accessible and Readable</h4>
<p class="sub-head">Making sure everyone can read the text.</p>
<p>More than just the font, its the color, spacing and styling that determines accessibility and readability.</p>
<p class="read-more"><a href="https://webdesign.tutsplus.com/articles/designing-accessible-content-typography-font-styling-and-structure--cms-31934">View <span class="title">Designing Accessible Content</span> article</a></p>
</section>
<section class="overall">
<h4>Overall Feel</h4>
<p class="sub-head">What does the typography say about the site?</p>
<p>More than the text on the page, how you style typography creates a mood and has an impact on how people feel about your site.</p>
<p class="read-more"><a href="https://www.smashingmagazine.com/2013/08/beautiful-typography-web-design/">View article<span class="title">A Journey Through Beautiful Typography In Web Design</span> </a></p>
</section>
</section>
<section class="example custom">
<h3>Customized Styles</h3>
<p class="section-description">Here the base styles from the previous example have been customized to fit the content.</p>
<section class="terminology">
<h4>Terminology</h4>
<p class="sub-head">The language of typography</p>
<p>In order to style type it's good to learn the names and definitions of typographical terms.</p>
<p class="read-more"><a href="https://www.supremo.co.uk/typeterms/">View article <span class="title">Type Terms</span> </a>
</p>
<p class="read-more"><a href="http://typedia.com/learn/only/typeface-classifications/">View article <span class="title">Typeface Classifications</span></a></p>
</section>
<section class="Hierarchy">
<h4>Hierarchy</h4>
<p class="sub-head">Organizing the importance of the content.</p>
<p>A core job of typography is to convey the text content of a page, including allowing the reader to quickly scan the page, see titles, know where sections begin and end and what content is similar an different.</p>
<p class="read-more"><a href="https://webdesign.tutsplus.com/articles/understanding-typographic-hierarchy--webdesign-11636">View article <span class="title">Understanding Typographic Hierarchy</span> </a></p>
</section>
<section class="readability">
<h4>Accessible and Readable</h4>
<p class="sub-head">Making sure everyone can read the text.</p>
<p>More than just the font, its the color, spacing and styling that determines accessibility and readability.</p>
<p class="read-more"><a href="https://webdesign.tutsplus.com/articles/designing-accessible-content-typography-font-styling-and-structure--cms-31934">View <span class="title">Designing Accessible Content</span> article</a></p>
</section>
<section class="overall">
<h4>Overall Feel</h4>
<p class="sub-head">What does the typography say about the site?</p>
<p>More than the text on the page, how you style typography creates a mood and has an impact on how people feel about your site.</p>
<p class="read-more"><a href="https://www.smashingmagazine.com/2013/08/beautiful-typography-web-design/">View article<span class="title">A Journey Through Beautiful Typography In Web Design</span> </a></p>
</section>
</section>
<section class="more-resources">
<h2>More Information</h2>
<h3>Overall Web Typography Guides</h3>
<p>Yes, there are a lot of guides. Pick one, start reading. If it isn't your style, try another. Also reading a few may help reinforce ideas.</p>
<ul>
<li><a href="https://typographyhandbook.com/">Typography Handbook</a>: online reference</li>
<li><a href="https://betterwebtype.com/">Better Web Typography for a Better Web</a>: free web course</li>
<li><a href="https://prowebtype.com/">Professional Web Typography</a> (book)</li>
<li><a href="http://thinkingwithtype.com/">Thinking with Type</a> (companion site to book)</li>
<li><a href="https://material.io/design/typography/understanding-typography.html">Understanding Typography</a></li>
<li><a href="https://blog.hubspot.com/website/website-typography">The Beginner's Guide to Typography in Web Design</a></li>
<li><a href="https://elementor.com/blog/guide-to-web-typography/">Web Typography: The Complete Guide for Designers</a></li>
<li><a href="http://webtypography.net/">Elements of Typographic Style Applied to the Web</a></li>
</ul>
<h3>Examples</h3>
<ul>
<li><a href="https://www.typewolf.com">Typewolf</a> (information, inspiration and more): </li>
<li><a href="https://gist.github.com/profstein/58123c5ff7df899117737072061daeb4">Gist with just the basic typography from this page</a>.</li>
<li><a href="https://ilovetypography.com/">I Love Typography</a></li>
<li><a href="https://fontsinuse.com/">Fonts in Use</a></li>
<li><a href="https://www.hongkiat.com/blog/showcase-web-design-beautiful-typography/">Showcase of Web Designs with Beautiful Typography</a></li>
</ul>
<h3>Tools</h3>
<ul>
<li><a href="https://www.gridlover.net/">Gridlover</a>: helps to choose font sizes and line spacing.</li>
<li>Check color contrast: WebAIM's <a href="https://webaim.org/resources/contrastchecker/">Contrast Checker</a> and Lea Verou's <a href="https://contrast-ratio.com/">Contrast Ratio</a></li>
<li><a href="https://chrome.google.com/webstore/detail/typography-inspector/mbbnlbimlnfachlfnjnolpehiimhbjjm">Typography Inspector</a>: chrome extension</li>
</ul>
<h3>Articles</h3>
<ul>
<li><a href="https://www.editorx.com/shaping-design/article/web-typography-rules">The Rules of Web Typography</a></li>
<li><a href="https://practicaltypography.com/typography-in-ten-minutes.html">Typography in ten minutes</a></li>
<li><a href="https://careerfoundry.com/en/blog/ui-design/beginners-guide-to-typography/">What Is Typography, And Why Is It Important? A Beginner’s Guide</a></li>
<li><a href="https://rwt.io/typography-tips">Typography Tips</a></li>
<li><a href="https://www.toptal.com/designers/typography/web-typography-infographic">Designing for Readability – A Guide to Web Typography (with Infographic)</a></li>
<li><a href="https://ux.christmas/2020/7">Digital typography and accessibility</a></li>
<li><a href="https://techstacker.com/readability-vs-legibility-typography/">Readability vs. Legibility in Typography — what’s the difference?</a></li>
<li><a href="https://medium.com/the-readability-group/a-guide-to-understanding-what-makes-a-typeface-accessible-and-how-to-make-informed-decisions-9e5c0b9040a0">A Guide to Understanding What Makes a Typeface Accessible</a></li>
<li><a href="https://material.io/design/usability/accessibility.html#hierarchy">Web page Hierarchy from Material.io</a></li>
<li><a href="https://www.hongkiat.com/blog/typography-for-modern-websites/">A Look Into: Better Typography For Modern Websites</a></li>
<li><a href="https://levelup.gitconnected.com/improve-your-web-typography-with-a-few-solid-tips-ccdea4477d00">Improve your web typography with a few solid tips</a>
</li>
<li><a href="https://www.smashingmagazine.com/2009/03/10-principles-for-readable-web-typography/">10 Principles Of Readability And Web Typography</a></li>
</ul>
</section>
</main>
/* Optional, include a web font */
@import url('https://fonts.googleapis.com/css2?family=Antonio:wght@100;600&family=EB+Garamond:ital,wght@0,400;0,700;1,400;1,700&display=swap');
/* ====================
RESET STYLES
==================== */
.reset *{
padding:0;
margin: 0;
font-weight: 400;
font-size: 16px;
}
/* ====================
BASE CSS STYLES
==================== */
.base-styles, .custom{
// base font styles
font-size: 1rem;
font-family: 'EB Garamond', serif;
font-weight: 400;
line-height: 1.5;
color: #333;
p, li {
margin-top: 0;
margin-bottom: 1em;
}
/* A link that has not been visited */
a:link {
color: #000080;
text-decoration: none;
border-bottom: 1px solid #000080;
}
/* A link that has been visited */
a:visited {
color: #800080;
border-bottom: 1px dashed #800080;
}
/* A link that is hovered on */
a:hover {
color: red;
border-bottom: 1px solid red;
}
/* A link that is selected */
a:active {
color: green;
border-bottom: 1px solid green;
}
/* Base Styling for headings */
h1, h2, h3, h4, h5, h6 {
font-weight: 600;
font-family: 'Antonio', sans-serif;
}
/* For each of your headings at minimum set the margin, size, line-height. Adjust font-weight and other properties as needed. */
h1 {
font-size: 5.063em;
line-height: 1;
margin: 0 0 0.5em 0;
}
h2 {
font-size: 3.375em;
line-height: 1.2;
margin: 1.5em 0 0.5em 0;
}
h3 {
font-weight: 100;
font-size: 2.25em;
line-height: 1;
margin: 1.5em 0 0.25em 0;
}
h4 {
font-size: 1.5em;
line-height: 1;
margin: 1.5em 0 0.5em 0;
}
h5 {
font-size: 1em;
line-height: 1;
margin: 1.5em 0 0.5em 0;
}
h6 {
font-size: 1em;
line-height: 1.5;
margin: 1em 0 0 0;
font-weight: 400; /* normal */
text-transform: uppercase;
}
}
/* ====================
CUSTOMIZED
==================== */
// Note, all of the base styles have also been applied above. This modifies them to fit the content
.custom{
h4{
margin-top: 2.5rem;
}
p{font-size:1.2rem;}
.title{
font-style:italic;
}
.sub-head{
font-style:italic;
color:#666;
margin-top:-.5rem;
}
.read-more{
/* A link that has not been visited */
text-align: center;
padding:10px;
border: 1px solid #000080;
a{
border-bottom:none;
text-decoration: none;
}
/* A link that has not been visited */
a:link {
color: #000080;
}
/* A link that has been visited */
a:visited {
color:#000080;
}
/* A link that is hovered on */
a:hover {
color: red;
}
/* A link that is selected */
a:active {
color: red;
}
}
}
/* ====================
LAYOUT
==================== */
.main{
display:grid;
grid-gap: 1.5rem;
grid-template-columns: 1fr;
padding:.725rem;
}
.page-header{
grid-column: 1/-1;
max-width:50rem;
}
.example{
// display: flex;
// flex-direction: column;
// justify-content: flex-end;
border-bottom: 1px solid #666;
margin-bottom: 1rem;
}
.example .section-description{
flex-grow:1;
}
@media (min-width: 640px){
.main{
grid-template-columns: 1fr 1fr;
}
.example{
border-right: 1px solid #666;
padding-right:1rem;
}
.more-resources{
grid-column:1/3;
}
}
@media (min-width: 1000px){
.main{
grid-template-columns: 1fr 1fr 1fr 1fr;
}
.more-resources{
grid-column:2/4;
}
}
/* ====================
STYLING FOR HEADER AND MORE RESOURCES SECTIONS
==================== */
.page-header{
font-size: 2rem;
font-family: 'EB Garamond', serif;
font-weight: 400;
line-height: 1.5;
}
.more-resources{
font-size: 1rem;
font-family: 'EB Garamond', serif;
font-weight: 400;
line-height: 1.5;
h2{
font-size: 2rem;
}
h3{
font-size: 1.5rem;
margin-bottom: 5px;
}
ul{
margin-top: 5px;
li{
margin-bottom: 1rem;
}
}
}
Also see: Tab Triggers