In this second part of the series, I take an in-depth look at the “italic” option provided by Google’s Font API. It comes in handy for downloading and using the italicized version of a specified font family. The driving logic of this option is very easy to grasp, so you shouldn’t have major trouble using it when styling text-based elements on your own web pages.
Using the Google Font API`s Italic Option - Working with the italic option (Page 3 of 4 )
As I expressed in the section that you just read, the Google Font API gives web designers the option to be more “selective” when requesting a specific font family, as it permits you to download only the italic version of that family via an additional query string option named “italic.”
For instance, say that you need to decorate the text elements of the previous web page with the “Nobile” and “Cantarell” fonts, but only using the italicized version of the latter. In a case like this, the API should be queried in the following way:
That was simple to code and read, right? To download only the italic version of a given font, its name must be followed by the “italic” option, separated by a colon (:). Once the fonts have been served from one or multiple Google hosts in the cloud, they can be used to style the selected HTML elements in a classical fashion, as show below:
font: normal 46px 'Cantarell', Helvetica, sans-serif;
font: normal 40px 'Cantarell', Helvetica, sans-serif;
font: normal 32px 'Cantarell', Helvetica, sans-serif;
font: normal 14px 'Nobile', Helvetica, serif;
Even though the above CSS styles look identical to the ones coded in preceding examples, in this case the H1, H2 and H3 elements will be displayed on screen in an italic style, which is the desired result. Naturally, to see how these text elements are rendered by the browser, the styles must be properly coupled to the markup of a web page. That's what I'm going to do in the last section of this tutorial, so you can have at hand a fully-functional example which you can tweak and improve at will.