css3 web font
@font-face syntax
@font-face can load server-side fonts, allowing the client browser to display fonts that are not installed on the client.
@font-face{ font-family:<YourWebFontName>; src:<source> [<format>] [,<source> [<format>]] *; [font-weight:<weight>]; [font-style:<style>];}
To implement @font-face
To use @font-face custom font normally, you need to meet the following key points.
- Upload fonts in various formats to the server to support various browsers.
-
Display the specified custom font name
in @font-face and the font source of the applied custom font.@font-face { font-family:'SingleMaltaRegular'; src: url('../fonts/singlemalta-webfont.eot'); src: url('../fonts/singlemalta-webfont.eot?#iefix') format('embedded-opentype'), url('../fonts/singlemalta-webfont.woff') format('woff'), url('../fonts/singlemalta-webfont.ttf') format('truetype'), url('../fonts/singlemalta-webfont.svg#SingleMaltaRegular') format('svg');}
Both font-family and src in the code block are required. Font-family is used to customize the font, and src is the source of the custom font.
The font-family in @font-face rules is slightly different from the font-family in styles. The font-family in @font-face only declares the name of the font, but does not assign this font to the element. The font-family in the style explicitly specifies the font name for the element.
Customize the font name through font-family in the @font-face rule. This name can be any name. It is only used for reference by the font-family attribute in the element style.
The above code declares the font name "SingleMaltaRegular" through @font-face, but it will not have any actual effect. If you want the text font in the web font to be SingleMaltaRegular, you need to reference it in the corresponding element in the style code block Fonts defined by @font-face, such as:
h2{font-family:"SingleMaltaRegular";}
Due to the compatibility issues of different browsers, the support for font formats is also different. Let’s take a look at what fonts are supported by each version of the browser.
-
TureTpe (.ttf) format:
.ttf font is the most common font for Windows and Mac and is a RAW format, so it is not optimized for websites , browsers that support this font include [IE9, Firefox3.5, Chrome4, Safari3, Opera10, iOS Mobile Safari4.2];
OpenType (.otf) format:
.otf font is considered an original font format, which is built on the basis of TrueType, so it also provides more functions. The browsers that support this font are [Firefox3 .5, Chrome4.0, Safari3.1, Opera10.0, iOS Mobile Safari4.2];
-
Web Open Font Format (.woff) format:
.woff font is the best format among Web fonts. It is a compressed version of open TrueType/OpenType and also supports the separation of metadata packages. Browsers that support this font include [IE9, Firefox3.5, Chrome6, Safari3 .6, Opera11.1];
-
Embedded Open Type (.eot) format:
.eot font is a special font for IE. This format font can be created from TrueType , browsers that support this font include [IE4];
-
SVG (.svg) format:
.svg font is a format based on SVG font rendering , Browsers that support this font include [Chrome4, Safari3.1, Opera10.0, iOS Mobile Safari3.2].
This means that in @font-face we need at least two format fonts, .woff and .eot, and even .svg and other fonts to support more browsing versions .

ToinsertanimageintoanHTMLpage,usethetagwithsrcandaltattributes.1)UsealttextforaccessibilityandSEO.2)Implementsrcsetforresponsiveimages.3)Applylazyloadingwithloading="lazy"tooptimizeperformance.4)OptimizeimagesusingtoolslikeImageOptimtoreduc

The core purpose of HTML is to enable the browser to understand and display web content. 1. HTML defines the web page structure and content through tags, such as, to, etc. 2. HTML5 enhances multimedia support and introduces and tags. 3.HTML provides form elements to support user interaction. 4. Optimizing HTML code can improve web page performance, such as reducing HTTP requests and compressing HTML.

HTMLtagsareessentialforwebdevelopmentastheystructureandenhancewebpages.1)Theydefinelayout,semantics,andinteractivity.2)SemantictagsimproveaccessibilityandSEO.3)Properuseoftagscanoptimizeperformanceandensurecross-browsercompatibility.

A consistent HTML encoding style is important because it improves the readability, maintainability and efficiency of the code. 1) Use lowercase tags and attributes, 2) Keep consistent indentation, 3) Select and stick to single or double quotes, 4) Avoid mixing different styles in projects, 5) Use automation tools such as Prettier or ESLint to ensure consistency in styles.

Solution to implement multi-project carousel in Bootstrap4 Implementing multi-project carousel in Bootstrap4 is not an easy task. Although Bootstrap...

How to achieve the effect of mouse scrolling event penetration? When we browse the web, we often encounter some special interaction designs. For example, on deepseek official website, �...

The default playback control style of HTML video cannot be modified directly through CSS. 1. Create custom controls using JavaScript. 2. Beautify these controls through CSS. 3. Consider compatibility, user experience and performance, using libraries such as Video.js or Plyr can simplify the process.

Potential problems with using native select on mobile phones When developing mobile applications, we often encounter the need for selecting boxes. Normally, developers...


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

Notepad++7.3.1
Easy-to-use and free code editor

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool
