1

I want to add <div> inside <input>

<input type="submit"  
  name="body_0$main_0$contentmain_0$maincontent_1$contantwrapper_0$disclamerwapper_1$DisclaimerAcceptButton"
  value="I understand and agree to all of the above "  
  onclick="return apt();"  
  id="DisclaimerAcceptButton"
  class="DisclaimerAcceptButton">

The button is too long so I want to split its caption into two lines. I don't have access to pure html since everything is dynamic.

0

5 Answers 5

3

input elements cannot have descendants:

<!ELEMENT INPUT - O EMPTY              -- form control -->
                    ^^^^^

However, if you can change the code that generates the button, you can use button instead:

<button name="body_0$main_0$contentmain_0$maincontent_1$contantwrapper_0$disclamerwapper_1$DisclaimerAcceptButton" onclick="return apt();" id="DisclaimerAcceptButton" class="DisclaimerAcceptButton"> 
    I understand and agree to <br />
    all of the above
</button>

This lets you style the content of the button however you want to.

Sign up to request clarification or add additional context in comments.

1 Comment

That won't work though with the ASP.NET Button component, which the name and id attributes bespeak the use of.
2

A div is a block level HTML element and it shouldn't be added inside the button in such a way. You can however use CSS to specify a width to the button, and thus acquire the multi-lineness that you're looking for.

1 Comment

Also, for legacy support in browsers such as Internet Explorer 6, you can use the HTML-representation of carriage return: &#13;&#10;
1

You can't add div inside of input element (unless you want it in input's value).

Comments

1

No can't do. And if it works on some browser, it's not guaranteed to work anywhere else, because it doesn't follow the standards.

Comments

0

Only you need:

<input type="checkbox" id="a"/>
<label for="a"><div>... div content ...</div></label>

Like somebody write in input you cannot put any element but in label for it can.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.