Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between @font-face and @import url?

Tags:

html

css

Don't really understand the difference between using @font-face and @import url(). Would someone explain this to me?

like image 753
matt.mcg Avatar asked May 15 '19 04:05

matt.mcg


3 Answers

@font-face is a css rule which allows you to download a particular font from your server to render a webpage if the user hasn't got that font installed.

@import url() Imports another style sheet into the current style sheet. If you have used this to embed a font, actually the imported style sheet includes the @font-face inside it.

like image 134
Ali Sheikhpour Avatar answered Oct 17 '22 16:10

Ali Sheikhpour


@import rule allows you to import a style sheet into another style sheet.

@font-face is a css rule which allows you to download a particular font from your server to render a webpage if the user hasn't got that font installed. This means that web designers will no longer have to adhere to a particular set of "web safe" fonts that the user has pre-installed on their computer.

like image 37
Binoj123 Avatar answered Oct 17 '22 14:10

Binoj123


The @font-face CSS at-rule specifies a custom font with which to display text; the font can be loaded from either a remote server or a locally-installed font on the user's own computer. If the local() function is provided, specifying a font name to look for on the user's computer, and the user agent finds a match, that local font is used. Otherwise, the font resource specified using the url() function is downloaded and used.

@font-face {
  font-family: "Open Sans";
  src: url("/fonts/OpenSans-Regular-webfont.woff2") format("woff2"),
       url("/fonts/OpenSans-Regular-webfont.woff") format("woff");
}

The @import CSS at-rule is used to import style rules from other style sheets. These rules must precede all other types of rules, except @charset rules; as it is not a nested statement, @import cannot be used inside conditional group at-rules.

@import url("fineprint.css") print;
@import url("bluish.css") speech;
@import 'custom.css';
@import url("chrome://communicator/skin/");
@import "common.css" screen;
@import url('landscape.css') screen and (orientation:landscape);
like image 1
DAMMAK Avatar answered Oct 17 '22 14:10

DAMMAK