Style guide update request: Styling HTML attributes with bold only?

@jpreuss started to enforce the rule stated in the style guide about the style for HTML attributes.

The doc (currently) states:

Attribute names

Use bold face .

[…]

Attribute values

Use “Code (inline)” style, and do not use quotation marks around strings, unless needed by the syntax of a code sample. For example: When the type attribute of an <input> element is set to email or tel …"

However, that does not seem to:

  • reflect the current state of the HTML attributes doc (most of them are enclosed in <code> (plus <strong> when it’s the first mention of a given attribute on the page defining that same attribute)
  • take into account the fact that an attribute is some code and would semantically deserve some <code>.

Any consensus to enforce this rule or to update the style guide accordingly?

Thanks!

1 Like

That thing about boldface for attribute names is a surprise. If it’s not a mistake, I disagree with it. Code terms should always be inside something that makes it look like code, like a proper <code> block.

There’s been confusion about what to do with strings and quotation marks. I had been told previously (perhaps a couple years ago) that the string values of things like enumerated strings should always be in quotes. That seemed odd to me, but I was fine with it, so I’ve been mostly doing that since. I have switched back just recently to starting to leave them out again on some pages and I like them better.

We should update this accordingly in the style guide.

Re: attribute names in boldface, that is ridiculous — no-one ever does that on MDN. I’ve just updated the styleguide.

I also think string values do no need to be in quotes.

I probably ought to give this document a proper update soon!

1 Like

Thanks @chrisdavidmills/@sheppy.
I’ll check previous edits of @jpreuss and reach out to him if necessary.

I’ve made a couple of updates to the style guide document. Someone else had already updated it to say to use <code> instead of bold, but I cleaned things up some in the surrounding text.

More importantly, I also updated the section on headings and sections to say not to use styles and <code> within headings. Having these styles within headings can lead to ugly headings that are hard to read, and more importantly, can lead to complications with parsing the contents of headings during automation and during link construction.

1 Like

Also, HTML attribute documentation is created using the {{HTMLAttrDef}} macro, which places the attribute name inside <strong> and <code>.

This is easy enough to fix. The id is just used for linking to, right? Se we could just put it on the <code> element instead and delete the <strong> element?

1 Like