image file guidance for website on .net8 (size px) for a file that includes text and is full screen width

Birbeck, Julie 20 Reputation points
2026-11-19T08:35:37.1533333+00:00

if wording must remain inside the artwork, for a hero image full width on a .net 8 website, what image file type and size should be provided for use

Developer technologies | .NET | Other
0 comments No comments

2 answers

Sort by: Most helpful
  1. Tom Tran (WICLOUD CORPORATION) 5,970 Reputation points Microsoft External Staff Moderator
    2026-11-19T09:33:16.8833333+00:00

    Hi @Birbeck, Julie ,

    Thanks for reaching out.

    For a full-width hero image that contains text as part of the artwork, I would recommend WebP as a good starting format. It offers a good balance between image quality and file size. PNG is another option if you need to preserve sharp text and graphics, while SVG may be suitable if the artwork is vector-based.

    For the image dimensions, I would suggest the following as a starting point:

    • Desktop: 1920 × 640 pixels for a wide hero banner. A larger version, such as 2560 × 853 pixels, may be useful for larger or higher-resolution displays.
    • Mobile: 1080 × 1350 pixels for a taller, mobile-friendly version.

    These are example dimensions rather than fixed requirements. The actual size depends on how the hero section is designed on your website.

    Since the wording needs to remain inside the artwork, I would recommend preparing a separate mobile version if possible. Simply shrinking the desktop image could make the text difficult to read on smaller screens.

    I would also suggest keeping the wording away from the edges of the artwork, as parts of the image may be cropped depending on the screen size. JPEG compression can also introduce visible artifacts around text, so I would generally prefer WebP or PNG for this type of artwork.

    One thing worth clarifying is that .NET 8 doesn't impose specific image dimensions for hero banners. How the image appears is determined by the website's layout and responsive design.

    You can refer to the MDN image format guide and responsive images documentation for additional guidance.

    Disclaimer: The MDN documentation is maintained by Mozilla and provides general web development guidance rather than Microsoft-specific requirements.

    Before finalizing the artwork, I would suggest checking how it looks on both desktop and mobile screens, particularly whether the wording remains clear and isn't cropped. If the image contains important wording, make sure that information is also available as accessible text.

    I hope this helps! If you found my response helpful or informative, I would greatly appreciate it if you could kindly follow this guidance. Thank you.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments

  2. AI answer

    2026-11-19T08:36:48.75+00:00

    If the wording must remain embedded in a full-width hero image, provide separate desktop and mobile artwork rather than one fixed-size file, with 1600–2400 px-wide desktop, 1024–1600 px-wide tablet, and 640–1080 px-wide mobile versions.

    Use Suggested pixel size Format
    Large desktop 2400 × 1050–1350 WebP, plus JPEG fallback if required
    Standard desktop/tablet 1600 × 700–900 WebP/JPEG
    Mobile portrait crop 800 × 900–1200 WebP/JPEG
    Vector-style artwork Responsive viewBox SVG, if fonts are outlined or reliably available

    These dimensions are practical starting points, not .NET requirements. Preserve the same aspect ratio whenever an image is resized; displaying it at a different ratio causes distortion.^1^

    Use:

    • WebP for most photographic or composited artwork.
    • JPEG when the publishing workflow requires broad fallback compatibility.
    • SVG only when the hero consists primarily of vector shapes, logos, and typography. Validate and sanitize SVG files before publishing.
    • PNG only where lossless detail or transparency is necessary; photographic PNG heroes are usually unnecessarily large.

    Keep all wording and logos inside a documented safe area. Do not place essential wording near the edges because a full-width hero commonly needs different crops at different viewport widths. Responsive <picture> sources allow the browser to select different artwork for desktop and mobile.^2^

    Important accessibility requirement

    Embedding wording in the image is not the preferred implementation. W3C guidance recommends real text instead of images of text because users may need to resize, restyle, translate, or increase the contrast of that text.^3^

    If the artwork cannot be changed:

    1. Include the same wording as accessible HTML text. It can be visually hidden if showing it twice is undesirable.
    2. Supply meaningful alt text describing the image and its message.
    3. If the same message is already exposed as HTML immediately beside the image, avoid repeating it in alt.
    4. Check readability and contrast on every supplied crop.
    5. Do not rely on embedded text for buttons or links; make the CTA a real HTML element.

    Alt text makes image information available to screen readers and also helps search engines understand the image.^4^

    Example for an ASP.NET Core .NET 8 site

    Place the files under wwwroot/images/hero/, then use responsive Razor/HTML markup:

    <picture>
      <source media="(max-width: 640px)"
              srcset="/images/hero/hero-mobile-800.webp">
      <source media="(max-width: 1200px)"
              srcset="/images/hero/hero-tablet-1600.webp">
      <img src="/images/hero/hero-desktop-2400.webp"
           width="2400" height="1050"
           alt="The complete message shown in the artwork"
           class="hero-image">
    </picture>
    
    .hero-image {
        display: block;
        width: 100%;
        height: auto;
    }
    

    The explicit width and height reserve the correct aspect ratio, while CSS scales the image to the available width. If the design requires a fixed-height, edge-to-edge crop, create breakpoint-specific artwork instead of depending on object-fit: cover, which can crop embedded wording.

    In .NET 8, static assets are normally served from wwwroot through UseStaticFiles.^5^ For a single Razor <img>, asp-append-version="true" can append a content hash so clients reload the file after it changes.^6^

    The designer handoff should therefore include three crops, their exact dimensions and safe areas, the accessible wording as plain text, and any required alt-text description—not just one large desktop bitmap.


    References

    1. Displays images with incorrect aspect ratio | Lighthouse | Chrome for Developers
    2. Using responsive images in HTML - HTML | MDN
    3. Understanding Success Criterion 1.4.5: Images of Text | WAI | W3C
    4. Overview: Generate image alt text with Image Analysis
    5. Serve static files in ASP.NET Core apps
    6. Image Tag Helper in ASP.NET Core
    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

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