Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@font-face not recognized in Visual Studio

I'm in Visual Studio and it's not recognizing the keyword "font" in the expression "@font-face". It's a mature HTML MVC app with all kinds of functionality, but when I tried to add the following code to load a custom font, it's not recognized.

<style type="text/css">
@font-face {
   font-family:comic;
   src:url(test.eot);
}
</style>

Tooltip error message:

The name 'font' does not exist in the current context

like image 718
Nick Gallant Avatar asked Aug 27 '15 14:08

Nick Gallant


People also ask

How do I add a font to Visual Studio?

In your VS code editor Go to File > Preferences > settings and search font. Insert the name of the newly downloaded font("Fira Code") before other default fonts and voila!! you have successfully installed a new font for your vscode editor ...

How do I put font faces in HTML?

To change font type purely with HTML, use the CSS font-family property. Set it to the value you want and place it inside a style attribute. Then add this style attribute to an HTML element, like a paragraph, heading, button, or span tag.

What is font face SCSS?

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.


2 Answers

"Razor examines the content on the right-hand side of any @ character and attempts to determine whether it is C# code (if it is a CSHTML file).

In cases where the content is valid as code as well (and you want to treat it as content), you can explicitly escape out @ characters by typing @@."

http://weblogs.asp.net/scottgu/introducing-razor

Add @@ instead of @ in .cshtml file for font-face.

like image 129
Saswata Sundar Avatar answered Oct 17 '22 05:10

Saswata Sundar


1.Create a CSS file for example "Fonts.css"

2.Drag your fonts you need to include to your project to "Fonts.css"

3.Include the "Fonts.css" in your View

َAnd try to add fonts

This is one of the ways that I think can help you

like image 42
Ghost Avatar answered Oct 17 '22 07:10

Ghost