2

I have this html file

<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>"This is my first page"</title>
<link href="assignment3-style.css" rel="stylesheet" type="text/css" />  
</head>
<body>
    <p>
        <ol style="I want the default style here">

        </ol>
    </p>

I want to override the style set by my stylesheet with the default style for ordered lists. How do I accomplish this?

  • Your HTML is invalid. Use a validator. http://validator.w3.org/nu/ – Quentin Jun 22 '15 at 18:57
  • Sorry i am new to html. thanks for the link. – Charles Driver Jr. Jun 22 '15 at 19:22
  • @Quentin: Your answer was (and still is) correct - you shouldn't have deleted it IMO. Though this question may conceivably be a duplicate of http://stackoverflow.com/questions/8228980/reset-css-display-property-to-default-value anyway, just with a different set of properties. – BoltClock Jun 22 '15 at 19:23

2 Answers2

1

Update: As of now, there is no reasonable way in CSS to reset to default styles. You will have to reset each and every property manually.

Just for reference purposes, here's my old - and wrong - answer:

Unless you want to reset all your <ol>, put a specific class on it, let's call it default-style.

For this class, then define in CSS

CSS:

.default-style { all: initial; } <-- This will NOT work!

HTML:

<ol class="default-style">
     <!-- your <li>s here -->
</ol>

If you want only certain CSS properties to default, set initial as their value, for example margin: initial;.

http://www.sitepoint.com/css3-inheritance-tips-tricks/

Community
  • 1
  • 1
connexo
  • 53,704
  • 14
  • 91
  • 128
  • 1
    Initial is not the same as browser default. See http://stackoverflow.com/questions/8228980/reset-css-display-property-to-default-value/8229026#8229026 In this specific case, although the default display of an ol is block, all: initial will reset it to inline, because the initial value of display is inline. – BoltClock Jun 22 '15 at 19:12
  • So the browser won't take the default styles for the element type that `all: initial;` is applied to into account? If that's true, what's the purpose of `initial` as a property value? – connexo Jun 22 '15 at 19:24
  • Honestly, [nobody knows](http://stackoverflow.com/questions/18534561/what-is-use-of-initial-value-in-css). Presumably it was put in for the sake of completeness, since CSS itself defines the concept of an initial value. – BoltClock Jun 22 '15 at 19:27
  • While this does not provide a solution to my issue it does answer the question. – Charles Driver Jr. Jun 22 '15 at 19:45
0

You can simply look in the css file where it effects the specific elements you want in default style and delete the css code, or make it more specific. Suppose you wanted ol to be in default styling for most instances, but wanted to keep the original code found in this stylesheet. You could simply do something like the following:

ol .not-default {
/*code that was already here*/
}

That way whenever you do not want default styling, you would simply write the following:

<ol class="not-default">Yay a stylish ordered list!</ol>

Hope that helps!

Jacques Mathieu
  • 113
  • 1
  • 13