Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why don't I get CSS class intellisense from CSS files?

One of the nice features of VS2012 was that when I'm editing an HTML (or .cshtml) file, it provided great intellisense.

When I start to type:

<a href="

The editor would open a prompt with "Pick URL..." and a list of possible options based on the current directory of the file.

Pick URL example

^ Visual Studio 2012

Furthermore, in VS2012 the editor would detect any referenced CSS file(s), like this:

<link rel="stylesheet" type="text/css" href="bootstrap.css" />

And would provide autocompletion of all CSS classes inside that file.

So if I type:

<div class="

I would be prompted with all Bootstrap3 classes automatically. Like this:

CSS class intellisense

^ Visual Studio 2012

However in VS2013 both of these features seem to be missing.

Now when I look for CSS classes I only get classes that I've already used inside the file:

VS2013 CSS completion

^ Visual Studio 2013

According to the articles HTML Editing Features in Visual Studio 2013 Preview and HTML Editing Features in Visual Studio 2013 RC by Microsoft, these issues seem to be touched on but are more aimed at the Release Candidate or beta versions of VS2013. I'm using VS2013 Ultimate 12.0.21005.1 REL with all the latest update that I'm aware of.

Why is VS2013 not detecting CSS files for class autocompletion and not prompting me for URLs when writing href=?

like image 357
Rowan Freeman Avatar asked Nov 02 '13 04:11

Rowan Freeman


2 Answers

After intellisense worked fine for a few weeks, I just ran into the same problem as the OP. Uninstalling and re-installing packages using NuGet did not resolve it.

Deleting the bin and obj directories from the project and the .suo file from the solution directory resolve it.

like image 171
basp Avatar answered Sep 27 '22 19:09

basp


This was a change between Visual Studio 2012 and Visual Studio 2013.

Previously, simply opening a file in Visual Studio 2012 (not a solution, just an HTML file) and using

<link rel="stylesheet" href="bootstrap.css" />

in the HTML file meant that Visual Studio would read inside the CSS file and give CSS class intellisense. Microsoft abandoned this approach, because:

it failed to work in cases where files were included dynamically, or where ASP.NET Bundling and Minification was utilized

[Source]

In Visual Studio 2013, CSS files that are included in your project/solution will now automatically be parsed and all HTML documents will gain CSS class intellisense.

like image 31
Rowan Freeman Avatar answered Sep 27 '22 19:09

Rowan Freeman