Tôi có thông báo dưới đây (hơi thay đổi):
"Tham gia cuộc thi vào ngày 30 tháng 1 năm 2011 và bạn có thể giành chiến thắng lên tới $$$$ - bao gồm cả những chuyến đi mùa hè tuyệt vời!"
Tôi hiện có:
<p style="font-size:14px; color:#538b01; font-weight:bold; font-style:italic;">Định dạng chuỗi văn bản, nhưng muốn thay đổi màu sắc của "ngày 30 tháng 1 năm 2011" thành #FF0000 và "Mùa hè" thành #0000A0.
Làm thế nào để tôi làm điều này một cách nghiêm ngặt với HTML hoặc nội tuyến CSS?
Sam R.
15.8k11 Huy hiệu vàng67 Huy hiệu bạc120 Huy hiệu đồng11 gold badges67 silver badges120 bronze badges
Đã hỏi ngày 7 tháng 1 năm 2011 lúc 5:38Jan 7, 2011 at 5:38
<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>
Hoặc bạn có thể muốn sử dụng các lớp CSS thay thế:
<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>Đã trả lời ngày 7 tháng 1 năm 2011 lúc 5:41Jan 7, 2011 at 5:41
JacobjacobJacob
76.4K24 Huy hiệu vàng146 Huy hiệu bạc226 Huy hiệu Đồng24 gold badges146 silver badges226 bronze badges
3
Bạn có thể sử dụng thẻ HTML5 <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> 0:
<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>Và sử dụng điều này trong 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; }TAG <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> 0 có màu nền mặc định ... ít nhất là trong Chrome.
bad_coder
9.81620 Huy hiệu vàng39 Huy hiệu bạc64 Huy hiệu đồng20 gold badges39 silver badges64 bronze badges
Đã trả lời ngày 14 tháng 12 năm 2012 lúc 23:58Dec 14, 2012 at 23:58
4
<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>
Các phần tử nhịp được nội tuyến, do đó không phá vỡ dòng chảy của đoạn văn, chỉ có kiểu ở giữa các thẻ.
Đã trả lời ngày 7 tháng 1 năm 2011 lúc 5:41Jan 7, 2011 at 5:41
Damien-WrightDamien-WrightDamien-Wright
Jacobjacob4 gold badges27 silver badges23 bronze badges
76.4K24 Huy hiệu vàng146 Huy hiệu bạc226 Huy hiệu Đồng
Đã trả lời ngày 7 tháng 1 năm 2011 lúc 5:41Jan 7, 2011 at 5:41
brian_dbrian_dbrian_d
Jacobjacob4 gold badges46 silver badges72 bronze badges
<font color="red">This is some text!</font>
76.4K24 Huy hiệu vàng146 Huy hiệu bạc226 Huy hiệu Đồng
Bạn có thể sử dụng thẻ HTML5 <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> 0:
Và sử dụng điều này trong CSS:37 gold badges267 silver badges272 bronze badges
TAG <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> 0 có màu nền mặc định ... ít nhất là trong Chrome.Sep 10, 2017 at 15:01
user8588011user8588011user8588011
9.81620 Huy hiệu vàng39 Huy hiệu bạc64 Huy hiệu đồng3 silver badges2 bronze badges
3
Đã trả lời ngày 14 tháng 12 năm 2012 lúc 23:58
<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> 3
Các phần tử nhịp được nội tuyến, do đó không phá vỡ dòng chảy của đoạn văn, chỉ có kiểu ở giữa các thẻ.
.mychangecolor{ color:#ff5 /* it changes to yellow */ }
7.0584 Huy hiệu vàng27 Huy hiệu bạc23 Huy hiệu đồng
Sử dụng nhịp. Ex) <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> 25 gold badges28 silver badges50 bronze badges
Huy hiệu vàng 11K446 Huy hiệu bạc72 Huy hiệu đồngNov 20, 2015 at 15:34
Điều này làm việc tốt nhất cho tôi khi tôi chỉ muốn thay đổi một từ thành màu đỏ trong một câu.
<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>
Josh Lee
165K37 Huy hiệu vàng267 Huy hiệu bạc272 Huy hiệu Đồng11 gold badges102 silver badges76 bronze badges
Đã trả lời ngày 10 tháng 9 năm 2017 lúc 15:01Jun 19, 2016 at 11:23
2833 Huy hiệu bạc2 Huy hiệu đồng
<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>
Bạn cũng có thể tạo một lớp học:
Sau đó, trong một tệp CSS làm:Nov 17, 2015 at 19:51