How to use namespaces in css?

my HTML page contains a div with the identifier "main", and I include another HTML page in my HTML page containing a div with the same identifier ("main"). I need to add a namespace to the id ("main") of my HTML page.

I include the header, footer from another site and including the content from my site to this HTML page. If other sites use the same identifier as my site, a conflict arises here.

On this HTML page, two css files are included. If both of them have the same class with a different style, there is a problem.

I need to apply my css file to my code and the other to the remaining code. can any body solve my problem?

+5
source share
6 answers

I agree with everyone so far, since there is no built-in CSS namespace and that if you have control (or desire / capacity) to edit your HTML, then this is the best approach.

One way to automate the process would be to write a script (PERL, PHP, .NET, etc.) to parse the HTML code you are pulling in and replace any existing ID or classes with a modified version.

i.e. <tag id="theID" class="theClass anotherClass">becomes<tag id="NAMESPACEtheID" class="NAMESPACEtheClass NAMESPACEanotherClass">

You can accomplish this with some creative regular expressions, although it would be harder if there was Javascript code that also needed to be changed.

, , , , .

, , !

+1

:

  • , , .
  • , .

, , . - , HTML, .

+4

- div, . css div.

:

#main
{Style}
.container #main
{Another style}

, HTML, .

+2

. , , .

, .

+2

, CSS , . : :)

+1

div div. , signup.html, main_signup

0
source

All Articles