CSS Font

Google Advertisements

Prev Tutorial Next Tutorial

CSS Font

CSS font is used for design text or font for display on web page. CSS font properties define the font family, boldness, size, and the style of a text.

CSS Font Families

Font Style

Font style are used for set font style. Font style property has three values they are;

  • 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)

Example: font style

<html>
<head>
<style>
h1 {
    font-style: normal;
}

h2 {
    font-style: italic;
}

p {
   font-style: oblique;
}
</style>
</head>
<h1>This is h1 Heading</h1>
<h2>This is h2 Heading</h2>
<p>This is Paragraph</p>
</body>
</html>

Output

This is h1 Heading

This is h2 Heading

This is Paragraph

Font Size

We can define size of font in following way

  • With Em
  • Percent
  • With Pixels

Font size in pixels

If you Setting the text size with pixels then you can gives full control over the text size.

Example: font size in pixel

<html>
<head>
<style>
h1 {
    font-size: 40px;
}

h2 {
    font-size: 30px;
}

p {
    font-size: 14px;
}
</style>
</head>
<h1>This is h1 Heading</h1>
<h2>This is h2 Heading</h2>
<p>This is Paragraph</p>
</body>
</html>

Output

This is h1 Heading

This is h2 Heading

This is Paragraph

Font size in Em

The em size unit is recommended by the W3C. 1em is equal to default text size in browsers (16px). The size convert pixels to em using this formula: pixels/16=em

Example: font size in Em

<html>
<head>
<style>
h1 {
    font-size: 2.5em; /* 40px/16=2.5em */
}

h2 {
    font-size: 1.875em; /* 30px/16=1.875em */
}

p {
    font-size: 0.875em; /* 14px/16=0.875em */
}
</style>
</head>
<h1>This is h1 Heading</h1>
<h2>This is h2 Heading</h2>
<p>This is Paragraph</p>
</body>
</html>

Output

This is h1 Heading

This is h2 Heading

This is Paragraph

Font size in percent

Text size work on all browsers, you can use default font-size in percent for the <body> element.

Example: font size in percent

<html>
<head>
<style>
body {
    font-size: 100%;
}
h1 {
    font-size: 2.5em;
}

h2 {
    font-size: 1.875em;
}

p {
    font-size: 0.875em;
}
</style>
</head>
<h1>This is h1 Heading</h1>
<h2>This is h2 Heading</h2>
<p>This is Paragraph</p>
</body>
</html>

Output

This is h1 Heading

This is h2 Heading

This is Paragraph

Browser supported

Properties
fontYesYesYesYesYes

Prev Tutorial Next Tutorial

Google Advertisements

We have more than 5 Groups which have 500000+ Members and some Pages have more than 100000+ members. If you want to post your article on our website/FB Group/FB Page please contact on [email protected] or 8076671483

Buy This Ad Space @$50 per Month, Ad Size 600X200 Contact on: [email protected] or 8076671483

Path variable is set for providing path for all Java tools like java, javac, javap, javah, jar, appletviewer which are used in java programming. All these tools are available in bin folders so we set path upto bin folders.

Classpath variable is set for providing a path for predefined Java classes which is used in our application. All classes are available in lib/rt.jar so we set classpath upto lib/rt.jar.

Cloud computing is the on demand availability of computer system resources, especially data storage and computing power, without direct active management by the user.

College Projects Related to Java, AWT, C Projects for College, C++ Projects for College, Android Projects.

Download Projects

Adsense Advertisements


Buy This ads Space 8076671483

Buy This Ad Space @$120 per Month, Ad Size 300X600 Contact on: [email protected] or 8076671483 Try this Keyword C++ Programs