CSS: Possible to define styles mid way through an html document?

Posted by Dr. Zim on Stack Overflow See other posts from Stack Overflow or by Dr. Zim
Published on 2010-06-07T05:17:32Z Indexed on 2010/06/07 5:22 UTC
Read the original article Hit count: 257

Filed under:
|
|

In ASP.NET MVC, there are these snippets of html called view templates which appear when their matching data appears on the screen. For example, if you have a customer order and it has a vendor address, the vendor address view template shows up populated with data.

Unfortunately, these don't have access to "MasterPages" nor are aware of their CSS surroundings.

Instead of loading these up with style tags, is there any way to create partial CSS files that could work for that particular html snippet, a sort of in-line CSS style section?

It would be really nice to plop this down just before we render the partial view:

<style type="text/css">
    input { margin: .2em .2em;
            overflow: hidden;
            width: 18.8em; 
            height: 1.6em;
            border: 1px solid black;}
</style>

to have the 15 or so input fields in that particular Html snippet be formatted the same. These are swapped out, so the positions of the input fields change. This may also imply a CSS reset on each partial view.

© Stack Overflow or respective owner

Related posts about css

Related posts about asp.net-mvc