# CSS Fonts and Icons

# **CSS Fonts**

Choosing the right font for your website is important!

## **CSS font-family Property**👇

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1683949711123/1d3345ae-32bc-49f1-8ba3-a391f069fa66.png align="center")

## **CSS Web Safe Fonts**👇

**However, there are no 100% completely web safe fonts. There is always a chance that a font is not found or is not installed properly.**

Therefore, it is very important to always use `fallback fonts.`

This means that you should add a list of similar "backup fonts" in the `font-family` property. If the first font does not work, the browser will try the next one, and the next one, and so on. Always end the list with a generic font family name.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1683949764892/e7944a23-316b-43f9-9fea-8834876d05b2.png align="center")

## **CSS Font Style**👇

The `font-style` property is mostly used to specify italic text.

This property has three values:

* normal - The text is shown normally
    
* italic - The text is shown in italics
    
* oblique - The text is "leaning" (oblique is very similar to italic, but less supported)
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1683949847306/0a7bcbb4-431a-4cc5-84e1-c7b231f566d6.png align="center")
    
    ## **Font Weight**👇
    
    The `font-weight` property specifies the weight of a font:
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1683949919149/58134f92-dadd-409f-90e4-45d3af94b02c.png align="center")
    

Example👇

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1683949989328/283941b3-6d9e-4986-84d6-b38b7e244cfd.png align="center")

## **Font Variant**👇

The `font-variant` property specifies whether or not a text should be displayed in a small-caps font.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1683950044360/6dfaf18c-c5e4-4814-a644-c524c240b25f.png align="center")

## **Font Size**👇

The `font-size`  property sets the size of the text

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1683950109778/cbaec673-50e2-4072-8621-fe3b5a1dbbd0.png align="center")

## **CSS Google Fonts**👇

If you do not want to use any of the standard fonts in HTML, you can use Google Fonts.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1683950177957/3776051b-a7b7-4eab-9917-c776c833e44f.png align="center")

## How To Use Google Fonts

Just add a special style sheet link in the &lt;head&gt; section and then refer to the font in the CSS.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1683950251138/e7354afc-de09-42e1-b1d2-a1f8b40baf23.png align="center")

## **CSS Font Shorthand**👇

The `font` property is a shorthand property for:

* `font-style`
    
* `font-variant`
    
* `font-weight`
    
* `font-size/line-height`
    
* `font-family`
    

**Note:** The `font-size` and `font-family` values are required. If one of the other values is missing, their default value are used.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1683950379002/7e09bbcd-9d8a-4199-88e5-492a2b256a1f.png align="center")

---

# CSS Icons

Icons can easily be added to your HTML page, by using an icon library.

# How To Add Icons

The simplest way to add an icon to your HTML page is with an icon library, such as Font Awesome.

Add the name of the specified icon class to any inline HTML element (like `<i>` or `<span>`).

**Font Awesome Icons**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1683950591190/558396e1-9b0b-4e7c-8f81-6d2bdcdca8b4.png align="center")

Example👇

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1683950657545/8b419e05-2ca9-4160-a287-16ffafd6f6b5.png align="center")

---

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1666336375150/5HqI8zNVh.png align="left")

\&gt; Download our HTML & CSS Visual Treat! ebook Here: [Click here](https://codemarch.gumroad.com/l/hxazr)
