{"id":761,"date":"2020-01-04T18:40:06","date_gmt":"2020-01-04T23:40:06","guid":{"rendered":"http:\/\/newmediaproduction.mynmi.net\/?page_id=761"},"modified":"2025-05-20T19:12:50","modified_gmt":"2025-05-20T19:12:50","slug":"fonts","status":"publish","type":"page","link":"https:\/\/nmi.cool\/webdev\/fonts\/","title":{"rendered":"Fonts"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"2560\" height=\"1707\" src=\"https:\/\/nmi.cool\/newmediaproduction\/wp-content\/uploads\/sites\/14\/2020\/09\/tim-mossholder-GOMhuCj-O9w-unsplash-scaled-1.jpg\" alt=\"\" class=\"wp-image-2384\" srcset=\"https:\/\/nmi.cool\/webdev\/wp-content\/uploads\/sites\/14\/2020\/09\/tim-mossholder-GOMhuCj-O9w-unsplash-scaled-1.jpg 2560w, https:\/\/nmi.cool\/webdev\/wp-content\/uploads\/sites\/14\/2020\/09\/tim-mossholder-GOMhuCj-O9w-unsplash-scaled-1-300x200.jpg 300w, https:\/\/nmi.cool\/webdev\/wp-content\/uploads\/sites\/14\/2020\/09\/tim-mossholder-GOMhuCj-O9w-unsplash-scaled-1-1024x683.jpg 1024w, https:\/\/nmi.cool\/webdev\/wp-content\/uploads\/sites\/14\/2020\/09\/tim-mossholder-GOMhuCj-O9w-unsplash-scaled-1-768x512.jpg 768w, https:\/\/nmi.cool\/webdev\/wp-content\/uploads\/sites\/14\/2020\/09\/tim-mossholder-GOMhuCj-O9w-unsplash-scaled-1-1536x1024.jpg 1536w, https:\/\/nmi.cool\/webdev\/wp-content\/uploads\/sites\/14\/2020\/09\/tim-mossholder-GOMhuCj-O9w-unsplash-scaled-1-2048x1366.jpg 2048w\" sizes=\"auto, (max-width: 2560px) 100vw, 2560px\" \/><figcaption class=\"wp-element-caption\">Photo by&nbsp;<a href=\"https:\/\/unsplash.com\/@timmossholder?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText\">Tim Mossholder<\/a>.<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>1. Font-family property<\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>body {font-family: Arial, Verdana, sans-serif;}<\/code><\/pre>\n\n\n\n<p>When you type in font-family in your CSS, you\u2019ll see a variety of different fonts at your disposal. To display these fonts on your website, users looking at your site will need to have these fonts installed on their computers. If the user doesn\u2019t have the first font listed (in the example above, Arial) installed, the browser will try to display the next font, then the next, and so on. If you\u2019re wondering, sans-serif and serif refer to two very broad categories of fonts\u2014read this <a href=\"https:\/\/www.impactbnd.com\/blog\/sans-serif-vs-serif-font-which-should-you-use-when\">article<\/a> to learn more.<\/p>\n\n\n\n<p>Note: If a font is more than one word, it must be placed in double quotes, ie, \u201cTimes New Roman.\u201d<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"google-fonts\">2. Google Fonts&nbsp;<\/h2>\n\n\n\n<p>Google Fonts can easily be imported to your website. To use Google Fonts you&#8217;ll add a special stylesheet link in the <code>&lt;head&gt;<\/code> of your HTML document.&nbsp;<\/p>\n\n\n\n<p>An important aspect of this class is learning how to help yourself\u2014there are tons of free, online resources to help with web development. In this case, <a href=\"https:\/\/developers.google.com\/fonts\/docs\/getting_started\">Google\u2019s instructions<\/a> are better than any I can devise, or you can do <strong>the Free Code Camp homework dedicated to Google Fonts, too (Responsive Web Design &gt; Basic CSS &gt; Import a Google Font). <\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Test it out! <\/h3>\n\n\n\n<p>Go ahead and test this out in Visual Studio Code. First, you&#8217;ll need to create a test HTML file&#8211; you can call it <code>fonts.html<\/code> if you like! Save it to your playground folder. Generate your HTML boilerplate. Next, you&#8217;ll want to create a blank CSS document named <code>fonts.css<\/code> and save it in a the <code>css<\/code> folder in playground. Make sure to <a href=\"https:\/\/nmi.cool\/webdev\/linking-to-an-external-stylesheet\/\" target=\"_blank\" rel=\"noreferrer noopener\">link your external stylesheet<\/a> in the &lt;head&gt; of your HTML document. Okay, now we are ready to go!<\/p>\n\n\n\n<p>Open <a href=\"https:\/\/fonts.google.com\" target=\"_blank\" rel=\"noreferrer noopener\">Google Fonts<\/a> in a web browser. Spend a couple of minutes browsing the font options and click on one you like. Click on a font that you like. It will open to a page that looks like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"567\" src=\"https:\/\/nmi.cool\/webdev\/wp-content\/uploads\/sites\/14\/2025\/05\/Screenshot-2025-05-20-at-3.00.37\u202fPM-1024x567.png\" alt=\"\" class=\"wp-image-6137\" srcset=\"https:\/\/nmi.cool\/webdev\/wp-content\/uploads\/sites\/14\/2025\/05\/Screenshot-2025-05-20-at-3.00.37\u202fPM-1024x567.png 1024w, https:\/\/nmi.cool\/webdev\/wp-content\/uploads\/sites\/14\/2025\/05\/Screenshot-2025-05-20-at-3.00.37\u202fPM-300x166.png 300w, https:\/\/nmi.cool\/webdev\/wp-content\/uploads\/sites\/14\/2025\/05\/Screenshot-2025-05-20-at-3.00.37\u202fPM-768x425.png 768w, https:\/\/nmi.cool\/webdev\/wp-content\/uploads\/sites\/14\/2025\/05\/Screenshot-2025-05-20-at-3.00.37\u202fPM-1536x851.png 1536w, https:\/\/nmi.cool\/webdev\/wp-content\/uploads\/sites\/14\/2025\/05\/Screenshot-2025-05-20-at-3.00.37\u202fPM-2048x1134.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Now it&#8217;s time to go shopping (with Google bucks). Click &#8220;Get Font&#8221; in the top right corner. That will add the font to your bag and give you some options. <\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"309\" src=\"https:\/\/nmi.cool\/webdev\/wp-content\/uploads\/sites\/14\/2025\/05\/Screenshot-2025-05-20-at-3.01.58\u202fPM-1024x309.png\" alt=\"\" class=\"wp-image-6138\" srcset=\"https:\/\/nmi.cool\/webdev\/wp-content\/uploads\/sites\/14\/2025\/05\/Screenshot-2025-05-20-at-3.01.58\u202fPM-1024x309.png 1024w, https:\/\/nmi.cool\/webdev\/wp-content\/uploads\/sites\/14\/2025\/05\/Screenshot-2025-05-20-at-3.01.58\u202fPM-300x90.png 300w, https:\/\/nmi.cool\/webdev\/wp-content\/uploads\/sites\/14\/2025\/05\/Screenshot-2025-05-20-at-3.01.58\u202fPM-768x232.png 768w, https:\/\/nmi.cool\/webdev\/wp-content\/uploads\/sites\/14\/2025\/05\/Screenshot-2025-05-20-at-3.01.58\u202fPM-1536x463.png 1536w, https:\/\/nmi.cool\/webdev\/wp-content\/uploads\/sites\/14\/2025\/05\/Screenshot-2025-05-20-at-3.01.58\u202fPM-2048x618.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Click &#8220;Get embed code,&#8221; and brace yourself. <\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"633\" src=\"https:\/\/nmi.cool\/webdev\/wp-content\/uploads\/sites\/14\/2025\/05\/Screenshot-2025-05-20-at-3.03.29\u202fPM-1024x633.png\" alt=\"\" class=\"wp-image-6139\" srcset=\"https:\/\/nmi.cool\/webdev\/wp-content\/uploads\/sites\/14\/2025\/05\/Screenshot-2025-05-20-at-3.03.29\u202fPM-1024x633.png 1024w, https:\/\/nmi.cool\/webdev\/wp-content\/uploads\/sites\/14\/2025\/05\/Screenshot-2025-05-20-at-3.03.29\u202fPM-300x186.png 300w, https:\/\/nmi.cool\/webdev\/wp-content\/uploads\/sites\/14\/2025\/05\/Screenshot-2025-05-20-at-3.03.29\u202fPM-768x475.png 768w, https:\/\/nmi.cool\/webdev\/wp-content\/uploads\/sites\/14\/2025\/05\/Screenshot-2025-05-20-at-3.03.29\u202fPM-1536x950.png 1536w, https:\/\/nmi.cool\/webdev\/wp-content\/uploads\/sites\/14\/2025\/05\/Screenshot-2025-05-20-at-3.03.29\u202fPM-2048x1267.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Make sure the &#8220;&lt;link&gt;&#8221; option is toggled rather than the &#8220;@import&#8221; option (this should occur automatically). <\/p>\n\n\n\n<p>Copy everything from the &#8220;Embed code in the &lt;head&gt; of your html&#8221; box and paste it &#8230; into the &lt;head&gt; of your html. Mine looks like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html lang=\"en\"&gt;\n&lt;head&gt;\n    &lt;meta charset=\"UTF-8\"&gt;\n    &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"&gt;\n    &lt;title&gt;Document&lt;\/title&gt;\n\n    <strong>&lt;link rel=\"preconnect\" href=\"https:\/\/fonts.googleapis.com\"&gt;\n&lt;link rel=\"preconnect\" href=\"https:\/\/fonts.gstatic.com\" crossorigin&gt;\n&lt;link href=\"https:\/\/fonts.googleapis.com\/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&amp;display=swap\" rel=\"stylesheet\"&gt;<\/strong>\n\n&lt;link href=\"css\/fonts.css\" rel=\"stylesheet\"&gt;\n\n&lt;\/head&gt;\n&lt;body&gt;\n\n    &lt;h1&gt;Let's test out some fonts&lt;\/h1&gt;&gt;\n    \n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<p>You&#8217;ll want to add a little content to this webpage so we can apply the font. Go ahead and add a heading or two, a paragraph&#8211; whatever you like. <\/p>\n\n\n\n<p>Now that you&#8217;ve got a little content, pick an element that you&#8217;d like to apply the font to\u2014maybe a paragraph or heading. In your style sheet, add a selector.<\/p>\n\n\n\n<p>Next, copy and paste the CSS rule from Google Fonts (the part highlighted in blue) into your stylesheet.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"695\" src=\"https:\/\/nmi.cool\/webdev\/wp-content\/uploads\/sites\/14\/2025\/05\/Screenshot-2025-05-20-at-3.09.11\u202fPM-1024x695.png\" alt=\"\" class=\"wp-image-6142\" srcset=\"https:\/\/nmi.cool\/webdev\/wp-content\/uploads\/sites\/14\/2025\/05\/Screenshot-2025-05-20-at-3.09.11\u202fPM-1024x695.png 1024w, https:\/\/nmi.cool\/webdev\/wp-content\/uploads\/sites\/14\/2025\/05\/Screenshot-2025-05-20-at-3.09.11\u202fPM-300x204.png 300w, https:\/\/nmi.cool\/webdev\/wp-content\/uploads\/sites\/14\/2025\/05\/Screenshot-2025-05-20-at-3.09.11\u202fPM-768x521.png 768w, https:\/\/nmi.cool\/webdev\/wp-content\/uploads\/sites\/14\/2025\/05\/Screenshot-2025-05-20-at-3.09.11\u202fPM-1536x1043.png 1536w, https:\/\/nmi.cool\/webdev\/wp-content\/uploads\/sites\/14\/2025\/05\/Screenshot-2025-05-20-at-3.09.11\u202fPM.png 1874w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Your stylesheet should look something like this: <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>h1 {\n     font-family: \"Montserrat\", sans-serif;\n   }<\/code><\/pre>\n\n\n\n<p>That&#8217;s it! Save both your HTML and CSS files and give the HTML file a preview in Chrome. You should see the font on your screen. <\/p>\n\n\n\n<p>Feel free to practice some of your CSS skills and have a little fun here: maybe add a <a href=\"https:\/\/nmi.cool\/webdev\/intro-css\/#color\" target=\"_blank\" rel=\"noreferrer noopener\">color<\/a>, change the font-size, or test out some of the <a href=\"https:\/\/developers.google.com\/fonts\/docs\/getting_started#enabling_font_effects_beta\" target=\"_blank\" rel=\"noreferrer noopener\">Google Font Effects<\/a>.<a href=\"#footnote-1-761\" id=\"note-1-761\" rel=\"footnote\">1<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Selecting fonts<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Less is more: typically, designers stick to <strong>three fonts<\/strong>. <\/li>\n\n\n\n<li>Look at free resources for font pairings, such as <a aria-label=\"fontpair.co (opens in a new tab)\" href=\"https:\/\/fontpair.co\/\" target=\"_blank\" rel=\"noreferrer noopener\">fontpair.co<\/a> and <a aria-label=\"fontjoy.com (opens in a new tab)\" href=\"https:\/\/fontjoy.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">fontjoy.com<\/a>. Try to not pick fonts randomly; every design choice should serve a purpose. Comic sans is not an appropriate font for a small business site, for instance. <\/li>\n\n\n\n<li>When it comes to picking font sizes, pay attention to the <a aria-label=\"typographic scale (opens in a new tab)\" href=\"http:\/\/spencermortensen.com\/articles\/typographic-scale\/\" target=\"_blank\" rel=\"noreferrer noopener\">typographic scale<\/a>\u2014the size of fonts and how they work in relation to each other. Check out typographic scales like <a aria-label=\"type-scale.com (opens in a new tab)\" href=\"https:\/\/type-scale.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">type-scale.com<\/a>.<\/li>\n<\/ul>\n<div class=\"footnotes\"><hr \/><ol><li id=\"footnote-1-761\" class=\"footnote\"><p> Go easy with these, they are fun but a little&#8230; intense and could make it hard to read your text if you aren&#8217;t careful<a href=\"#note-1-761\" class=\"footnote-return\">&#8617;<\/a><\/p><\/li><!--\/#footnote-1.footnote--><\/ol><\/div><!--\/#footnotes-->","protected":false},"excerpt":{"rendered":"<p>1. Font-family property When you type in font-family in your CSS, you\u2019ll see a variety of different fonts at your disposal. To display these fonts on your website, users looking at your site will need to have these fonts installed on their computers. If the user doesn\u2019t have the first font listed (in the example [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-761","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/nmi.cool\/webdev\/wp-json\/wp\/v2\/pages\/761","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nmi.cool\/webdev\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/nmi.cool\/webdev\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/nmi.cool\/webdev\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nmi.cool\/webdev\/wp-json\/wp\/v2\/comments?post=761"}],"version-history":[{"count":4,"href":"https:\/\/nmi.cool\/webdev\/wp-json\/wp\/v2\/pages\/761\/revisions"}],"predecessor-version":[{"id":6144,"href":"https:\/\/nmi.cool\/webdev\/wp-json\/wp\/v2\/pages\/761\/revisions\/6144"}],"wp:attachment":[{"href":"https:\/\/nmi.cool\/webdev\/wp-json\/wp\/v2\/media?parent=761"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}