+ 3

Why can't I use <style> and <h1> for the same paragraph?

10th Nov 2020, 10:29 AM
.jg
8 ответов
+ 12
<h1> <p style="color:white; background-color: aqua;"> The text </p> </h1> <!-- Khumayra Kimsanboeva The code above is working fine. It may happen because h1 is an block element and it is not inherited with the properties of p tag. Edit: there is no need of strong tag and you can also add style to H1 tag <h1 style="color:white; background-color: aqua;"> Text here </h1> -->
10th Nov 2020, 10:39 AM
ツSampriya😘ツ
ツSampriya😘ツ - avatar
+ 3
Can you please attach your code here. And there should be no problem you can use <style> and <h1> for same paragraph.
10th Nov 2020, 10:30 AM
ツSampriya😘ツ
ツSampriya😘ツ - avatar
+ 3
But you are applying style to p element not h1
10th Nov 2020, 10:40 AM
Abhay
Abhay - avatar
0
<p style="color:white; background-color: aqua;"><h1><strong>The text</strong></h1> </p>
10th Nov 2020, 10:33 AM
.jg
0
If I remove <h1> , the code works but otherwise it makes the heading but there is no style
10th Nov 2020, 10:35 AM
.jg
0
Ohh understand . Thank you))
10th Nov 2020, 10:40 AM
.jg
0
Even if the element is inline it doesn't inherits all the properties of parents .
10th Nov 2020, 10:56 AM
Abhay
Abhay - avatar
0
Semantically speaking, an "h1" element is not supposed to be inside the "p" paragraph element. Also strong wouldn't be effective on Heading tags. They are bold/strong by default. Here's how it should be <p style="color: white; background-color: aqua;"><strong>some text</strong></p> or <h1 style="color: white; background-color: aqua;">some text</h1>
10th Nov 2020, 11:01 AM
Adnan Niaz
Adnan Niaz - avatar