html black代码,HTML Black Code

HTML Black Code

This page contains HTML code for coloring an element black. Typically, you might be changing the color of text or the background color of that text or another element. But you can also use HTML color codes to change the color of an element's border.

Black Text

One way of setting black text is by using the HTML

tag along with the style attribute. This is called inline styles.

However, depending on how much text you need to color, you could apply the styles against a

tag (for all text within that element) or even the tag (for all text on the page).

Source CodeResult

Black text

Black text

Here's the same thing, but this time using embedded styles.

Source CodeResult

.blackText {color:black;}

Black text

Black text

You could also place the CSS code into a external style sheet.

Black Background Color

You can set the background color of an element to black by using the CSS background-color property or the background shorthand property. If you do this, you will need to ensure that any text (or foreground element) is not black, in order for it to be visible.

In this example, I've placed the text inside a

tag, set its background color to black, and set its text color to white.

Source CodeResult

White text, black background.

White text, black background.

Black Border Color

When you use CSS to create a border around an element, you need to specify the border's color.

In this example, I've specified that the

should have a dotted border with a color of black.

Source CodeResult

Normal text, but with a border around the div element.

Normal text, but with a border around the div element.

Black Color Codes

The above examples use black as the color value. I could just as easily used the hexadecimal or RGB color values and the result would've been the same.

Here are the various methods of specifying the color black in HTML.

Source CodeResult

Black text

Black text (hexadecimal #000000)

Black text (hexadecimal shorthand #000)

Black text (RGB value rgb(0,0,0))

Black text

Black text (hexadecimal #000000)

Black text (hexadecimal shorthand #000)

Black text (RGB value rgb(0,0,0))

Shades of Black

Here are some different shades of blacks & grays that can be used instead of just plain old "black".

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值