How to use two css files in an html

Asked

Viewed 572 times

3

How can I use two CSS files in an HTML file, but one of the CSS files is only used in one div.

I have a CSS file to style the page, but I needed another CSS file to style a div in the middle of the page.

'Cause I’m running tests to use, and I put up the CSS file I need just for the div first, and all until this div gets out of shape.

And if you come in second, everything after that div is deformed. I would like to know whether this can be done or not, and whether.

  • You can explain better "I put the css file I need just for div first"?

1 answer

5


Just add them both to the <head> of your HTML:

...
<head>
    ...
    <link rel="stylesheet" href="/css/css1.css" type="text/css" media="screen">
    <link rel="stylesheet" href="/css/css2.css" type="text/css" media="screen">
    ...
</head>
...

If both files apply to the same element, the second file may end up determining the style, but this will also depend on the CSS rules of precedence.

  • yes I know. but look what I edited in the question

  • 1

    Now I’ve seen it. But then it depends on which rules are conflicting, as I said it depends on the precedence of each of your rules.

  • thank you very much! that’s what the two files were applying to div.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.