tags:

views:

44

answers:

2

How can I reset <ul> and <li> tags to defaults inside html file without touching css?

For example, this gives me all items horizontally lined up same without any indenting. I am assuming they are getting their attributes from the css file, removal of css link in html makes them properly. So how to reset them?

<ul type="disc">
<li>Electronics
    <ul type="square">
    <li>DVD Players</li>
    <li>Computers
        <ul type="circle">
        <li>Desktops</li>
        </ul>
    </li>
    <li>Portable MP3 players</li>
    <li>T.V.s</li>
    </ul>
</li>
<li>Furniture
    <ul type="square">
    <li>Beds</li>
    <li>Tables</li>
    <li>Chairs</li>
    </ul>
</li>
</ul>

Thanks!

+3  A: 

You would have to iterate through every possible CSS property that could affect the list, and set it to auto for each element; not very efficient.

Also, there is no way of changing CSS properties without touching CSS, unless you want to mess with <font>-style formatting (which I don't recommend).

SimpleCoder
Thank you SimpleCoder, that is what i did. I added an onpage style. I wanted to learn if there was a way to reset it, i realized it is not possible, your answers were enlightening.
MariaKeys
You are welcome! If you like my answer (or another one), please consider accepting it as the correct answer.
SimpleCoder
A: 

Unfortunately for you, what you are asking to do (as simplecoder said) is not very efficient and requires you to use JavaScript (preferably jQuery as it works with CSS really well).

Fortunately for you, what you want to be accomplished is actually a very simple task. Without seeing your source code I can tell you with certainty what is happening:

  • There is a ul or li type selector, and your list is inheriting its styles from those generic style rules.

To fix, all you have to do is go into your CSS file and erase the styling rules for the ul and li tag. (However, assuming code on your website is already dependent on that code [why else would it be written?] you would be better off adding IDs or CLASSes to your "special" ul lists, and then instead of deleting your ul {} and li {} rules, just change them to ul#yourID {} and ul#yourID li{} thus preserving your current code while allowing you to keep your uls/lis default from the browser's stylesheet).

Moses
Thank you Moses, that is what i did. I added an onpage style. I wanted to learn if there was a way to reset it, i realized it is not possible, your answers were enlightening.
MariaKeys