Ik heb het onderstaande bericht (enigszins gewijzigd):
‘Doe vóór 30 januari 2011 mee aan de wedstrijd en maak kans op maximaal
$$$$ — inclusief geweldige zomervakanties!”
Ik heb momenteel:
<p style="font-size:14px; color:#538b01; font-weight:bold; font-style:italic;">
de tekenreeks opmaakt, maar de kleur van “30 januari 2011” wilt wijzigen in #FF0000 en “zomer” in #0000A0.
Hoe doe ik dit strikt met HTML of inline CSS?
Antwoord 1, autoriteit 100%
<p style="font-size:14px; color:#538b01; font-weight:bold; font-style:italic;">
Enter the competition by
<span style="color: #ff0000">January 30, 2011</span>
and you could win up to $$$$ — including amazing
<span style="color: #0000a0">summer</span>
trips!
</p>
Of misschien wilt u in plaats daarvan CSS-klassen gebruiken:
<html>
<head>
<style type="text/css">
p {
font-size:14px;
color:#538b01;
font-weight:bold;
font-style:italic;
}
.date {
color: #ff0000;
}
.season { /* OK, a bit contrived... */
color: #0000a0;
}
</style>
</head>
<body>
<p>
Enter the competition by
<span class="date">January 30, 2011</span>
and you could win up to $$$$ — including amazing
<span class="season">summer</span>
trips!
</p>
</body>
</html>
Antwoord 2, autoriteit 39%
U kunt de HTML5-tag <mark>
gebruiken:
<p>Enter the competition by
<mark class="red">January 30, 2011</mark> and you could win up to $$$$ — including amazing
<mark class="blue">summer</mark> trips!</p>
En gebruik dit in de CSS:
p {
font-size:14px;
color:#538b01;
font-weight:bold;
font-style:italic;
}
mark.red {
color:#ff0000;
background: none;
}
mark.blue {
color:#0000A0;
background: none;
}
De tag <mark>
heeft een standaard achtergrondkleur…tenminste in Chrome.
Antwoord 3, autoriteit 28%
<p style="font-size:14px; color:#538b01; font-weight:bold; font-style:italic;">
Enter the competition by <span style="color:#FF0000">January 30, 2011</span> and you could win up to $$$$ — including amazing <span style="color:#0000A0">summer</span> trips!
</p>
De span-elementen zijn inline en onderbreken dus de stroom van de alinea niet, alleen stijl tussen de tags.
Antwoord 4, autoriteit 18%
<font color="red">This is some text!</font>
Dit werkte het beste voor mij toen ik slechts één woord in een zin in de kleur rood wilde veranderen.
Antwoord 5, autoriteit 15%
gebruik overspanningen. vb) <span style='color: #FF0000;'>January 30, 2011</span>
Antwoord 6, autoriteit 2%
Je kunt ook een les maken:
<span class="mychangecolor"> I am in yellow color!!!!!!</span>
Doe dan in een CSS-bestand:
.mychangecolor{ color:#ff5 /* it changes to yellow */ }
Antwoord 7, Autoriteit 2%
Kleer deze code op, maar u vindt het leuk om aan uw behoeften te voldoen, u kunt tekst selecteren? in de alinea om te zijn welk lettertype of stijl u nodig hebt!:
<head>
<style>
p{ color:#ff0000;font-family: "Times New Roman", Times, serif;}
font{color:#000fff;background:#000000;font-size:225%;}
b{color:green;}
</style>
</head>
<body>
<p>This is your <b>text. <font>Type</font></strong></b>what you like</p>
</body>
Antwoord 8
U kunt de langere Booringer Way
gebruiken
<p style="font-size:14px; color:#538b01; font-weight:bold; font-style:italic;">Enter the competition by</p><p style="font-size:14px; color:#ff00; font-weight:bold; font-style:italic;">summer</p>