CSS Font-size26 Mar 2025 | 2 min read The font-size property in CSS is used to specify the height and size of the font. It affects the size of the text of an element. Its default value is medium and can be applied to every element. The values of this property include xx-small, small, x-small, etc. SyntaxThe font-size can be relative or absolute. Absolute-sizeIt is used to set the text to a definite size. Using absolute-size, it is not possible to change the size of the text in all browsers. It is advantageous when we know the physical size of the output. Relative-sizeIt is used to set the size of the text relative to its neighboring elements. With relative-size, it is possible to change the size of the text in browsers. NOTE: If we do not define a font-size, then for the normal text such as paragraphs, the default size is 16px, which is equal to 1em.Font-size with pixelsWhen we set the size of text with pixels, then it provides us the full control over the size of the text. ExampleFont-size with emIt is used to resize the text. Most of the developers prefer em instead of pixels. It is recommended by the world wide web consortium (W3C). As stated above, the default text size in browsers is 16px. So, we can say that the default size of 1em is 16px. The formula for calculating the size from pixels to em is em = pixels/16. ExampleResponsive font sizeWe can set the size of the text by using a vw unit, which stands for the 'viewport width'. The viewport is the size of the browser window. 1vw = 1% of viewport width. If the width of the viewport is 50cm, then the 1vw is equal to 0.5 cm. ExampleFont-size with the length propertyIt is used to set the size of the font in length. The length can be in cm, px, pt, etc. Negative values of length property are not allowed in font-size. SyntaxExampleNext TopicCSS font-family |
CSS Font-Weight Introduction CSS font weight is a property used in web development to control the thickness and boldness of text within a webpage. It is used to define the weight of the text. The available weight depends on the font family used by the browser. It plays an...
9 min read
Clearfix CSS What is CSS Clearfix? A CSS technique called clearfix keeps floated elements inside containers and ents them from collapsing when they contain floated child elements. Elements that are floated in CSS are removed from the standard document flow, which occasionally causes problems with their parent...
5 min read
CSS card design is most important for a user-friendly method of presenting information in an organized style. The card is used to become an essential component of contemporary web design. It works from straightforward, basic designs to more complex, dynamic card design layouts. We can design exciting...
6 min read
The appearance of components on a webpage can be softened by using CSS to create rounded borders. Rounded borders offer a feeling of aesthetics and might enhance the visual attractiveness of the entire design. I'll go over all the different attributes and values you may use...
17 min read
Background-Size in CSS Introduction We can determine the size of the background image with the help of the property. We can make the image as left, stretched, and fit for the available space. There are so many syntaxes for the implementation of the property. We...
8 min read
The CSS white space property is used to specify how to display the content within an element. It is used to handle the white spaces inside an element. values There are many white space values that can be used to display the content inside an element. Value Description normal This...
1 min read
When more than one conflicting rules of CSS indicates the same element, then the browser will follow some rules for determining the particular one. Specificity is the way which helps the browsers to decide which property value is most relevant for the element. It determines...
2 min read
In CSS, there are various properties that you can apply to your web page to make it look appealing. Each CSS property has its value that describes how a web page element should look. Before knowing about , let us know about the CSS Box Model. Understanding...
6 min read
Text Indent CSS Web development uses the underlying technology of Cascading Style Sheets (CSS) to manage the visual presentation of web pages. A key feature of CSS is text indentation, which gives you control over how text is aligned and placed within elements. This article will...
11 min read
Cascading Style Sheets (CSS) are the backbone of web design, allowing developers and designers to control the appearance of web pages. One crucial aspect of CSS is managing the borders of elements, which can significantly impact a website's overall look and feel. This comprehensive guide will...
6 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India