Html textarea жирный шрифт

How do I make text bold in HTML?

I’m trying to make some text bold using HTML, but I’m struggling to get it to work. Here’s what I’m trying:

Some text that I want emboldened. 

I agree that it should be searched on google first, but I think the point is next time someone searches google, she/he will be directed to SO, which I see as good thing. More traffic and people coming on SO.

@binfolder might want to say whether or not he learned from Google. Another, more general possibility: more and more people are developing without school, and without reading books. We learned this stuff on «day one» or «day two» of «HTML 101». They don’t have scheduled classes.

@Andrija: I agree about directing them here. This is why my answer directed them back to a place where they can learn the answer to the next question: «how do I do italic?»

10 Answers 10

HTML doesn’t have a tag, instead you would have to use . Note however, that using is discouraged in favor of CSS for a while now. You would be better off using CSS to achieve that.

has never been deprecated. Recommended against in favor of , , , etc., yes; deprecated, no.

Why should using be discouraged in favor of CSS? That’s like saying using is discouraged in favor of CSS. It’s in the standard so use it.

Gumbo: From w3.org/TR/html4/present/graphics.html#h-15.2.1 – «The following HTML elements specify font information. Although they are not all deprecated, their use is discouraged in favor of style sheets.»

Actually those elements are making a comeback in HTML 5 as «phrase elements» — for example symbolises small print, while is to be used for book titles, I think.

I'm Bold! and I'm Bold Too! 

From: http://www.december.com/html/x1/

This element encloses text which should be rendered by the browser as boldface. Because the meaning of the B element defines the appearance of the content it encloses, this element is considered a «physical» markup element. As such, it doesn’t convey the meaning of a semantic markup element such as strong.

Description This element brackets text which should be strongly emphasized. Stronger than the em element.

  • Some text that I want emboldened.
  • Some text that I want emboldened.

Could someone tell me what I’m doing wrong?»

«bold» has never been an HTML element («b» is the closest match).

