PLEASE HELP ME!!! Why do some code affect the outcome of others๐Ÿ˜ž๐Ÿ˜ž๐Ÿ˜ž and how to prevent it??? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

PLEASE HELP ME!!! Why do some code affect the outcome of others๐Ÿ˜ž๐Ÿ˜ž๐Ÿ˜ž and how to prevent it???

E.g. p { color:white; background-color:pink; } How can we stop this code from affecting the outcome of others???

16th Nov 2021, 12:04 AM
Praise Onyemenam
Praise Onyemenam - avatar
2 Answers
+ 1
Add code, so we can see exacly what is problem. Probably you mean other paragraph? You are selecting every paragraph, and changing its style. To select only one, or group, you need to add id(if you select one) or class(to select more elements, what need to have same style), than select this in css. Like: <p id="anyName">asd</p> <p>ayxcs</p> #anyName { color: red; } Here only first will have style. Also you can use inline css on that element
16th Nov 2021, 12:22 AM
PanicS
PanicS - avatar
+ 1
Because you are setting style for the tag <p>. Instead, you can use class selector to change styles of selected paragraphs only. .stylish{ color:white; background-color:pink; } <p class="stylish"> This paragraph will be affected </p> <p> This paragraph will not be affected </p>
16th Nov 2021, 12:29 AM
Ashish Neupane
Ashish Neupane - avatar