style a part of <p> | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

style a part of <p>

<p> my birthday is on 2 march 2001 <p> how can i only style the date in p tag in CSS suppose i want to underline it make it bold change its color of only the date

7th Jul 2020, 7:49 AM
Abdul Majeed Faraz
Abdul Majeed Faraz - avatar
14 Answers
+ 4
Do you need something like this https://code.sololearn.com/W56I80x9oryP/?ref=app
7th Jul 2020, 7:56 AM
Nilesh
+ 6
U can either use this inside your style tag or CSS //Your HTML <p> ....... </p> body{ } p{ color : red; text-decoration : underline ; }
7th Jul 2020, 7:52 AM
Nilesh
+ 3
What do you mean by separate CSS file?
7th Jul 2020, 8:02 AM
Nilesh
+ 3
thanks everyone for help
9th Jul 2020, 5:40 PM
Abdul Majeed Faraz
Abdul Majeed Faraz - avatar
+ 3
Abae salae Tujae Ya Bhi Nahi Ata 😂😂😂😂😂😂
11th Jul 2020, 5:36 PM
Rameez
Rameez - avatar
+ 2
thanks that exactly what looking for but is there any way i can do it in seperate css file
7th Jul 2020, 7:58 AM
Abdul Majeed Faraz
Abdul Majeed Faraz - avatar
+ 2
thanks everyone i got it thanks for help
7th Jul 2020, 8:02 AM
Abdul Majeed Faraz
Abdul Majeed Faraz - avatar
+ 2
Place the date in a span tag, you can assign a class to the span and style it or just go ahead and style the span tag in CSS. SYNTAX: <p> my birthday is on <span> 2 march 2001 </span> </p>
7th Jul 2020, 3:33 PM
Tandoh Achiever Teneng
Tandoh Achiever Teneng - avatar
+ 2
You can do this: HTML: <p> my birthday is on <span id="date">2 march 2001.</span></p> CSS: #date { color: red; text-decoration: underline; } You can make the entry shorter without using CSS: <p>my birthday is on <span style="color:red; text-decoration:underline">2 march 2001.</span></p>
8th Jul 2020, 5:26 AM
joseffie
joseffie - avatar
+ 2
It can be use in or outside it too
8th Jul 2020, 9:15 AM
Rahid Ahmed
Rahid Ahmed - avatar
+ 1
if i use p{ color : red; text-decoration : underline ; } this it will also style the whole para but i only want to style "2 march 2001" part
7th Jul 2020, 7:53 AM
Abdul Majeed Faraz
Abdul Majeed Faraz - avatar
+ 1
Use inline element as _style=""_ Or use external css file
7th Jul 2020, 7:58 AM
Suren🇮🇳
Suren🇮🇳 - avatar
+ 1
nilesh can u tell me
7th Jul 2020, 8:00 AM
Abdul Majeed Faraz
Abdul Majeed Faraz - avatar
+ 1
<head> ........ ....... ... <style> .dataMatching { text-decoration: underline; } </style> </head> <p>my birthday is on <div class="dataMatching">2 march 2001</div></p> P.S. hope it helped u😺
8th Jul 2020, 7:58 AM
Sonya