0

I have an html document.

In the document I link an external CSS Stylesheet

<link rel="stylesheet" type="text/css" href="css/whatever.css" />

But this external CSS Stylesheet modifies all my HTML document.

I need the External CSS Stylesheet to modify only a specific section of the HTML document.

  • 1
    Can you provide an html sample of the issue? – Adam Buchanan Smith Sep 09 '16 at 23:05
  • 1
    Could you provide the html and css? – Ahmed Mahmud Sep 09 '16 at 23:06
  • Based on what I have understoodfrom your post, maybe you should be using id's? – Ahmed Mahmud Sep 09 '16 at 23:06
  • 2
    Styles loaded from an external stylesheet will apply to any element on the page that matches the selectors of any given rule, so you either need to use inline styles where needed, or add more classes to the elements and then adjust those externally loaded styles (by adding in the required classes in as additional selectors) to target them that way. – UncaughtTypeError Sep 09 '16 at 23:11
  • also please indent your code with 4 extra spaces so that it is displayed as code – YakovL Sep 09 '16 at 23:42
  • Possible duplicate of [Limit scope of external css to only a specific element?](http://stackoverflow.com/questions/17667874/limit-scope-of-external-css-to-only-a-specific-element) –  Sep 10 '16 at 03:53
  • One approach might involve the use of an iframe. –  Sep 10 '16 at 03:54

2 Answers2

0

You can define the css inside the html document in two differents ways.

<style> //Your style </style>

or inline <tag style:"property:style;"></tag>

0

That's what classes are for if you want to style a specific part just wrap it in a div, give it a class and style it.

p { color: red; }

.specific p { color: blue; }
<div class="specific">
  <p>Test</p>
</div>
<p>Test</p>
<p>Test</p>
Rudi Urbanek
  • 1,935
  • 1
  • 12
  • 15