androidhtml

How to indent and remove line spacing in HTML unordered list


I am using html.fromHtml() method in my android and I want to create a bullet point list:

Html.fromHtml("<p><ul><li>30 Cricket Questions</li><font color='#FF0000'><li>400 Seconds</li><li>7 Lives</li></ul></p>");

My problem is the line spacing and the indent.

Currently the list is set as so:

- 30 Cricket Questions


- 400 Seconds


- 7 Lives

I want to close the line space between each item and tab the 7 lives across a bit. How is this done in html? Tried padding=0 but did not work and unsure what the correct command is based on google. Also as a side question, how can I colour a bullet point red and shape it as a square?

Desired output:

- 30 Cricket Questions
- 400 Seconds
      - 7 Lives

Thanks


Solution

  • You can use multiples types of HTML lists.

    Nested lists

    <ul>
      <li>Item 1</li>
      <li>
        <font color="red">Item 2</font>
        <ul>
          <li>Item 2.1</li>    
        </ul>
      </li>
      <li>Item 3</li>
    </ul>
    

    Description lists

    <dl>
      <dt>Item 1</dt>
      <dd>description</dd>
      <dt>Item 2</dt>
      <dd>description</dd>
    </dl>