Home arrow HTML arrow Page 2 - Google Font API: Requesting a Bold Font Style Using a Numeric Notation
HTML

Google Font API: Requesting a Bold Font Style Using a Numeric Notation


If you’re a web designer who wants to take full advantage of the functionality offered by the brand new web service implemented by Google, that is the already popular Font API, then this article series might be the material that you’re looking for. It shows you how to work with the API’s most relevant features. In this ninth (and final) article of the series, you'll learn another way to get the bold version of a font.

Author Info:
By: Alejandro Gervasio
Rating: 5 stars5 stars5 stars5 stars5 stars / 5
July 07, 2010
TABLE OF CONTENTS:
  1. · Google Font API: Requesting a Bold Font Style Using a Numeric Notation
  2. · Review: the shorthand bi
  3. · Downloading a bold font style via a numeric notation
  4. · Embedding the previous CSS styles into a web page

print this article
SEARCH DEVARTICLES

Google Font API: Requesting a Bold Font Style Using a Numeric Notation - Review: the shorthand bi
(Page 2 of 4 )

As always, before I begin explaining how to download the bold style of a given font family by using a numeric syntax, I would first like to spend some moments reviewing the example built in the previous chapter of the series. It showed how to utilize the shorthand “bi” provided by the API to request at the same time the bold and italic versions of a specified typeface.

Having clarified that, here’s the example web page that demonstrates the use of the pertinent shorthand with the “Cantarell” font. Look at it, please:   

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Using the Google Font API (with the bi option)</title>

<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Cantarell:bi|Nobile" />

<style type="text/css">

body {

    padding: 0;

    margin: 0;

    background: #fff;

    font: 1em Arial, Helvetica, sans-serif;

    color: #000;

}

#wrapper {

    width: 960px;

    margin: 0 auto;

    background: #f4f4f4;

}

#header, #content, #footer {

    padding: 20px;

}

h1 {

    font: normal 46px 'Cantarell', Helvetica, sans-serif;

    color: #00f;  

}

h2 {

    font: normal 40px 'Cantarell', Helvetica, sans-serif;

    color: #ff8040;  

}

h3 {

    font: normal 32px 'Cantarell', Helvetica, sans-serif;

    color: #ff8040;

}

p {

    font: normal 14px 'Nobile', Helvetica, serif;

}

</style>

</head>

<body>

<div id="wrapper">

    <div id="header">

        <h1>Using the Google Font API</h1>

        <h2>Header section</h2>

        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse auctor commodo risus, et ultrices sapien vestibulum non. Maecenas scelerisque quam a nulla mattis tincidunt. Etiammassalibero, pharetra vel laoreet et, ultrices non leo. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed posuere ullamcorper lacus et sollicitudin. Morbi ultrices condimentum lacus, sit amet venenatis purus bibendum sit amet.</p>

    </div>

    <div id="content">

        <h2>Main content section</h2>

        <h3>Subheading section</h3>

        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse auctor commodo risus, et ultrices sapien vestibulum non. Maecenas scelerisque quam a nulla mattis tincidunt. Etiammassalibero, pharetra vel laoreet et, ultrices non leo. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed posuere ullamcorper lacus et sollicitudin. Morbi ultrices condimentum lacus, sit amet venenatis purus bibendum sit amet.</p>

    </div>

    <div id="footer">

        <h2>Footer section</h2>

        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse auctor commodo risus, et ultrices sapien vestibulum non. Maecenas scelerisque quam a nulla mattis tincidunt. Etiammassalibero, pharetra vel laoreet et, ultrices non leo. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed posuere ullamcorper lacus et sollicitudin. Morbi ultrices condimentum lacus, sit amet venenatis purus bibendum sit amet.</p>

    </div>

</div>

</body>

</html>

As shown above, the “bi” option is a mere abbreviation for the “bolditalic” argument discussed in the earlier chapters of this series, and therefore its functionality is exactly the same. So, if you need to style your text-based HTML elements by using two styles (bold and italic) simultaneously, it’s up to you to pick the argument that best fits your preferences, since they behave identically.

Of course, the previous example would be rather incomplete if I didn’t complement it with an image that shows the results generated by the “bi” option when applied to the H2 headers of the earlier web page, so here’s one that depicts this process quite clearly:

 

So far, so good. Now that you've grasped the logic behind using the “bi” shorthand, it’s time to explore a few additional features offered by the Google Font API. Like someone said once, “a promise should never be broken” (or something like that). In this case I’m going to adhere to this wise quote by keeping the promise I made in the introduction. Thus, in the next section I’m going to explain how to request the bold style of a font family using something as simple as a single number.

Want to see how this will be done? Then click on the link below and keep reading.


blog comments powered by Disqus
HTML ARTICLES

- Does HTML5 Need a Main Element?
- Revisiting the HTML5 vs. Native Debate
- HTML5: Not for Phone Apps?
- HTML5 or Native?
- Job Hunting? Freelancer.com Lists This Quart...
- HTML5 in the News
- Report: HTML5 Mobile Performance Lags
- The Top HTML5 Audio Players
- Top HTML5 Video Tutorials
- HTML5: Reasons to Learn and Use It
- More of the Top Tutorials for HTML5 Forms
- MobileAppWizard Releases HTML5 App Builder
- HTML5 Boilerplate: Working with jQuery and M...
- HTML5 Boilerplate Introduction
- New API Platform for HTML5

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials