+ 1

How do you distinguish between paragraphs <p> in the html when editing in css? like if I wanted to have different images behind different paragraphs, would you use the class ""? know it's basic, but I can't think through all the new stuff I've learnt lol thanks!

hi everyone, new to coding after working in an IT company on customer service and getting interested in the "back end". This course is great. I have a question (think it's been covered but can't wrack my brain for the answer)

24th Apr 2016, 11:52 PM
Jonothan Pinchen
Jonothan Pinchen - avatar
6 Respostas
+ 1
Yes you can use class (I prefer ID). If you want to set picture "x.png" to paragraph 1 and picture "y.png" to paragraph 2 as the background you have to give each paragraph a different class/ID (in your HTML area of course): <p class="one">this is paragraph one</p> and <p class="two">this is paragraph two</p> Now you can set the different backgrounds in CSS: p.one:{ background-image:url(x.png); } and p.two:{ background-image:url(y.png); } Hope it helped! :)
28th Apr 2016, 12:34 AM
Jan Kaiser
Jan Kaiser - avatar
+ 1
Use ID to target unique elements. Usually, classes are more common, you will see and use them often.
18th Jun 2016, 11:15 PM
beaTa
beaTa - avatar
0
I've made a little mistake: don't write p.one:{} but p.one {}
28th Apr 2016, 12:37 AM
Jan Kaiser
Jan Kaiser - avatar
0
add a class to p write like this in html <p class="my"> write like this in css p.my {background:url(#####) no-repeat;} add image url in the place of '#'
16th Nov 2016, 1:39 PM
Balu nair.v
Balu nair.v - avatar
26th Nov 2016, 11:08 AM
code-or-die
0
you can distinguish between any element using a class use <p class="name"> in html and use p.name in css
4th Jan 2018, 6:17 AM
Balu nair.v
Balu nair.v - avatar