<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by German Asmus on Medium]]></title>
        <description><![CDATA[Stories by German Asmus on Medium]]></description>
        <link>https://medium.com/@germanasmusmaher?source=rss-72083677b473------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*-S12fLiZHd6o4aZMnivRBg.jpeg</url>
            <title>Stories by German Asmus on Medium</title>
            <link>https://medium.com/@germanasmusmaher?source=rss-72083677b473------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 00:20:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@germanasmusmaher/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[El coraje se encuentra contigo, siempre]]></title>
            <link>https://germanasmusmaher.medium.com/el-coraje-se-encuentra-contigo-siempre-c6092bfddc33?source=rss-72083677b473------2</link>
            <guid isPermaLink="false">https://medium.com/p/c6092bfddc33</guid>
            <category><![CDATA[crecimiento-personal]]></category>
            <category><![CDATA[bienestar]]></category>
            <category><![CDATA[reflecciones]]></category>
            <category><![CDATA[autoayuda]]></category>
            <category><![CDATA[coraje]]></category>
            <dc:creator><![CDATA[German Asmus]]></dc:creator>
            <pubDate>Mon, 06 Mar 2023 03:26:46 GMT</pubDate>
            <atom:updated>2023-03-06T03:26:46.573Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1rTkJmNm2_TlaVBG" /><figcaption>Photo by <a href="https://unsplash.com/@t_mallp_rt?utm_source=medium&amp;utm_medium=referral">Tom Allport</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Libera la fortaleza que tienes dentro, sortea los obstáculos que te detienen, sé el protagonista de tu historia.</h4><p>Mira donde estás parado. Observa lo que tienes en frente. ¿Puedes ver cómo el llano se extiende a lo largo y a lo ancho, y que, a lo lejos en el horizonte nace y muere el sol? El tiempo sigue avanzando.</p><p>Te aconsejo que eches a andar. <em>“¿Hacia dónde ir?”</em>,<em> </em>dirás. Pues, ve donde encuentres un verdadero desafío; un río que cruzar, una montaña que rodear, un enemigo con quien luchar. <em>“¿Y por qué querría enfrentarme a un enemigo?”</em>, contestarás.</p><p>Eres el protagonista de tu propia historia. ¿Y, aun así, piensas quedarte de brazos cruzados? No hay relato en la haraganía o en el rigor.</p><p>¿Qué contarás a los demás sobre ti? Si no hay hazañas, ni proezas, ni nada de lo que te puedas jactar. ¡Avanza! Aunque sea con miedo. No eres de cristal, pero tampoco necesitas un temple de acero para hacerle frente al porvenir. Solo necesitas ser lo que eres, entender lo que puedes hacer con lo que tienes.</p><p>Aprende que la valentía está siempre allí, contigo, en la decisión que tomes y en la acción que le preceda. En tomar la oportunidad, y en ese camino encontraras el significado de responsabilidad, lo que conlleva ser el protagonista, al final notaras lo que has logrado y que has vencido.</p><p>¿Qué te detiene de hacer lo que quieres? ¿Esperas que se te den todos tus deseos? Debes salir al mundo, aventurarte, aprender de otros, equivocarte, acertar. Sal de tu zona de confort. Parafraseando a J.R.R Tolkien: “No todo el que vaga está perdido”, echa a andar, en cualquier dirección, luego encontrarás el curso.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c6092bfddc33" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript overview — using flat and flatMap]]></title>
            <link>https://germanasmusmaher.medium.com/javascript-overview-using-flat-and-flatmap-f0d5daaae985?source=rss-72083677b473------2</link>
            <guid isPermaLink="false">https://medium.com/p/f0d5daaae985</guid>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[vanilla-javascript]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[German Asmus]]></dc:creator>
            <pubDate>Mon, 11 Jan 2021 19:54:11 GMT</pubDate>
            <atom:updated>2021-01-11T20:35:53.276Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N8nPVI4yZmxeaRPforkGeA.png" /></figure><h3>JavaScript overview — using flat and flatMap</h3><p>With the aims of productivity, let skip the introduction of a new problem by starting with the e-commerce use case presented in the previous post <em>(</em><a href="https://germanasmusmaher.medium.com/javascript-overview-using-reduce-map-and-find-e35664acfcd4"><em>JavaScript overview — using filter, map, and reduce</em></a><em>)</em>and the business requirements we left undone. As we know, the plain data structure we are working with goes as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3Gnhv3uQ7zgJuclH" /></figure><p>Now we are assigned to the requirement presented below, and we can solve it by using as many approaches as we want, but take in mind our main task would be to use the flat and flatMap functions.</p><p><strong>For the order whose total value exceeds $5500.00 apply the 5% discount over the entire buy.</strong></p><p>Taking a look at the data model, to get the total of the order we should seek the prices of every product by the quantity specified on the line item.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rV7ZCEUGZqY-I1fG" /></figure><h4><strong>Flattening</strong></h4><p>Flattening an array means to take an array with items (first level) that may contain at least one sub-array as a child (second level) and subsequently, this last child could have a few children (third level) until the innermost array ends with the offspring chain (i-est level).</p><p>Suppose we have a multilevel array with numbers, where we don’t care about its distribution or its contextual meaning:</p><pre>[-2, [2, [30, 24], 15, 20], [99], 21, 5, [10, [66], 0]]</pre><p>With little effort, we can take the elements by their corresponding level. At the first level (topmost) we have [-2, 21, 5], on the second level items are [2, 15, 20, 99, 10, 0], and at the third level (the innermost) the items left are [30, 24, 66].</p><p>The task now is to flatten the levels of the array to obtain a new array where every item stands at the top. As a result we must have [-2, 2, 30, 24, 15, 20, 99, 21, 5, 10, 66, 0].</p><p>The way we afford this kind of task on JavaScript is by calling the function <strong>flat</strong> which simplifies our work just with an optional argument that tells how many levels to flat (or none, implicitly taken as a first-level flattening).</p><pre>[-2, [2, [30, 24], 15, 20], [99], 21, 5, [10, [66], 0]].flat(2);<br>//[-2, 2, 30, 24, 15, 20, 99, 21, 5, 10, 66, 0]</pre><p>If no argument is provided, the flat function would just work over the zero and first level of the array.</p><pre>[-2, [2, [30, 24], 15, 20], [99], 21, 5, [10, [66], 0]].flat();<br>//[-2, 2, [30, 24], 15, 20, 99, 21, 5, 10, [66], 0]</pre><p>To summarize, the <strong>flat</strong> function takes an optional argument and returns a new array as a result of the transformations made to the original array.</p><pre>flat([<strong>depth</strong>]);</pre><ol><li>the <strong>depth</strong> defines how many levels must be flattened.</li></ol><p>On the other hand, the <strong>flatMap</strong> function can perform the flattening after mapping each item over the array, but here the flattening is always at the first level. With this constraint, we are incapable of doing certain tasks <strong>flat</strong> function does.</p><pre>[-2, [2, [30, 24], 15, 20], [99], 21, 5, [10, [66], 0]]<br>.flatMap(item =&gt; item * 2);<br>//[-4, NaN, 198, 42, 10, NaN]</pre><p>The flatMap would try to apply the mapping to the current item on the array, as the example above, the items that are not numbers can not be multiplied by 2 returning a “Not A Number” value on the place where we used to have a sub-array.</p><p>The <strong>flatMap</strong> function takes at the most two arguments and it applies the mapping and the consequent flattening to the original array returning a new one with the corresponding transformations.</p><pre>flatMap(callback(<strong>current </strong>[, <strong>index</strong>]){});</pre><ol><li>the current item being processed the moment</li><li>the index of the current value</li></ol><h4>Further reading</h4><p>If you are interested in the subject, I let you here some useful links to start your JavaScript journey.</p><ul><li><a href="https://exploringjs.com/es2018-es2019/ch_array-prototype-flat-flatmap.html">https://exploringjs.com/es2018-es2019/ch_array-prototype-flat-flatmap.html</a></li><li><a href="https://codeburst.io/how-to-flatten-a-nested-javascript-array-628e01b85512">https://codeburst.io/how-to-flatten-a-nested-javascript-array-628e01b85512</a></li><li><a href="https://www.youtube.com/watch?v=8JJGPCYBW5o&amp;ab_channel=AllThingsJavaScript%2CLLC">https://www.youtube.com/watch?v=8JJGPCYBW5o&amp;ab_channel=AllThingsJavaScript%2CLLC</a></li></ul><p><strong>Thanks for reading! </strong>I hope you enjoyed the article, I will try to upload new content periodically.</p><p>Please, let me know if you like the article by leaving a comment or by clicking on the 👏 button. Also, you can follow me on <a href="https://germanasmusmaher.medium.com/">Medium</a>, <a href="https://twitter.com/AsmusGerman">Twitter</a>, and <a href="http://www.linkedin.com/in/german-asmus">LinkedIn</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f0d5daaae985" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Javascript overview — using reduce, map and find]]></title>
            <link>https://germanasmusmaher.medium.com/javascript-overview-using-reduce-map-and-find-e35664acfcd4?source=rss-72083677b473------2</link>
            <guid isPermaLink="false">https://medium.com/p/e35664acfcd4</guid>
            <category><![CDATA[vanilla-javascript]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[German Asmus]]></dc:creator>
            <pubDate>Mon, 09 Nov 2020 20:15:09 GMT</pubDate>
            <atom:updated>2021-01-11T14:14:49.940Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uLznskCZEXw5l5S0GLgTaA.png" /></figure><h3>Javascript overview — using filter, map, and reduce</h3><p>Talking from my empirical point of view, the functional way in JavaScript fits incredibly well for many common use cases we can afford in the real world.</p><p>Like many others, I make use of the imperative paradigm with ordinary coding blocks like the conditional and iterative ones, however, the JavaScript language gives us the tools for solving things the easier and the faster way. But before taking action, it’s always better if you know your stuff.</p><p>Let’s suppose that a given use case comes up with a large array of some kind of complex object, like an e-commerce order with several properties.</p><p>The data we are going to work with follows the structure shown in the figure below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9qnsEGLGPoVGYtuq" /></figure><p>For those who feel more comfortable with a class diagram than with a plain object structure, we can model it as follows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/0*p_nCxCr1qPBdgKiB" /></figure><p>As always, requirements came to our hands. Here we are given a typical listing of functionalities like:</p><ul><li><a href="http://medium.com/p/e35664acfcd4#e98e">retrieve which products are in stock and which are not by labeling them as <em>available</em> and <em>out of stock</em> respectively.</a></li><li>there couldn’t be any line item for unstocked products. So, at the time of picking the saleable items from the list, those which are not available must be disabled.</li><li>retrieve the total of the order.</li><li>etc…</li></ul><p>And some business requirements may apply to some specific situations:</p><ul><li>no item line should exceed the maximum of 10 units.</li><li>if an item line reaches the maximum quantity, the last item is free.</li><li>for the order whose total value exceeds $5500.00 apply the 5% discount over the entire buy.</li><li>etc…</li></ul><p>Taking place on the problem and assuming that the current dataset we are working on has already been given, then we can start solving the requirements as follows:</p><h4><strong>Retrieve which products are in stock and which are not by labeling them as <em>available</em> and <em>out of stock</em> respectively.</strong></h4><p>As we already know, our data source is an array of orders and each one has an inner array of line items that describes the amount of a certain product offered by the e-commerce shop. The goal is to reach the <em>stock</em> property on the product to do the corresponding labeling.</p><p>Taking in mind the requirement does not specify the structure of the result, we can return an array of objects describing the product we have just processed and its corresponding label.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ah54Ah2-2KPz9FUl" /></figure><h4><strong>Reduction</strong></h4><p>The reduction is the process of converting an expression to a simpler form. By having an expression, the reduction process will produce the only possible answer.</p><pre>(5 + (2 + 10)) → (5 + 12) → 17</pre><p>The same occurs with JavaScript, a <em>reducer function</em> is required when calling to <strong>reduce</strong> to produce the reduction result. Taking the same example as above:</p><pre>[5, 2, 10].reduce((total, current) → total + current, 0); //17</pre><p>The function provided (better known as <em>callback</em>) takes four arguments:</p><pre>reduce(callback(<strong>accumulator</strong>, <strong>current </strong>[, <strong>index</strong>]){}[,<strong>initialValue</strong>]);</pre><ol><li>the <strong>accumulator</strong>, where the last reduced result is stored</li><li>the <strong>current value</strong>, which is the next value to be processed</li><li>the <strong>index</strong> of the current value</li><li>the <strong>initial value</strong></li></ol><h4><strong>Mapping</strong></h4><p>The mapping process does the projection from the current domain to a different one. The thing is, to map is doing the switching between domains applying a transformation function which takes an element from the first context and returns a new element corresponding to the second context.</p><p>Let’s say we need to capitalize a list of names.</p><pre>[“joe”, “bob”, “rose”].map((name) =&gt; <em>utility</em>.capitalize(name)); //[“Joe”, “Bob”, “Rose”]</pre><p>Calling the <strong>map</strong> function requires a <em>callback</em> which takes two arguments:</p><pre>map(callback(<strong>current </strong>[, <strong>index</strong>]){});</pre><ol><li>the <strong>current value</strong> to be transformed</li><li>the <strong>index </strong>of the current value</li></ol><p>Suppose the requirement we have just resolved accomplished the specified by the business, but suddenly an order appears without line items or some line item shows some quantity and none product is related. Will the code survive to this unexpected situation?</p><p>The concept of preventive programming is not commonly known but its usage does, furthermore the idea of preventing a future disaster comes to our minds forcing us to write some extra code. In this case, we forgot to consider the worst scenario and now we have to fix it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ax6Hb_5rRNiGM4NK" /></figure><p>As we know the causes of the problems, the solution is simple. First, we need to take out the orders with no line items. After that, remove the line items that have no product related.</p><p>To do this, make use of the <strong>filter </strong>function which takes a filtering expression that must return a boolean on each evaluation. The required <em>callback</em> takes two arguments:</p><pre>filter(callback(<strong>current </strong>[, <strong>index</strong>]){});</pre><ol><li>the <strong>current value</strong> to be evaluated</li><li>the <strong>index</strong> of the current value</li></ol><p>And with this fix, no order should appear without line items and no line item should be processed if it has not a related product.</p><p>Hey, <strong>thanks for reading! </strong>This is the first article from a series where I am going to resolve some of the requirements listed before, using a similar approach and improving the examples with more accurate solutions. Just saying, the code here can be improved (even with other JavaScript functions), the goal is to show the usage of reduce, map and filter.</p><p>Please, let me know if you like the article by leaving a comment or clicking on the 👏 button.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e35664acfcd4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Comenzando con CSS]]></title>
            <link>https://germanasmusmaher.medium.com/comenzando-con-css-2d013ac8537d?source=rss-72083677b473------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d013ac8537d</guid>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[web]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[style]]></category>
            <category><![CDATA[blog]]></category>
            <dc:creator><![CDATA[German Asmus]]></dc:creator>
            <pubDate>Tue, 07 May 2019 04:55:43 GMT</pubDate>
            <atom:updated>2020-11-09T18:14:17.421Z</atom:updated>
            <content:encoded><![CDATA[<p>Al hablar de CSS, estamos sintetizando las palabras <em>hoja de estilos en cascada</em> (del ingles, Cascading Style Sheet), mientras que por otro lado, sabemos que sirve para especificar cómo deberán presentarse los documentos HTML, en cuanto a la disposición de sus elementos, colores, tipografías, formas, transiciones, animaciones y otros efectos.</p><p>Cuando abrimos un documento HTML, el navegador se debe resolver ciertas cuestiones, antes de que el usuario pueda visualizar correctamente el documento estilizado. Por lo general, <em>pueden existir varias fuentes de estilo</em>, lo que nos lleva suponer que <em>existe una manera de proceder.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/409/1*73raNRE-ZLbH2GEK-GBjKw.png" /></figure><p>Los estilos pueden definirse en archivos con extensión .css o pueden estar embebidos en el documento HTML. En el primer caso, los archivos se deberán invocar a partir de un elemento <em>link</em> en el cual se especifica la URL de locación de la fuente.</p><pre>&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;theme.css&quot;&gt;</pre><p>Mientras que para el segundo caso, existen varias formas de que se comentarán más adelante.</p><p>Por otro lado, los navegadores incorporan sus propias hojas de estilos (que son utilizadas por defecto), y a su vez, omiten aquellos estilos que no puedan resolver, evitando que tengamos que tratar con el manejo de errores.</p><p>Todo esto se debe a que CSS se define bajo el término de <strong>cascada </strong>porque <em>trabaja con reglas en base a un orden de prioridad</em>, lo que da lugar a suponer en un principio, dos cosas:</p><ol><li>En algún lugar hay reglas, que existen o que hay que definir.</li><li>Que las reglas siguen un orden de prioridad, por el cual una regla es más preponderante que otra.</li></ol><p>Y quien interprete todas estas reglas será el navegador.</p><h3>Reglas</h3><p>Las reglas son el <em>cómo</em> de todo este universo y para entenderlas, debemos entrar en el campo más técnico de CSS, definiendo lo que son y cómo se componen:</p><ul><li><em>Una</em> <em>hoja de estilos es un conjunto de una o más reglas que se aplican a un documento HTML</em></li><li><em>Una regla se compone de un selector y al menos una declaración</em></li><li><em>Una declaración se compone de una propiedad y un valor</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*rGeP76Rnx_-YxQzEWPi6-A.png" /></figure><p>La sintaxis de una regla básica en CSS sigue un modelo, donde se especifica primero el selector y luego el cuerpo entre llaves. Dentro, la declaración se indica con una propiedad seguida de dos puntos y un valor, terminando la sentencia con un punto y coma.</p><p>Una regla de mayor complejidad, podría contar con múltiples selectores y múltiples declaraciones. CSS nos permite <strong>agrupar selectores y declaraciones</strong>, y este es un punto fuerte del cual nos podemos abrazar para hacer pequeñas hojas de estilo con mucha personalidad.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*smAihsTGGFCXQfWqLxZVhQ.png" /></figure><h4>La prioridad de las reglas</h4><p>En CSS ocurre una “competencia entre reglas”, que el intérprete deberá resolver en base a ciertos criterios bien definidos. Una hoja de estilos puede tener reglas que compitan entre sí, como así también puede ocurrir una competencia entre reglas de distintas hojas de estilo.</p><p>Al momento de diseñar nuestra hoja de estilos, tenemos que tener en cuenta cuáles son los factores que hacen a las reglas que definimos, más o menos prioritarias.</p><p>Un modelo general que explica el orden de prioridad de las reglas sería el siguiente:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/281/1*lUWm6NiXtLxejXGNMrcp-A.png" /></figure><ol><li><strong>!Important</strong> es una palabra reservada que se aplica en una declaración y significa que dicho estilo es el más prioritario, sobre las declaraciones que apliquen a la misma propiedad del mismo selector.</li><li>Los estilos <strong>inline</strong> son aquellos que por alguna razón de diseño se prefiere declarar directamente en el documento HTML bajo la propiedad <em>style</em> de un elemento HTML.</li><li>Si bien <strong>media</strong> es un concepto avanzado para este post, prácticamente se utiliza para declarar estilos que se activan bajo ciertas condiciones. Se suele usar mucho para manejar distintas resoluciones de pantalla.</li><li>En este punto, hay que separar la idea de quién es el <strong>usuario</strong> y quién es el <strong>diseñador</strong>. Por un lado, quien elabora los estilos del documento HTML es el diseñador, que existe en un tiempo previo al usuario. En cambio, el usuario existe en el mismo momento en que se está viendo el documento estilizado (o a lo que se llama comúnmente, <em>página web renderizada</em>). Si hacemos una analogía, podemos ver que hay un rol de <em>productor </em>y otro de <em>consumidor</em>.</li><li>Aquí es donde toman fuerza las reglas de las hojas de estilo definidas por el diseñador, y son estas las que sobrescriben las reglas heredadas provistas por el navegador en las fuentes de estilo por defecto. La especificidad de los selectores aplicará más o menos prioridad a la regla.</li><li>Este caso lo encontraremos muy visible en las hojas de estilo que vayamos definiendo. El orden de las reglas es un mecanismo muy útil para darnos idea de por qué algunas declaraciones pueden parecernos no tener ningún efecto sobre el estilo que queremos especificar. Su funcionamiento se puede resumir diciendo que <strong>la última regla tiene la mayor prioridad</strong>.</li><li>En cuanto a la herencia en las reglas, digamos que en la omisión de una regla, se aplica el estilo heredado del padre.</li><li>Último en la lista están las reglas provistas por el navegador en las fuentes de estilo por defecto.*</li></ol><h3>Pongamos los conocimientos en práctica</h3><p>Simulemos el caso en el que nos proponemos hacer una publicación para nuestro blog. Sabemos que los elementos básicos que tenemos que tener en cuenta son la tipografía, el tamaño y el color del texto, y el formato de los títulos.</p><p>En el siguiente bloque, se puede ver el documento HTML en crudo. Para los que no están familiarizados, recomiendo investigar un poco sobre el tema (les aseguro que no es nada complicado).</p><pre>&lt;h1&gt;Titulo 1&lt;/h1&gt;</pre><pre>&lt;h2&gt;Subtitulo&lt;/h2&gt;</pre><pre>&lt;p&gt;Lorem ipsum dolor sit amet consectetur, adipisicing elit. Eum libero facere dignissimos nisi quia incidunt blanditiis veniam nemo minus quis.&lt;/p&gt;</pre><pre>&lt;h3&gt;Título de apartado&lt;/h3&gt;</pre><pre>&lt;p&gt;Lorem ipsum dolor, sit amet consectetur adipisicing elit. Aliquid provident illum, doloremque repellat, molestiae odio quisquam laudantium saepe reprehenderit quibusdam earum esse hic eum commodi nostrum totam odit, maiores tenetur quasi quam iure! Sed beatae, vero quasi officia doloribus dolorem?&lt;/p&gt;</pre><pre>&lt;ul&gt;<br>  &lt;li&gt;Lorem, ipsum.&lt;/li&gt;<br>  &lt;li&gt;Lorem, ipsum dolor.&lt;/li&gt;<br>  &lt;li&gt;Lorem ipsum dolor sit.&lt;/li&gt;<br>&lt;/ul&gt;</pre><p>Se puede observar que nuestro documento no tiene más elementos ni propiedades que los acordados. Sin embargo, iremos introduciendo algunos conceptos que serán útiles en ciertas circunstancias.</p><p>Como resultado, el navegador estará renderizando una página web a partir de lo que tiene y lo que no. Si nos ponemos en el rol del diseñador, hasta ahora no hemos definido ninguna hoja de estilos, y es por esto que el navegador deberá resolver a partir de los valores por defecto que él mismo tiene incorporado.</p><p>Si lo vemos desde los ojos del usuario, estaremos frente a una página web de lo más sencilla, estéticamente hablando.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/1*eepHvdJr6n6xMeir4q0gbg.png" /></figure><p>Con todo esto presente, podemos empezar a definir nuestras primeras reglas.</p><p>Empezaremos trabajando sobre el documento HTML (todavía no haremos uso del elemento <em>link</em> del que se habló al comienzo). Para agregar estilo al post, utilizaremos el elemento <em>style</em>, en el que podremos empezar a escribir nuestra propia hoja de estilos.</p><pre>&lt;style&gt;</pre><pre>h1 { font-weight: 400; }<br>h1 { font-family: Helvetica, sans; }</pre><pre>h2 { font-weight: 200; }<br>h2 { font-family: Helvetica, sans; }<br>h2 { color: gray }</pre><pre>h3 { font-weight: 200; }<br>h3 { font-family: Helvetica, sans; }<br>h3 { color: gray }</pre><pre>p { font-family: Helvetica, sans; }<br>p { font-size: 14px; }<br>p { text-align: justify; }</pre><pre>ul { font-style: italic; }<br>ul { font-size: 14px; }<br>ul { list-style: none; }</pre><pre>li { margin: 10px 0px; }</pre><pre>&lt;/style&gt;</pre><p>En CSS, todos los elementos de HTML pueden ser referenciados por un selector. En nuestra primer hoja de estilos, podemos observar que hemos agregado estilos directamente a los títulos, a los párrafos y a la lista.</p><p>Como primer resultado, obtenemos algunos pequeños cambios respecto de la versión inicial.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*SKVuzG2kcO9pzZBJeOO5NA.png" /></figure><p>Sabemos que podemos agrupar algunos selectores y declaraciones a fin de sintetizar un poco nuestra hoja de estilos.</p><pre>&lt;style&gt;</pre><pre>html {  font-family: Helvetica, sans;  text-align: justify; }</pre><pre>h1 { font-weight: 400; }</pre><pre>h2, h3 { font-weight: 200;  color: gray; }</pre><pre>p, ul { font-size: 14px; }</pre><pre>ul { font-style: italic; list-style: none; }</pre><pre>li { margin: 10px 0px; }</pre><pre>&lt;/style&gt;</pre><p>En esta segunda versión, aparece un nuevo selector llamado <em>html</em>, que hace referencia al elemento raíz del documento HTML.</p><p>Como un dato no menor, existe un selector que funciona como comodín, se indica con un <em>asterisco </em>y sirve para hacer declaraciones que afectarán a todos los elementos del documento, sobrescribiendo los valores por defecto, pero no así con otras reglas si su posición en la hoja es menos prioritaria.</p><p>Ahora supongamos que queremos que el párrafo bajo el subtitulo tenga un estilo diferente al del párrafo bajo el título del apartado. Por ejemplo, queremos que como resultado, el primer párrafo tenga un color más claro y además esté en itálica (cursiva).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*ASMHTRn5UWaJwUgcR92UFA.png" /></figure><p>Actualmente, nuestra hoja de estilos no puede diferenciar entre un párrafo y otro, y para estos casos es que podemos optar por utilizar otros tipos de selectores, como los <strong>identificadores</strong> o las <strong>clases</strong>.</p><h3>Identificadores y clases</h3><h4>Identificadores</h4><p>Como lo indica su nombre, se utiliza para identificar un único elemento, en este caso un elemento HTML y su valor debe ser irrepetible en todo el documento. Esta propiedad tan particular, puede ser referenciada como un selector para aplicar reglas de estilo.</p><p>Para definir el identificador de un elemento HTML, basta con agregar la propiedad <em>id</em> y asignarle un valor único.</p><pre>&lt;p id=&quot;parrafo-subtitulo&quot;, ipsum.&lt;/p&gt;</pre><p>Mientras que para invocar un identificador en la hoja de estilos, debe estar precedido por un símbolo numeral (<em>#</em>), sin espacios.</p><pre>&lt;style&gt;</pre><pre>...</pre><pre>#parrafo-subtitulo { font-style: italic; }</pre><pre>&lt;/style&gt;</pre><h4>Clases</h4><p>En primer medida, podemos darnos la licencia de decir que una clase es como un identificador, con la única diferencia de que el nombre de la clase puede estar declarado múltiples veces en el documento HTML, en varios de sus elementos. En otras palabras, una clase es un conjunto de declaraciones cuya definición puede referenciarse más de una vez desde el documento HTML.</p><p>Por lo tanto, si queremos definir una clase en la hoja de estilos, el selector debe estar precedido por un punto, sin espacios.</p><pre>&lt;style&gt;</pre><pre>...</pre><pre>.parrafo { font-style: italic; }</pre><pre>&lt;/style&gt;</pre><p>Mientras que en el documento HTML, basta con agregar la propiedad <em>class</em> a los elementos que quieran referenciar la clase.</p><pre>&lt;p class=&quot;parrafo&quot;&gt;Lorem, ipsum.&lt;/p&gt;</pre><h4>¿Cuándo una clase y cuando un identificador?</h4><p>Elegir entre un identificador o una clase, es parte del juicio del diseñador. Sin embargo, existen situaciones en las que conviene más uno, que otro. En lo que a mí respecta:</p><ul><li>Si el estilo que debemos definir aplica únicamente a un único elemento, se recomienda utilizar un identificador.</li><li>Si el estilo que debemos definir debe poder ser reutilizado por varios elementos, se recomienda utilizar una clase.</li></ul><p>En el último caso, podemos recurrir a la especificidad del selector para acotar el uso de la regla a unos pocos elementos que cumplan cierto criterio.</p><p>Retomando el caso con el que estábamos trabajando, se ha requerido que el primer párrafo deba tener un estilo distinto al último.</p><p>Aquí estamos en una situación de diseño, se puede hacer uso tanto de un identificador como de una clase. En este caso trabajaremos con un identificador al cual nombraremos “<em>parrafo-subtitulo</em>”.</p><p>Las modificaciones serán las siguientes:</p><ol><li>Agregar el identificador al primer párrafo del documento HTML</li></ol><pre>&lt;p id=&quot;parrafo-subtitulo&quot;&gt;Lorem ipsum dolor sit amet consectetur, adipisicing elit. Eum libero facere dignissimos nisi quia incidunt blanditiis veniam nemo minus quis.&lt;/p&gt;</pre><p>2. Agregar la regla del selector cuyo nombre hace referencia al identificador</p><pre>#parrafo-subtitulo { color: gray; font-style: italic; }</pre><p>Supongamos que ahora los elementos de la lista del ejemplo llevan un titulo en negrita y el texto consecutivo mantiene el formato. Pero el primero, a su vez debe estar subrayado. Como resultado, se pretende obtener:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*PHZt0TqQQV0A3ZTLSOXJqw.png" /></figure><p>Para definir la regla, el selector para el primer elemento de la lista, debe ser más específico. Solo si se cumple la secuencia del selector, se debe aplicar el estilo correspondiente.</p><pre>ul li span.negrita {<br>  font-weight: bold;<br>};</pre><pre>ul li span.negrita.subrayado {<br>  text-decoration: underline;<br>};</pre><p>El estilo se aplicará solo si pertenece a un elemento de una lista sin orden, bajo el cuerpo de un elemento <em>span</em> cuyas clases sean <em>negrita </em>y <em>subrayado</em>.</p><p>En resumen, vimos que el uso de los identificadores y de las clases nos da una ventaja sustancial frente a los selectores comunes que hacen referencia a los elementos HTML, y que la especificidad de la regla aporta enormemente a estilizar elementos particulares del documento.</p><p>Aún con todo lo que fuimos viendo, CSS tiene mucho más que darnos, pero eso quedará para otro post.</p><p>Para aquellos que quieran ver el ejemplo funcionando, lo dejo a disposición en CodePen</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2Fgermanasmus%2Fembed%2Fpreview%2FPggdEr%3Fheight%3D600%26slug-hash%3DPggdEr%26default-tabs%3Dhtml%2Cresult%26host%3Dhttps%3A%2F%2Fcodepen.io&amp;url=https%3A%2F%2Fcodepen.io%2Fgermanasmus%2Fpen%2FPggdEr%2F&amp;image=https%3A%2F%2Fscreenshot.codepen.io%2F905685.PggdEr.small.a1481ec1-aaa5-44e5-a588-b30e856557b1.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/9ee85524911e09b8c3693a27602ebef7/href">https://medium.com/media/9ee85524911e09b8c3693a27602ebef7/href</a></iframe><h3>Resumen</h3><p>En este post pasamos por aspectos básicos y fundamentales de CSS, los que podemos adoptar como primeras herramientas para situaciones futuras y más reales.</p><p>Ahora sabemos por qué CSS hace alusión a la palabra <strong>cascada</strong>, cómo es su sintaxis, la existencia de reglas, su forma de interpretarlas y de procesarlas, y el uso de identificadores y clases como nuevos mecanismos para estilizar de forma más óptima nuestro documento HTML.</p><p>Sin más, espero que les haya gustado el post, siéntanse en libertad de comentar o escribirme.</p><p>Saludos.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d013ac8537d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>