How can i "lock" colors in CSS to be used for 4 different html pages inside one web document? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How can i "lock" colors in CSS to be used for 4 different html pages inside one web document?

I use CSS to define colors, but if i type something more, the browser show the last color that i use for my task.

15th Jun 2018, 9:13 PM
Marconi
Marconi - avatar
5 Answers
+ 1
Need to make 4 pages of web site (this is for an exam) but i cannot to set up 4 diffenrent colors, in CSS I hope u aunderstand what i want to got... (CSS) cololors background-color:#07F; background-color:#A0A; background-color:#F90; background-color:#666; and this is Code for HTML part names of pages should be Index, bios, portfolio and contact... <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Grupa 5</title> <link rel="stylesheet" type="text/css" href="ispit.css"> </head> <body id="index.html"> </body> </html>
15th Jun 2018, 9:37 PM
Marconi
Marconi - avatar
+ 1
Well, here's something to consider: If the background-color is the only thing that you want to be different between the pages, then it's more efficient to just put the proper background-color in each HTML file and not create a CSS file at all. If you have other styling in the ispit.css file, then you could: 1. Create a separate class in the ispit.css file for each background-color, for example, .bg-a { background-color: #07F; } .bg-b { background-color: #A0A; } .bg-c { background-color: #F90; } .bg-d { background-color: #666; } then, 2. Apply the classes to each HTML file as needed, for example, <body class="bg-a"> and, maybe this goes without saying, but 3. Make sure you link the ispit.css stylesheet to all four of the HTML files as you've done in the head of your sample code. Otherwise, I think that we need more information about what you want to achieve to give you a better answer.
16th Jun 2018, 9:39 AM
Janningā­
Janningā­ - avatar
0
Can you please link your code or provide an example?
15th Jun 2018, 9:27 PM
damyco
damyco - avatar
0
So, you have 4 different html files/pages if yes just create new css file for each page and link them one for each. Then set the backgrounds on each css
15th Jun 2018, 10:04 PM
damyco
damyco - avatar
0
U mean to create 4 different CSS files, each of 4 HTML files? Is there any chance to create only one CSS for all 4 Html? cause that is just a part of the tast... need to do a few things before i finish it.
15th Jun 2018, 10:08 PM
Marconi
Marconi - avatar