- Default font color html
- Attributes
- DOM interface
- Specifications
- Browser compatibility
- Found a content problem with this page?
- MDN
- Support
- Our communities
- Developers
- HTML — Fonts
- Set Font Size
- Example
- Relative Font Size
- Example
- Setting Font Face
- Example
- Specify alternate font faces
- Setting Font Color
- Example
- The Element
- Example
- Example of the <basefont> Element
- HTML Default Font
Default font color html
Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
The HTML element defines the font size, color and face for its content.
Warning: Do not use this element. Use the CSS Fonts properties to style text.
Attributes
Like all other HTML elements, this element supports the global attributes.
This attribute sets the text color using either a named color or a color specified in the hexadecimal #RRGGBB format.
This attribute contains a comma-separated list of one or more font names. The document text in the default style is rendered in the first font face that the client’s browser supports. If no font listed is installed on the local system, the browser typically defaults to the proportional or fixed-width font for that system.
This attribute specifies the font size as either a numeric or relative value. Numeric values range from 1 to 7 with 1 being the smallest and 3 the default. It can be defined using a relative value, like +2 or -3 , which sets it relative to 3 , the default value.
DOM interface
This element implements the HTMLFontElement interface.
Specifications
Browser compatibility
BCD tables only load in the browser
Found a content problem with this page?
This page was last modified on Jul 17, 2023 by MDN contributors.
Your blueprint for a better internet.
MDN
Support
Our communities
Developers
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998– 2023 by individual mozilla.org contributors. Content available under a Creative Commons license.
HTML — Fonts
Fonts play a very important role in making a website more user friendly and increasing content readability. Font face and color depends entirely on the computer and browser that is being used to view your page but you can use HTML tag to add style, size, and color to the text on your website. You can use a tag to set all of your text to the same size, face, and color.
The font tag is having three attributes called size, color, and face to customize your fonts. To change any of the font attributes at any time within your webpage, simply use the tag. The text that follows will remain changed until you close with the tag. You can change one or all of the font attributes within one tag.
Note −The font and basefont tags are deprecated and it is supposed to be removed in a future version of HTML. So they should not be used rather, it’s suggested to use CSS styles to manipulate your fonts. But still for learning purpose, this chapter will explain font and basefont tags in detail.
Set Font Size
You can set content font size using size attribute. The range of accepted values is from 1(smallest) to 7(largest). The default size of a font is 3.
Example
Font size = "1"
Font size = "2"
Font size = "3"
Font size = "4"
Font size = "5"
Font size = "6"
Font size = "7"
This will produce the following result −
Relative Font Size
You can specify how many sizes larger or how many sizes smaller than the preset font size should be. You can specify it like or
Example
Font size = "-1"
Font size = "+1"
Font size = "+2"
Font size = "+3"
Font size = "+4"
This will produce the following result −
Setting Font Face
You can set font face using face attribute but be aware that if the user viewing the page doesn’t have the font installed, they will not be able to see it. Instead user will see the default font face applicable to the user’s computer.
Example
Times New Roman
Verdana
Comic Sans MS
WildWest
Bedrock
This will produce the following result −
Specify alternate font faces
A visitor will only be able to see your font if they have that font installed on their computer. So, it is possible to specify two or more font face alternatives by listing the font face names, separated by a comma.
When your page is loaded, their browser will display the first font face available. If none of the given fonts are installed, then it will display the default font face Times New Roman.
Note − Check a complete list of HTML Standard Fonts.
Setting Font Color
You can set any font color you like using color attribute. You can specify the color that you want by either the color name or hexadecimal code for that color.
Note − You can check a complete list of HTML Color Name with Codes.
Example
This text is in pink
This text is red
This will produce the following result −
The Element
The element is supposed to set a default font size, color, and typeface for any parts of the document that are not otherwise contained within a tag. You can use the elements to override the settings.
The tag also takes color, size and face attributes and it will support relative font setting by giving size a value of +1 for a size larger or −2 for two sizes smaller.
Example
This is the page's default font.
Example of the <basefont> Element
This is darkgray text with two sizes larger
It is a courier font, a size smaller and black in color.
This will produce the following result −
HTML Default Font
element defined the HTML font size and color. However, the use of this element for font setting is no longer effective as the most popular browsers do not support it.
head> basefont color="green" size="6" face="verdana"> head>
Here are the options to control fonts without using the HTML element:
- To set HTML text color, apply the CSS color property.
- To set HTML font size, use the CSS font-size property.
- To style fonts by indicating font-related properties, use the CSS font property.
- To set a list of fonts from the highest priority to lowest, use the CSS font-family property.
The example below shows the proper way of setting font style with CSS properties:
p>Don’t worry: if Plan A doesn’t work, there are 25 more letters in the alphabet. p>
- Easy to use with a learn-by-doing approach
- Offers quality content
- Gamified in-browser coding experience
- The price matches the quality
- Suitable for learners ranging from beginner to advanced
- Free certificates of completion
- Focused on data science skills
- Flexible learning timetable
- Simplistic design (no unnecessary information)
- High-quality courses (even the free ones)
- Variety of features
- Nanodegree programs
- Suitable for enterprises
- Paid Certificates of completion