HTML should contain structured content; publisher CSS should suggest styles for that content. That way user agents can expose the structured content with useful styling and navigational controls to users who can’t see your suggested bold styling (e.g. users of search engines, totally blind users using screen readers, poorly sighted users using their own colors and fonts, geeky users using text browsers, users of voice-controlled, speaking browsers like Opera for Windows). Thus the right way to make text bold depends on why you want to style it bold. For example:

  • Want to distinguish headings from other text? Use heading elements («h1» to «h6») and suggest a bold style for them within your CSS («h1, h2, h3, h4, h5, h6 «.
  • Want to embolden labels for form fields? Use a «label» element, programmatically associate it with the the relevant «select», «input» or «textarea» element by giving it a «for» attribute matching an «id» attribute on the target, and suggest a bold style for it within your CSS («label ).
  • Want to embolden a heading for a group of related fields in a form, such as a group of radio choices? Surround them with a «fieldset» element, give it a «legend» element, and suggest a bold style for it within your CSS («legend «).
  • Want to distinguish a table caption from the table it captions? Use a «caption» element and suggest a bold style for it within your CSS («caption «).
  • Want to distinguish table headings from table data cells? Use a «th» element and suggest a bold style for it within your CSS («th «).
  • Want to distinguish the title of a referenced film or album from surrounding text? Use a «cite» element with a class («cite ), and suggest a bold style for it within your CSS («.movie-title «).
  • Want to distinguish a defined keyword from the surrounding text defining or explaining it? Use a «dfn» element and suggest a bold style for it within your CSS («dfn «).
  • Want to distinguish some computer code from surrounding text? Use a «code» element and suggest a bold style for it within your CSS («code «).
  • Want to distinguish a variable name from surrounding text? Use a «var» element and suggest a bold style for it within your CSS («var «).
  • Want to indicate that some text has been added as an update? Use an «ins» element and suggest a bold style for it within your CSS («ins «).
  • Want to lightly stress some text («I love kittens!»)? Use an «em» element and suggest a bold style for it within your CSS (e.g. «em «).
  • Want to heavily stress some text, perhaps for a warning («Beware the dog!«)? Use a «strong» element and suggest a bold style for it within your CSS (e.g. «strong «).

… You get the idea (hopefully).

Can’t find an HTML element with the right semantics to express /why/ you want to make this particular text bold? Wrap it in a generic «span» element, give it a meaningful class name that expresses your rationale for distinguishing that text («Let me begin this news article with a sentence that summarizes it.), and suggest a bold style for it within your CSS («.lede . Before making up your own class names, you might want to check if there’s a microformat (microformats.org) or common convention for what you want to express.

Источник

HTML тег

Между открывающим тегами можно поместить любой текст, который будет отображаться моноширинным начертанием. В текстовое поле можно вводить любое количество символов.

Синтаксис

Содержимое элемента заключается между открывающим () тегами.

Для определения размера текстового поля можно использовать атрибуты cols и rows , или же использовать CSS свойства height и width . А с помощью CSS свойства resize можно запретить изменение размера текстового поля.

Пример

html> html> head> title>Заголовок документа title> head> body> form> textarea name="comment" rows="12" cols="35">Написать комментарий автору. textarea>br> input type="submit" name="submitInfo" value="Отправить"> form> body> html>

Результат

textareaexample1

В этом примере мы определили текстовую область тегом , присвоили ей имя “comment”, использовав атрибут name ; задали высоту строк (12 символов) атрибутом rows и указали ширину поля атрибутом cols (35 символов). Мы также разместили внутри формы кнопку, при нажатии на которую введенная информация отправляется на сервер.

Пример

html> html> head> title>Заголовок документа title> style> .comment < width: 60%; height: 100px; padding: 10px; outline: 0; border: 3px solid #1c87c9; background: #d0e2bc; line-height: 20px; > style> head> body> form> p>Пример с использованием CSS стилей p> textarea class="comment"> Написать комментарий автору. textarea> br> input type="submit" name="submitInfo" value="Отправить"> form> body> html>

Результат

textareaexample2

В этом примере мы использовали CSS стили для визуального оформления текстового поля.

Атрибуты

Атрибут Значение Описание
autocomplete on
off
Определяет, может ли содержимое элемента быть автоматически дополнено браузером (автозаполнение).
autofocus autofocus Указывает, что текстовая область должна автоматически получать фокус при загрузке страницы.
cols number Определяет видимую ширину текстовой области (в символах). Значение по умолчанию 20 символов.
dirname textareaname.dir Определяет и передает на сервер направление текста.
disabled disabled Логический атрибут, указывающий, что текстовая область должна быть отключена.
form form_id Определяет одну или несколько форм, к которым принадлежит элемент и связывает их при помощи идентификатора (id).
maxlenght number Указывает максимальное количество символов, которое может содержать текстовая область.
minlength number Указывает минимальное количество символов, которое может содержать текстовая область.
name text Определяет имя текстового поля.
placeholder text Указывает текст подсказки, которая описывает ожидаемое значение для ввода пользователем в элемент. Подсказка отображается в пустом текстовом поле, и исчезнет при получение им фокуса.
readonly readonly Указывает, что текстовая область доступна только для чтения.
required required Логический атрибут, указывающий, что текстовая область должна быть заполнена перед отправлением формы.
rows number Определяет видимое количество строк в текстовой области. Значение по умолчанию 2 символа.
wrap Определяет, как текст должен быть перенесен, когда отправляется форма.
soft -(значение по умолчанию) текст отправляется одной сплошной строкой без добавления дополнительных переносов строк.
hard -браузер автоматически вставляет разрывы строки так, что каждая строка не будет шире текстового поля. Используется только если установлен атрибут cols.

Как добавить стиль к тегу ?

Распространенные свойства для изменения визуальной насыщенности/выделения/размера текста внутри тега :

  • CSS свойство font-style задает стиль шрифта: normal | italic | oblique | initial | inherit
  • CSS свойство font-family создает приоритетный список названий семейства шрифтов и/или общее имя шрифтов для выбранных элементов.
  • CSS свойство font-size задает размер щрифта.
  • CSS свойство font-weight устанавливает насыщенность шрифта.
  • CSS свойство text-transform задает регистр текста (заглавные или строчные буквы).
  • CSS свойство text-decoration устанавливает оформление текста. Оно является сокращенным свойством для text-decoration-line, text-decoration-color, text-decoration-style.

Цвет текста внутри тега :

Стили форматирования текста для тега :

  • CSS свойство text-indent указывает размер отступа первой строки в текстовом блоке.
  • CSS свойство text-overflow указывает, как будет отображаться пользователю строчный текст, выходящий за границы блока.
  • CSS свойство white-space указывает, как будут отображены пробелы внутри элемента.
  • CSS свойство word-break указывает перенос строки.

Другие свойства для тега :

  • CSS свойство text-shadow добавляет тень к тексту.
  • CSS свойство text-align-last выравнивает последнюю строку текста.
  • CSS свойство line-height устанавливает межстрочный интервал.
  • CSS свойство letter-spacing устанавливает расстояние между буквами/символами в тексте.
  • CSS свойство word-spacing устанавливает расстояние между словами в тексте.

Источник

How can I display bold text in a textarea? [closed]

It’s difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.

It displays the raw HTML code. Instead, I would like it to simply display bold text. How can I achieve that?

@Devjosh guess he just copypasted random words to fill up some contect, other wise the same error comes if the question is a small one

@footy hmm now i see there are changes in the validations when you post a question but what is this mess that xujinliang pasted in question

@footy, it feels bad when people ask for help and don’t even bothered to make their question clear and with such a lazy and irresponsible way

I’m pretty sure the question should be «I want bold text in a textarea. But with my first code the text in the textarea is test . How can I make the textarea display the ‘bold’ effect?»

2 Answers 2

If you want the textarea to display bold text, you can do that via css style attribute:

This makes the textarea display all text bold, as it would be in text .

However, this affects all text in the textarea. There is no way to show only one word in bold.

@Devjosh You’re right, but I don’t believe the OP will read, understand and follow the comments to the original question right now, but rather will be frustrated. Getting help and not only being downvoted and laughed at may turn his attention to the problem of his bad phrasing, too.

In order to display styled HTML instead of the pure HTML code inside a textarea, you need a JavaScript WYSIWYG editor. You can choose from many different ones, I can think of two right now: CKEditor and TinyMCE, though you can find many more. Please refer to the documentation of each one to learn about how to integrate it in your application. Read the information on their websites to decide which one suits you best.

Just to let you have a quick start, here’s an example of how to easily integrate the ones I mention.

CKEditor

First, place the downloaded CKEditor package in your application’s document root, so that you can access the file /ckeditor/ckeditor.js.

On the page with the textarea, add this code:

Finally, make sure the textarea in question has the wysiwyg class:

TinyMCE

Again, download the package and put it somewhere in the docroot, so that the file /tinymce/tiny_mce.js is accessible.

Add this piece of code in the file containing the textarea:

If you’ve set everything up correctly, you should get a WYSIWYG editor instead of the textarea, displaying all your styles.

Источник

Читайте также:  Время вычисления программы питон
Оцените статью