Nick Gallant
Nick Gallant

Reputation: 305

@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

Upvotes: 13

Views: 7585

Answers (2)

Ghost
Ghost

Reputation: 27

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

Upvotes: 1

Saswata Sundar
Saswata Sundar

Reputation: 586

"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.

Upvotes: 23

Related Questions