Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Frans de Jong 550 posts 1862 karma points MVP 4x c-trib
    Apr 12, 2016 @ 14:27
    Frans de Jong
    0

    Empty alt attribute not possible in Razor?

    To comply with WCAG I neet to declare a empty alt attribute in a partial view.

    The problem is that <img src="someImage" alt="" /> renders to <img src="someImage" alt />

    How can I prevent Umbraco from deleting ="" ?

    Thanks

  • Kevin Jump 2343 posts 14890 karma points MVP 8x c-trib
    Apr 12, 2016 @ 17:31
    Kevin Jump
    100

    Hi

    do you have the snippet of code that is doing this?

    of the top of my head i can't think why this is happening, but if you wrapped it in Html.Raw then you would have full control of what got written out

    e.g

    <img src="..." @Html.Raw("alt=\"" + altVal + "\"")> 
    

    should work (if i got the "'s right)

  • Frans de Jong 550 posts 1862 karma points MVP 4x c-trib
    Apr 13, 2016 @ 06:02
    Frans de Jong
    0

    Oh, I'm such a morron..... I checked in Internet explorer and it shows the =""...

    It is chrome that removed it.

    Thanks anyway.

  • Mladen B. 12 posts 35 karma points
    Dec 23, 2017 @ 10:18
    Mladen B.
    1

    Just to add to this that Chrome didn't remove anything. You were just looking at the wrong place, probably. I suppose you were watching the "Inspect Element" section of the Chrom dev tools? The things you see there are the actual dom model, represented as an html structure.

    You can see the original html by right clicking the page and choosing "View page source". There, you should see the real html that reached your browser (with all the errors and stuff that caused the Chrome to ignore/remove them in the final DOM model).

Please Sign in or register to post replies

Write your reply to:

Draft