Customizing the Tag Helper element.

ASR 671 Reputation points
2022-04-27T11:28:13.427+00:00

I am following below Microsoft link to change the Tag Helper element font. https://learn.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/intro?view=aspnetcore-6.0

I am using ImageTagHelper:
<img src="~/images/image1.jpg" alt="image" asp-append-version="true" />

When I change the color to Green from setting "HTML razor tag helper element" Nothing happened.

But when I select another option "HTML razor tag helper Attribute." color of asp-append-version changes.

So, what does "HTML razor tag helper element" do. (Tools > Options > Environment > Fonts and Colors)

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,148 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Callida Takemi 1 Reputation point
    2022-04-27T18:20:46.32+00:00

    The Information you shared above is great. I have been reading all you shared here. In this you explained everything very well. If i want any further guideline we will contact you here https://learn.microsoft.com/en-us/answers/questions/828350/customizing-the-tag-helper-results-element-font.html


  2. ASR 671 Reputation points
    2022-04-28T04:23:59.853+00:00

    I got the difference. There are two settings Within Options -> Environment -> Font & Colors -> Display Items in Visual Studio.

    Setting 1 "HTML Element Name"
    Setting 2 "HTML Razor Tag Helper Element".

    Now because many tag helper share comman name as of HTML Element name. "HTML element override font and color setting for "HTML Razor Tag Helper Element".
    For example color won't change for "Image Tag Helper" because it target <img> which is also an HTML image element. Similary for AnchorTag Helper which target "<a>".

    But if we try withEnvironment tag helper like below, it will work
    <environment>
    <strong>IWebHostEnvironment.EnvironmentName is Staging or Production</strong>
    </environment>

    Or, for "Partial" Tag Helper like:
    <partial name="Amit">
    </partial>