{"id":23985,"date":"2024-01-23T07:56:24","date_gmt":"2024-01-23T06:56:24","guid":{"rendered":"https:\/\/nelkodev.com\/blog\/fuentes-y-tipografias-para-textos-y-alineaciones-en-css\/"},"modified":"2024-06-03T17:34:02","modified_gmt":"2024-06-03T16:34:02","slug":"fuentes-y-tipografias-para-textos-y-alineaciones-en-css","status":"publish","type":"post","link":"https:\/\/nelkodev.com\/en\/blog\/fonts-and-typography-for-texts-and-alignments-in-css\/","title":{"rendered":"Fonts and typographies for texts and alignments in CSS"},"content":{"rendered":"<p>In web development, the choice of fonts and the correct alignment of texts are fundamental aspects to achieve an attractive and readable design. In this article, I&#039;ll show you how to use CSS to change the texts, spacing, and alignments of your web page.<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_80 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #ffffff;color:#ffffff\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #ffffff;color:#ffffff\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewbox=\"0 0 24 24\" version=\"1.2\" baseprofile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/nelkodev.com\/en\/blog\/fonts-and-typography-for-texts-and-alignments-in-css\/#Cambiar_textos_con_CSS\" >Change texts with CSS<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/nelkodev.com\/en\/blog\/fonts-and-typography-for-texts-and-alignments-in-css\/#Alinear_texto_en_HTML_y_CSS\" >Align text in HTML and CSS<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/nelkodev.com\/en\/blog\/fonts-and-typography-for-texts-and-alignments-in-css\/#Preguntas_frecuentes\" >Frequently asked questions<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/nelkodev.com\/en\/blog\/fonts-and-typography-for-texts-and-alignments-in-css\/#%C2%BFComo_puedo_cambiar_la_fuente_en_HTML\" >How can I change the font in HTML?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/nelkodev.com\/en\/blog\/fonts-and-typography-for-texts-and-alignments-in-css\/#%C2%BFComo_puedo_centrar_un_texto_en_HTML\" >How can I center text in HTML?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/nelkodev.com\/en\/blog\/fonts-and-typography-for-texts-and-alignments-in-css\/#%C2%BFComo_puedo_justificar_un_texto_en_HTML\" >How can I justify text in HTML?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/nelkodev.com\/en\/blog\/fonts-and-typography-for-texts-and-alignments-in-css\/#%C2%BFQue_otras_propiedades_puedo_utilizar_para_cambiar_los_estilos_de_los_textos_en_CSS\" >What other properties can I use to change text styles in CSS?<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Cambiar_textos_con_CSS\"><\/span>Change texts with CSS<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>When we create a web page, it is common that we want to customize the appearance of the texts. CSS allows us to change the font, size, color and other styles of the texts on our page. To do this, we use the property <code>font-family<\/code> to define the source, and the property <code>font-size<\/code> to set the text size.<\/p>\n<p>For example, if we want to use the font &quot;Arial&quot; and a text size of 16 pixels, we can use the following CSS code:<\/p>\n<pre>\nbody { font-family: Arial, sans-serif; font-size: 16px; }\n<\/pre>\n<p>This way, all text elements within the element <code>&lt;body&gt;<\/code> They will use the &quot;Arial&quot; font and a size of 16 pixels.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Alinear_texto_en_HTML_y_CSS\"><\/span>Align text in HTML and CSS<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Text alignment is another important aspect to improve the readability of our website. CSS offers us various properties to align the text in different ways.<\/p>\n<p>For example, if we want to center a text in HTML, we can use the property <code>text-align<\/code> with the value &quot;center&quot;. The following CSS code shows how to do it:<\/p>\n<pre>\n.centered-text { text-align: center; }\n<\/pre>\n<p>When you apply this class to an HTML element, the text within that element will be centered horizontally.<\/p>\n<p>In addition to centering, we can also justify the text using the property <code>text-align<\/code> with the value &quot;justify&quot;. This option distributes the text evenly along the line, creating aligned margins on both sides.<\/p>\n<p>For example:<\/p>\n<pre>\n.justified-text { text-align: justify; }\n<\/pre>\n<p>With this code, the text inside the element with class &quot;justified-text&quot; will be justified along the line.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Preguntas_frecuentes\"><\/span>Frequently asked questions<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"%C2%BFComo_puedo_cambiar_la_fuente_en_HTML\"><\/span>How can I change the font in HTML?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>You can change the font in HTML using CSS. To do this, define the property <code>font-family<\/code> on the element you want to modify. For example:<\/p>\n<pre>\nh1 { font-family: &quot;Roboto&quot;, sans-serif; }\n<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"%C2%BFComo_puedo_centrar_un_texto_en_HTML\"><\/span>How can I center text in HTML?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>To center text in HTML, use the property <code>text-align<\/code> with the value &quot;center&quot; in the element containing the text. For example:<\/p>\n<pre>\n&lt;div style=&quot;text-align: center;&quot;&gt;Centered text&lt;\/div&gt;\n<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"%C2%BFComo_puedo_justificar_un_texto_en_HTML\"><\/span>How can I justify text in HTML?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>To justify text in HTML, use the property <code>text-align<\/code> with the value &quot;justify&quot; in the element containing the text. For example:<\/p>\n<pre>\n&lt;p style=&quot;text-align: justify;&quot;&gt;Justified text&lt;\/p&gt;\n<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"%C2%BFQue_otras_propiedades_puedo_utilizar_para_cambiar_los_estilos_de_los_textos_en_CSS\"><\/span>What other properties can I use to change text styles in CSS?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>In addition to <code>font-family<\/code> y <code>font-size<\/code>, you can use properties like <code>color<\/code> for text color, <code>font-weight<\/code> for font thickness, <code>text-decoration<\/code> to add decorations to the text (such as underlining), among others.<\/p>\n<p>In conclusion, fonts and text alignments are essential aspects for the design of a web page. With CSS, we can change the styles of the texts and align them appropriately. Use these techniques to create more attractive and readable web pages.<\/p>","protected":false},"excerpt":{"rendered":"<p>En el desarrollo web, la elecci\u00f3n de las fuentes y la correcta alineaci\u00f3n de los textos son aspectos fundamentales para lograr un dise\u00f1o atractivo y legible. En este art\u00edculo, te mostrar\u00e9 c\u00f3mo utilizar CSS para cambiar los textos, espacios y alineaciones de tu p\u00e1gina web. Cambiar textos con CSS Cuando creamos una p\u00e1gina web, es [&hellip;]<\/p>","protected":false},"author":1,"featured_media":23986,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[420,1121],"tags":[1156,205,519,815,60,1155,814],"class_list":["post-23985","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","category-css","tag-alineaciones","tag-blog","tag-css","tag-fuentes","tag-para","tag-textos","tag-tipografias"],"_links":{"self":[{"href":"https:\/\/nelkodev.com\/en\/wp-json\/wp\/v2\/posts\/23985","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nelkodev.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nelkodev.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nelkodev.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nelkodev.com\/en\/wp-json\/wp\/v2\/comments?post=23985"}],"version-history":[{"count":0,"href":"https:\/\/nelkodev.com\/en\/wp-json\/wp\/v2\/posts\/23985\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nelkodev.com\/en\/wp-json\/wp\/v2\/media\/23986"}],"wp:attachment":[{"href":"https:\/\/nelkodev.com\/en\/wp-json\/wp\/v2\/media?parent=23985"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nelkodev.com\/en\/wp-json\/wp\/v2\/categories?post=23985"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nelkodev.com\/en\/wp-json\/wp\/v2\/tags?post=23985"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}