Michael Andersen
Michael Andersen

Reputation: 1

Is it okay to add a headline inside an HTML button?

I was wondering if it is semantically correct or OK to add a headline such as h1, h2, h3, h4 inside an HTML button.

Example

<button type="button">
   <h3>Button headline text</h3>
</button>

Upvotes: 0

Views: 238

Answers (1)

Quentin
Quentin

Reputation: 943564

Semantically? Maybe. You could make arguments either way and it would depend on context.

However, syntactically, it is invalid. HTML does not allow h3 elements to be descendants of button elements.

Upvotes: 1

Related Questions