Logo in header of layout page code

Dean Everhart 1,541 Reputation points
2023-06-16T13:18:37.7866667+00:00

The code below works to put a logo in the header (re: layout page).

Is this the correct way of doing it...correct syntax? What is the best way of doing this?

User's image

Developer technologies ASP.NET ASP.NET Core
Developer technologies ASP.NET Other
{count} votes

Accepted answer
  1. AgaveJoe 30,126 Reputation points
    2023-06-16T15:23:08.78+00:00

    Is this the correct way of doing it...correct syntax? What is the best way of doing this?

    If you are happy with the image size, location, etc, then you're done. However, the img tag you shared is missing the tag ending />.

    <img src="/media/logo.png" alt="Company" />
    

    https://www.w3schools.com/tags/tag_img.asp

    I notice that the Company Name in the following line of code... ...appears smaller than it normally would.

    The "Company" link uses the "navbar-brand" style. You can find the "navbar-brand" style in the browser's dev tools. Simply right click "Company" and select "Inspect".

    .navbar-brand {
        padding-top: 0.3125rem;
        padding-bottom: 0.3125rem;
        margin-right: 1rem;
        font-size: 1.25rem;
        text-decoration: none;
        white-space: nowrap;
    }
    

    Override the style if you want a larger company name. One way to do that is to add an inline style.

    <a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index" style="font-size:4.0em">MvcDemo</a>
    

    Another option is to take advantage of the "cascade" in cascading style sheets (CSS) and add a .navbar-brand style to the site.css file that comes with the MVC template.

    .navbar-brand {
        font-size: 4.0em;
    }
    

    Learn CSS.

    https://www.w3schools.com/css/

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.