开发者

How to reset <ul> and <li> inside html?

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!


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).


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