CSS or JS selector

1

I have a paragraph with no id that I need to stylize. Stylization can only occur for this paragraph. Example:

<p>Conteúdo</p>

So I want to apply CSS only to it.

seletor {estilo;}

Note: I can not add an id in the "p".

    
asked by anonymous 20.06.2017 / 21:14

3 answers

4

To style with JavaScript you can select the anchor with [href="www.whmcs.com"] .

Example:

var a = document.querySelector('[href="www.whmcs.com"]');
var p = a.parentElement;

p.style.backgroundColor = '#ddf';
p.style.padding = '5px';
<p>Algo...</p>
<p>Powered by <a href="www.whmcs.com">WHMCompleteSolution</a>.</p> 
<p>Algo...</p>
    
20.06.2017 / 22:50
0

try to get the parent selector of this p for example:

#meu_id p{}

Or maybe indexing

p:nth-child(1){}
    
20.06.2017 / 21:18
0

If this paragraph is unique, I do not see any harm in simply using a class , after all it is for this even though they exist , there is no reason to create a complex selector, or use JavaScript, just do something like:

.powerdby {
    color: #f00; /* é apenas um exemplo */
}
<p>Oi</p>

<p class="powerdby">
Powered by <a href="www.whmcs.com">WHMCompleteSolution</a>.
</p>

<p>Tchau</p>

Note: To stylize links you need to apply a selector as .poweredby a { ... } , because colors and underscores are not affected by inheritance, even with !important

    
20.06.2017 / 22:57