1

我试图在我的 Index.HTML 的一个段落中加粗和着色某些单词(或使它们成为斜体、不同大小等)。

但通常的格式化标签 (HTML) 不起作用。

我有一个 StyleSheet,其中包含我所有的网站样式和属性,但我只想更改段落中的三个单词(例如)。我该怎么做?

索引.html:

<div id="da-slider" class="da-slider">
    <div class="da-slide">
        <h2>This is the Heading</h2>
        <p>And HERE is where I want to make this word BOLD and this WORD in a different color, for example</p>
        <a href="#" class="da-link">Read more</a>
    <div class="da-img"><img src="img/pp-slider/imac.png" alt="image01" /></div>
</div>
4

5 回答 5

6

检查这个小提琴:这里

这是一个小例子。

我习惯<strong>Word</strong>让它变得大胆,但<b>Word</b>会做得很好。

用于<i></i>使单词斜体。我也曾经<span class="color">Word</span>把它弄成蓝色。

于 2013-05-15T07:47:32.517 回答
3

您可以通过预定义的 HTML 标签 strong、i、em 获得所需的结果,或者您可以设置单独的类以分配给不同的元素。

这是您可以保存并尝试的文档...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Untitled Document</title>
        <style>
            body {
                font-size:100%;
                font-family:arial;
            }

            .boldme {
                font-weight:bold;
            }

            .italicme {
                font-style:italic;
            }

            .iambigger {
                font-size:150%;
            }

            .colormered {
                color:#FF0000;
            }
        </style>
    </head>
<body>
    <div class="da-slide">
        <h2>This is the Heading</h2>
        <p>And <span class="iambigger">HERE</span> is where I want to make <span class="italicme">this</span> word <span class="boldme">BOLD</span> and this <span class="colormered">WORD</span> in a different color, for example.</p>
        <p>And by the way, <span class="boldme italicme iambigger colormered">I can have combinations of all</span></p>
        <a href="#" class="da-link">Read more</a>
        <div class="da-img">
            <img src="img/pp-slider/imac.png" alt="image01" />
        </div>
    </div>
</body>
</html>

如果您还需要了解其他信息,请告诉我...

于 2013-05-15T08:11:27.600 回答
1

将单词包裹在 a 中<span>,然后对其应用样式

HTML:

<p>And <span>HERE</span> is where I want to make this word <span>BOLD</span> and this <span>WORD</span> in a different color, for example</p>

CSS:

#da-slider p span{
    color:#F00;
    font-weight:bold;
}

看到这个小提琴

于 2013-05-15T07:46:07.780 回答
1

用法:

Bold : <b> 
Italic : <i>
Underline :  <u>

例子:

使文本<b>BOLD</b>

使文本<b><i>BOLD and ITALIC</i></b>

您还可以使用带跨度的 CSS:

例子 :

这使得文本<span>Bold and italic</span>

使用以下 CSS:

span {
    font-weight: bold;
    font-style: italic;
}
于 2013-05-15T07:49:05.877 回答
0

这是解决方案

的HTML:

<div id="da-slider" class="da-slider">
    <div class="da-slide">
        <h2>This is the Heading</h2>
        <p>And HERE is where I want to make this word <span>BOLD</span> and this <span>WORD</span> in a different color, for example</p>
        <a href="#" class="da-link">Read more</a>
    <div class="da-img"><img src="img/pp-slider/imac.png" alt="image01" /></div>
</div>
</div>

CSS:

.da-slide p span {
    font-weight: bold;
}

希望这可以帮助。

于 2013-05-15T08:18:55.683 回答