2

Question

What is the best way to have lots of text for the title attribute within the HTML input type button?

Currently I literally just have lots of text, but this results in very long lines of HTML code. For example:

<input id="DoSomething" type="button" name="DoSomething" value="Do Something" title="This a shadow of the amount of text one can put as the title.">

My Use Case

Why use lots of text for the title attribute? Because I'm trying to have instructions about the button's purpose within a tooltip. My webpage is crowded, and I don't want to list the text as a paragraph, external to the button. I am open to other ideas.

Source: https://stackoverflow.com/a/2238299/11163122

Intrastellar Explorer
  • 3,005
  • 9
  • 52
  • 119
  • I think this is a coding/programming, and more a user-experience, problem. As such this may be worth asking [ux.se]. – David Thomas Oct 01 '19 at 23:42

1 Answers1

1

So, this could either be done with Javascript, as follows:

var inputDoSomething = document.getElementById('DoSomething');
inputDoSomething.setAttribute('title', 'This a shadow of the amount of text one can put as the title.');
<input id="DoSomething" type="button" name="DoSomething" value="Do Something">

Or via your backend file (I am assuming C#), like so:

C#

protected void Page_Load(object sender, EventArgs e)
{
  DoSomething.Attributes.Add("title","This a shadow of the amount of text one can put as the title.");
}

HTML in .ASPX file

<input id="DoSomething" type="button" name="DoSomething" value="Do Something" runat="server">
EGC
  • 1,719
  • 1
  • 9
  • 20