How to Make Text Bold in HTML

How do I make text bold in HTML?

use <strong> or <b> tag

also, you can try with css <span style="font-weight:bold">text</span>

How do I style this text to be bold?

You can use CSS to achieve this using the font-weight property.

<center style="color: black; font-weight: bold;">
Free Shipping & Returns
<center>

Red and Bold Text in Html

You do it like this in HTML with some CSS styling:

Please Google before asking next time and read StackOverflow how to ask questions:how to ask a good question Stackoverflow Good luck with your coding!

<b style='color:red;'>English</b>

How to make the text in the button bold?

You've placed bold in your comma-separated list of font names, so if there isn't a generic sans-serif font available it will look for one named bold.

See the documentation for font. Order matters.

Put bold at the front of the list of properties in the shorthand.

.auth_subm {  height: 20pt;  width: 130pt;  font: bold 10pt Arial, Helvetica, sans-serif;  margin: 2pt;  margin-right: 0px;  text-align: center}
<input value="how get answers" type="button" onclick="location.href='otv.html'" class="auth_subm" />

Making a text bold using DOM Events

The problem is you are changing the input.value to bold. You can't style the input.value you should directly change the input style.

Also, you can't use the input.value = it is not built-in function like toUpperCase, it is style.

Use input.value.style.fontWeight may work, but you need to apply it back which click on other element which is messy. The easiest way is to <b> so you don't have to worry to change it back.

Also, I problem I have to mentioned, you should declare the input value inside the function, you declare it at the beginning which will always be empty since you assign the value at page loading.

let text = document.getElementById("text")
let input = document.getElementById("type")
let button1 = document.getElementById("button1")
let button2 = document.getElementById("button2")
let button3 = document.getElementById("button3")
let button4 = document.getElementById("button4")

button1.onclick = uppercase
button2.onclick = lowercase
button3.onclick = bold
//button4.onclick = italic

function uppercase() {
let value1 = document.getElementById("type").value
text.innerHTML = value1.toUpperCase()
}

function lowercase() {
text.innerText = input.value.toLowerCase()
}

function bold() {
text.innerHTML = '<b>'+input.value+'</b>'
}
<p id="text">Escreva seu texto abaixo</p>

<div id="container">
<input type="text" id="type">
</div>
<main>
<ul>
<li class="buttons">
<button id="button1">A</button>
</li>
<li class="buttons">
<button id="button2">a</button>
</li>
<li class="buttons">
<button id="button3">B</button>
</li>
<li class="buttons">
<button id="button4">I</button>
</li>
</ul>
</main>

Bold the selected text

It isn't possible to bold text inside of a textarea, however, it is possible to bold text inside of a div.

A div can behave like a textarea by setting it to contentEditable -- <div contentEditable></div>.

Conveniently, Javascript has a built in function to bold selected text, document.execCommand("bold").

By using both editable divs and Javascript built in functions, it is possible to create an app like Google Docs that can bold selected text.

document.getElementById("bold_button").onclick = function() {
document.execCommand("bold");
}
<div contentEditable id="text">
The World Before the Flood is an oil-on-canvas painting by English artist William Etty, first exhibited in 1828. It depicts a scene from John Milton's Paradise Lost in which Adam sees a vision of the world immediately before the Great Flood. The painting illustrates the stages of courtship as described by Milton: a group of men select wives from a group of dancing women, take their chosen woman from the group, and settle down to married life. Behind them looms an oncoming storm, a symbol of the destruction which the dancers and lovers are about to bring upon themselves. When first exhibited at the 1828 Royal Academy Summer Exhibition, the painting attracted large crowds. Many critics praised it, but others condemned it as crude, tasteless and poorly executed. The painting, currently in the Southampton City Art Gallery, and a preliminary oil sketch for it, now in the York Art Gallery, were exhibited together in a major retrospective of Etty's work in 2011 and 2012
</div>
<button id="bold_button">Bold</button>


Related Topics



Leave a reply



Submit