{"id":115,"date":"2008-05-07T07:00:47","date_gmt":"2008-05-07T12:00:47","guid":{"rendered":"http:\/\/cssnewbie.com\/?p=115"},"modified":"2008-05-07T07:00:47","modified_gmt":"2008-05-07T12:00:47","slug":"replacing-font-tag-tips","status":"publish","type":"post","link":"https:\/\/cssdeck.com\/blog\/replacing-font-tag-tips\/","title":{"rendered":"7 Tips for Replacing the Font Tag"},"content":{"rendered":"<p><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2008\/05\/fonttag-400.gif\" alt=\"\" title=\"Dreamweaver Gives Up by Alexandra Roberts. Used under a Creative Commons license.\" width=\"400\" height=\"150\" class=\"alignnone size-full wp-image-117\" \/><\/p>\n<p>So let\u2019s say \u2013 hypothetically \u2013 that you\u2019ve decided to take the plunge and replace all of the font tags in your website with semantic code and CSS. Hypothetical congratulations! You\u2019re one step closer to web nirvana. Or perhaps you\u2019ve just inherited a website filled to the brim with hundreds of nested font tags forming some sort of primordial typographical soup. You have my (very real) condolences. Luckily, replacing font tags with semantic code and CSS isn\u2019t as terribly difficult as it might seem at the outset. And to help you along your way, here are a few tips on how to tackle the project.<\/p>\n<h3>Font Usage Assessment<\/h3>\n<p>Start out with a complete assessment of your current font usage. How many typefaces are you using currently? How many sizes? Do you use some of them more than others (hopefully so!). In what context are the fonts used? Write out this information and see if you can\u2019t discover some sort of a rational pattern in the usage. If you\u2019re lucky, a good, distinct pattern will appear \u2013 article headings always appear in 20-pixel Arial, for example.<\/p>\n<h3>Replace Font Tags with Semantic Tags<\/h3>\n<p>If you\u2019re lucky, and the font tags follow some sort of a rational pattern, you\u2019re in a good spot. The easiest way to start down the road to font tag recovery is to replace as many font tags as you can with semantic, meaningful tags. For example, if all of the article headings look the same, why not replace those font tags with an actual heading tag (&lt;h1&gt; &#8211; &lt;h6&gt;)? And if all of your paragraphs contain identical font tags, then you can just eliminate those tags straight away. Then you can style these elements later on down the road with CSS.<\/p>\n<h3>Avoid Classitis<\/h3>\n<p>The last thing you want to do when eliminating all of those font tags is just to replace them with a slew of unique classes and IDs. Classitis (as this practice is commonly called) is nearly as bad a disease on the web as is font tag usage. Only use classes and IDs when absolutely necessary; if all of your &lt;h3&gt; tags have a class of \u201carticleHeading,\u201d what\u2019s to stop you from just applying those styles to your &lt;h3&gt; instead? For more information on Classitis and how to prevent it, <a href=\"\/combating-classitis\/\">see this article on Combating Classitis.<\/a><\/p>\n<h3>Let Your Fonts Cascade<\/h3>\n<p>When it comes time to start writing your CSS, remember to <a href=\"\/what-is-this-css-thing-anyway\/\">let your font choices cascade.<\/a> If you discover that you have one size and typeface used in 90% of your website (14px Arial, for example), there\u2019s no reason to set this font information on every possible tag in your CSS. Just set your \u201cdefault\u201d (i.e., most common) typeface on your body tag instead. This will save you a ton of time and effort down the road. <\/p>\n<h3>Perform Unique-Case Triage<\/h3>\n<p>If you come across a single-use font tag in your website \u2013 a font style that is used in one and only one place in your website \u2013 this would be a good time to stop and consider whether to eliminate that unique case. Is that different typeface necessary? Was it even and <em>intentional<\/em> choice? With so many font tags scattered about, some differences in typography may be entirely accidental. If you decide that this specific instance is both deliberate and necessary (e.g., your error messages look different than the rest of the text), <a href=\"\/when-to-use-css-ids-and-classes\/\">set an ID<\/a> on the tag and style the element that way.<\/p>\n<h3>Use CSS Shorthand<\/h3>\n<p>You\u2019ve probably found that, while you\u2019ve managed to eliminate hundreds of font tags from your website, you\u2019ve added dozens of lines of CSS to your site \u2013 and that can seem like an uneasy trade if you\u2019re more comfortable with font tags than CSS. To help cut down on the length of your CSS file, it can help to use the <a href=\"\/css-shorthand\/\">font property shorthand (described here).<\/a> By using the shorthand, you can turn six or so lines of CSS into a single, easily digestible rule.<\/p>\n<h3>Make an Editor Do the Work<\/h3>\n<p>HTML editors can sometimes cause just as many problems as they solve \u2013 they can be a great source for font tags, for example. But many editors (Dreamweaver, Notepad++< and many others) also have pretty powerful search-and-replace functionality. And this will come in handy when you finally get to the toughest part of transitioning away from font tag usage \u2013 deleting all of those font tags you don\u2019t want anymore. At that point, and editor capable of doing a search\/replace \u2013 and perhaps even better, one that understands regular expressions \u2013 can be worth its weight in gold. Otherwise, you could just always consider the time it takes you to go through all that code as some sort of penance. :)\n\nThese are seven suggestions to help make it easier to transition from font tags to semantic code and CSS. If you have any other suggestions  you\u2019d like to add, offer them up in the comments!\n<\/p>\n<div class=\"wp-socializer wpsr-share-icons \" data-lg-action=\"show\" data-sm-action=\"show\" data-sm-width=\"768\" ><h3>Share and Enjoy !<\/h3><div class=\"wpsr-si-inner\"><div class=\"wpsr-counter wpsrc-sz-32px\" style=\"color:#000\"><span class=\"scount\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"facebook,twitter,linkedin,pinterest,print,pdf\">0<\/span><\/span><small class=\"stext\">Shares<\/small><\/div><div class=\"socializer sr-popup sr-32px sr-circle sr-opacity sr-pad sr-count-1 sr-count-1\"><span class=\"sr-facebook\"><a rel=\"nofollow\" href=\"https:\/\/www.facebook.com\/share.php?u=\" target=\"_blank\"  title=\"Share this on Facebook\"  style=\"color: #ffffff\" ><i class=\"fab fa-facebook-f\"><\/i><span class=\"ctext\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"facebook\">0<\/span><\/span><\/a><\/span>\n<span class=\"sr-twitter\"><a rel=\"nofollow\" href=\"https:\/\/twitter.com\/intent\/tweet?text=%20-%20%20\" target=\"_blank\"  title=\"Tweet this !\"  style=\"color: #ffffff\" ><i class=\"fab fa-twitter\"><\/i><\/a><\/span>\n<span class=\"sr-linkedin\"><a rel=\"nofollow\" href=\"https:\/\/www.linkedin.com\/sharing\/share-offsite\/?url=\" target=\"_blank\"  title=\"Add this to LinkedIn\"  style=\"color: #ffffff\" ><i class=\"fab fa-linkedin-in\"><\/i><\/a><\/span>\n<span class=\"sr-pinterest\"><a rel=\"nofollow\" href=\"https:\/\/www.pinterest.com\/pin\/create\/button\/?url=&amp;media=&amp;description=\" target=\"_blank\"  title=\"Submit this to Pinterest\"  style=\"color: #ffffff\" data-pin-custom=\"true\"><i class=\"fab fa-pinterest\"><\/i><span class=\"ctext\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"pinterest\">0<\/span><\/span><\/a><\/span>\n<span class=\"sr-print\"><a rel=\"nofollow\" href=\"https:\/\/www.printfriendly.com\/print?url=\" target=\"_blank\"  title=\"Print this article \"  style=\"color: #ffffff\" ><i class=\"fa fa-print\"><\/i><\/a><\/span>\n<span class=\"sr-pdf\"><a rel=\"nofollow\" href=\"https:\/\/www.printfriendly.com\/print?url=\" target=\"_blank\"  title=\"Convert to PDF\"  style=\"color: #ffffff\" ><i class=\"fa fa-file-pdf\"><\/i><\/a><\/span><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<\/p>\n<p>So let\u2019s say \u2013 hypothetically \u2013 that you\u2019ve decided to take the plunge and replace all of the font tags in your website with semantic code and CSS. Hypothetical congratulations! You\u2019re one step closer to web nirvana. Or perhaps you\u2019ve [&#8230;]<\/p>\n<p><a class=\"more-link article\" href=\"https:\/\/cssdeck.com\/blog\/replacing-font-tag-tips\/\" title=\"Click to read '7 Tips for Replacing the Font Tag'\">Read Article<\/a><\/p>\n","protected":false},"author":18,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[179,192],"tags":[],"_links":{"self":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/115"}],"collection":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/comments?post=115"}],"version-history":[{"count":0,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/115\/revisions"}],"wp:attachment":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/media?parent=115"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/categories?post=115"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/tags?post=115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}