Inspector Input selected=""

I’ve been using the Inspector for a while and one thing keeps confusing me. When an input element is marked as selected via HTML, it shows in the inspector as selected=""

My HTML:
HTML in Inspector:

It does the same for readonly modifiers.

Thanks!

Do you mean that you write <option selected> but in the inspector it renders as <option selected=""> ?
If so, it seems like Bug 1691057

Yes, that is it. I looked everywhere to figure out if maybe I was just doing it wrong (even though I’v been doing this for several years)! As Julian says:

The markup view is not meant to represent the authored HTML from the page, it’s rather a representation of what the browser understands and renders. For instance, if an element lacks a closing tag, the markup view will still generate it.

And the same applies to Chrome/Opera. If you set itemscope="" they will keep rendering it as itemscope . They choose to omit the empty string value in their UI, but they still don’t try to respect the authored HTML 100%.

I would, however, like to point out to the dev team, that it always says selected="" and never selected=“selected” (if the item is selected.) It would be more helpful without the quotes or if it said selected=“true/false”

hey Lisa,

It would be more helpful without the quotes or if it said selected=“true/false”

selected="true/false" would be misleading, because in HTML selected="false" will set it to true. This is a common mistake made by beginners in HTML.

I second that Firefox should only show selected instead of selected="", this “only” needs somebody to work on this :slight_smile:

I was looking at the true/false more as “feedback,” not something I would put in my HTML code, but you are correct. It would be very confusing to new users. It was very confusing to me and I’ve been doing this for years; I thought I was doing something wrong! Now that I understand why, I feel more confident, but I wasted a lot of time trying to find out why the code in the inspector was reporting differently than what it should be.

I would have been 100% satisfied with a help article or tip that had said “The markup view is not meant to represent the authored HTML from the page, it’s a representation of what the browser understands and renders.” or maybe something in more lay terms for beginners :slight_smile:

I appreciate your feedback, it’s important that we discuss things in this manner so we can help develop better products. I didn’t consider how my idea would impact beginners.