How to set font family and size in html/css


Tags: html,css

Problem :

I'd like to use css syntax in HTML document to set the font-family to "Arial" and font-size to 0.3cm for the whole document.

I use this code:

<style>
body { font-family: Arial; font-size: 0.3cm }
</style>

I am not sure if writing only Arial is enough, or should I write something like this?

<style>

body { font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif; font-size: 0.3cm }
  </style>

and I am also not sure if I cam use "cm" in the code, I mean it works in the browser but is it correct "code-wise" ?

thanks



Solution :

font-family: Arial

This means the browser will use Arial if you have it installed on your system. If not, it will use whatever the default font is for your browser.

font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif

This means the browser will use Arial if you have it installed on your system. If not, it will use Helvetica Neue if you have it installed on your computer. If not, it will use Helvetica if you have it installed on your computer. If not, it will use whatever the default sans-serif font is for your browser.

Both are perfectly valid. They just do slightly different things.

and I am also not sure if I cam use "cm" in the code

Yes, cm is a valid CSS unit of measurement.


    CSS Howto..

    How to cancel/disable hover and active effects coming from another CSS library?

    How to place items exactly where you want to CSS

    how to create a image slider with help of only HTML and CSS?

    How to set CSS for the php script loaded by Jquery

    How to create Two Columns with Separate Scrollbars in Responsive Bootstrap?

    How to select all elements after specific element in CSS

    How to control number of items per row using media queries in Flexbox?

    sidebar is under the openlayers map how to set css

    How to get span to be only as wide as the image inside of it?

    How do you skew a div and keep the background image unskewed

    how to have the text under the logo css

    How to apply css class to uploaded image? [closed]

    How to create DRY CSS when using transform & keyframes

    How to get CSS triangles to display in a row instead of vertical

    how to center UL in my page?

    How to apply css mark on videogular time line at specific time

    CSS - How to set height of absolute div same with neighbor image?

    How can i make a div to slide in from right side to left?

    How to change drop-down menu to drop-up menu

    How to embed css to HTML in laravel?

    how to override the specific style of spans in a div [span in a span ] using css or jquery?

    How to make custom login button work

    How can I apply a custom css rule to small helping arrows that appears on column reordering in Kendo UI grid

    How do I make custom scrollbars with jScrollPane to be always visible?

    How to make a grid layout with unknown number of columns and each column has equal size? [closed]

    HTML/CSS - How do I make divs to size according to their contents?

    How to select multiple objects of a class for css manipulation

    JS/JQuery: How to switch class several times in a loop way?

    How to edit ol tags in rich text editor

    How to set focus/active on the clicked li(tab) in angular.js