Capitalize first letter of an inline element's text The Next CEO of Stack OverflowCapitalize first letter of sentences CSSHow to change an element's class with JavaScript?Vertically align text next to an image?How do I give text or an image a transparent background using CSS?How to disable text selection highlighting?How to write a:hover in inline CSS?How do I vertically align text in a div?How do I remove the space between inline-block elements?How do I vertically center text with CSS?CSS Capitalize First Letter In All Caps WordHow to apply :first-letter pseudo-element for div with display:flex?

How do I get the green key off the shelf in the Dobby level of Lego Harry Potter 2?

Does it take more energy to get to Venus or to Mars?

Why do remote companies require working in the US?

How to count occurrences of text in a file?

Term for the "extreme-extension" version of a straw man fallacy?

What is the purpose of the Evocation wizard's Potent Cantrip feature?

Solution of this Diophantine Equation

Does the Brexit deal have to be agreed by both Houses?

Why didn't Khan get resurrected in the Genesis Explosion?

When did Lisp start using symbols for arithmetic?

The King's new dress

Science fiction novels about a solar system spanning civilisation where people change their bodies at will

How to make a variable always equal to the result of some calculations?

Grabbing quick drinks

Unreliable Magic - Is it worth it?

Why doesn't a table tennis ball float on the surface? How do we calculate buoyancy here?

What is the point of a new vote on May's deal when the indicative votes suggest she will not win?

Visit to the USA with ESTA approved before trip to Iran

Are there languages with no euphemisms?

Whats the best way to handle refactoring a big file?

Customer Requests (Sometimes) Drive Me Bonkers!

How to safely derail a train during transit?

Example of a Mathematician/Physicist whose Other Publications during their PhD eclipsed their PhD Thesis

If I blow insulation everywhere in my attic except the door trap, will heat escape through it?



Capitalize first letter of an inline element's text



The Next CEO of Stack OverflowCapitalize first letter of sentences CSSHow to change an element's class with JavaScript?Vertically align text next to an image?How do I give text or an image a transparent background using CSS?How to disable text selection highlighting?How to write a:hover in inline CSS?How do I vertically align text in a div?How do I remove the space between inline-block elements?How do I vertically center text with CSS?CSS Capitalize First Letter In All Caps WordHow to apply :first-letter pseudo-element for div with display:flex?










0















I read elsewhere that the following should capitalize the first letter of the text of an inline element (e.g. a <span>).



However, if you run the code snippet you'll see that it doesn't work. If I replace the <span> with a <div> it works, but is there a way to capitalize the first letter without changing the element type?






.list .capitalize:first-letter 
text-transform: capitalize;
display: inline-block;

<div class="list">
<span class="capitalize">capitalize me</span>
</div>












share|improve this question






















  • ::first-letter "The ::first-letter CSS pseudo-element applies styles to the first letter of the first line of a block-level element" Source . The answer you referenced has a comment --> "Keep in mind that .qcont has to be a block."

    – Ramiz Wachtler
    Mar 7 at 14:13
















0















I read elsewhere that the following should capitalize the first letter of the text of an inline element (e.g. a <span>).



However, if you run the code snippet you'll see that it doesn't work. If I replace the <span> with a <div> it works, but is there a way to capitalize the first letter without changing the element type?






.list .capitalize:first-letter 
text-transform: capitalize;
display: inline-block;

<div class="list">
<span class="capitalize">capitalize me</span>
</div>












share|improve this question






















  • ::first-letter "The ::first-letter CSS pseudo-element applies styles to the first letter of the first line of a block-level element" Source . The answer you referenced has a comment --> "Keep in mind that .qcont has to be a block."

    – Ramiz Wachtler
    Mar 7 at 14:13














0












0








0








I read elsewhere that the following should capitalize the first letter of the text of an inline element (e.g. a <span>).



However, if you run the code snippet you'll see that it doesn't work. If I replace the <span> with a <div> it works, but is there a way to capitalize the first letter without changing the element type?






.list .capitalize:first-letter 
text-transform: capitalize;
display: inline-block;

<div class="list">
<span class="capitalize">capitalize me</span>
</div>












share|improve this question














I read elsewhere that the following should capitalize the first letter of the text of an inline element (e.g. a <span>).



However, if you run the code snippet you'll see that it doesn't work. If I replace the <span> with a <div> it works, but is there a way to capitalize the first letter without changing the element type?






.list .capitalize:first-letter 
text-transform: capitalize;
display: inline-block;

<div class="list">
<span class="capitalize">capitalize me</span>
</div>








.list .capitalize:first-letter 
text-transform: capitalize;
display: inline-block;

<div class="list">
<span class="capitalize">capitalize me</span>
</div>





.list .capitalize:first-letter 
text-transform: capitalize;
display: inline-block;

<div class="list">
<span class="capitalize">capitalize me</span>
</div>






html css






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 7 at 14:09









DónalDónal

123k156486751




123k156486751












  • ::first-letter "The ::first-letter CSS pseudo-element applies styles to the first letter of the first line of a block-level element" Source . The answer you referenced has a comment --> "Keep in mind that .qcont has to be a block."

    – Ramiz Wachtler
    Mar 7 at 14:13


















  • ::first-letter "The ::first-letter CSS pseudo-element applies styles to the first letter of the first line of a block-level element" Source . The answer you referenced has a comment --> "Keep in mind that .qcont has to be a block."

    – Ramiz Wachtler
    Mar 7 at 14:13

















::first-letter "The ::first-letter CSS pseudo-element applies styles to the first letter of the first line of a block-level element" Source . The answer you referenced has a comment --> "Keep in mind that .qcont has to be a block."

– Ramiz Wachtler
Mar 7 at 14:13






::first-letter "The ::first-letter CSS pseudo-element applies styles to the first letter of the first line of a block-level element" Source . The answer you referenced has a comment --> "Keep in mind that .qcont has to be a block."

– Ramiz Wachtler
Mar 7 at 14:13













3 Answers
3






active

oldest

votes


















3














The pseudo element ::first-letter only works if the parent element is a block element, so the span must be inline-block:






.list .capitalize 
display: inline-block;

.list .capitalize::first-letter
/* you could use capitalize as well, but since it's just one letter, just use uppercase on it */
text-transform: uppercase;

<div class="list">
<span class="capitalize">capitalize me</span>
</div>








share|improve this answer




















  • 1





    While this is the correct answer, please use the new format ::first-letter with two ::

    – Mattia Astorino
    Mar 7 at 14:20











  • @MattiaAstorino done.

    – Mr Geek
    Mar 7 at 14:23


















2














Span has not default display, so you have to set it to block or something else

And it's not correct to set display property of first-letter, you should do it for entire class






.list .capitalize
display: block;

.list .capitalize::first-letter
text-transform: uppercase;

<div class="list">
<span class="capitalize">capitalize me</span>
</div>








share|improve this answer






























    -1














    You need to make the span itself display: inline-block - not the ::first-letter pseudo element.



    .list .capitalize 
    display: inline-block;






    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55045789%2fcapitalize-first-letter-of-an-inline-elements-text%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      3














      The pseudo element ::first-letter only works if the parent element is a block element, so the span must be inline-block:






      .list .capitalize 
      display: inline-block;

      .list .capitalize::first-letter
      /* you could use capitalize as well, but since it's just one letter, just use uppercase on it */
      text-transform: uppercase;

      <div class="list">
      <span class="capitalize">capitalize me</span>
      </div>








      share|improve this answer




















      • 1





        While this is the correct answer, please use the new format ::first-letter with two ::

        – Mattia Astorino
        Mar 7 at 14:20











      • @MattiaAstorino done.

        – Mr Geek
        Mar 7 at 14:23















      3














      The pseudo element ::first-letter only works if the parent element is a block element, so the span must be inline-block:






      .list .capitalize 
      display: inline-block;

      .list .capitalize::first-letter
      /* you could use capitalize as well, but since it's just one letter, just use uppercase on it */
      text-transform: uppercase;

      <div class="list">
      <span class="capitalize">capitalize me</span>
      </div>








      share|improve this answer




















      • 1





        While this is the correct answer, please use the new format ::first-letter with two ::

        – Mattia Astorino
        Mar 7 at 14:20











      • @MattiaAstorino done.

        – Mr Geek
        Mar 7 at 14:23













      3












      3








      3







      The pseudo element ::first-letter only works if the parent element is a block element, so the span must be inline-block:






      .list .capitalize 
      display: inline-block;

      .list .capitalize::first-letter
      /* you could use capitalize as well, but since it's just one letter, just use uppercase on it */
      text-transform: uppercase;

      <div class="list">
      <span class="capitalize">capitalize me</span>
      </div>








      share|improve this answer















      The pseudo element ::first-letter only works if the parent element is a block element, so the span must be inline-block:






      .list .capitalize 
      display: inline-block;

      .list .capitalize::first-letter
      /* you could use capitalize as well, but since it's just one letter, just use uppercase on it */
      text-transform: uppercase;

      <div class="list">
      <span class="capitalize">capitalize me</span>
      </div>








      .list .capitalize 
      display: inline-block;

      .list .capitalize::first-letter
      /* you could use capitalize as well, but since it's just one letter, just use uppercase on it */
      text-transform: uppercase;

      <div class="list">
      <span class="capitalize">capitalize me</span>
      </div>





      .list .capitalize 
      display: inline-block;

      .list .capitalize::first-letter
      /* you could use capitalize as well, but since it's just one letter, just use uppercase on it */
      text-transform: uppercase;

      <div class="list">
      <span class="capitalize">capitalize me</span>
      </div>






      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Mar 7 at 14:22

























      answered Mar 7 at 14:16









      Mr GeekMr Geek

      7,68221336




      7,68221336







      • 1





        While this is the correct answer, please use the new format ::first-letter with two ::

        – Mattia Astorino
        Mar 7 at 14:20











      • @MattiaAstorino done.

        – Mr Geek
        Mar 7 at 14:23












      • 1





        While this is the correct answer, please use the new format ::first-letter with two ::

        – Mattia Astorino
        Mar 7 at 14:20











      • @MattiaAstorino done.

        – Mr Geek
        Mar 7 at 14:23







      1




      1





      While this is the correct answer, please use the new format ::first-letter with two ::

      – Mattia Astorino
      Mar 7 at 14:20





      While this is the correct answer, please use the new format ::first-letter with two ::

      – Mattia Astorino
      Mar 7 at 14:20













      @MattiaAstorino done.

      – Mr Geek
      Mar 7 at 14:23





      @MattiaAstorino done.

      – Mr Geek
      Mar 7 at 14:23













      2














      Span has not default display, so you have to set it to block or something else

      And it's not correct to set display property of first-letter, you should do it for entire class






      .list .capitalize
      display: block;

      .list .capitalize::first-letter
      text-transform: uppercase;

      <div class="list">
      <span class="capitalize">capitalize me</span>
      </div>








      share|improve this answer



























        2














        Span has not default display, so you have to set it to block or something else

        And it's not correct to set display property of first-letter, you should do it for entire class






        .list .capitalize
        display: block;

        .list .capitalize::first-letter
        text-transform: uppercase;

        <div class="list">
        <span class="capitalize">capitalize me</span>
        </div>








        share|improve this answer

























          2












          2








          2







          Span has not default display, so you have to set it to block or something else

          And it's not correct to set display property of first-letter, you should do it for entire class






          .list .capitalize
          display: block;

          .list .capitalize::first-letter
          text-transform: uppercase;

          <div class="list">
          <span class="capitalize">capitalize me</span>
          </div>








          share|improve this answer













          Span has not default display, so you have to set it to block or something else

          And it's not correct to set display property of first-letter, you should do it for entire class






          .list .capitalize
          display: block;

          .list .capitalize::first-letter
          text-transform: uppercase;

          <div class="list">
          <span class="capitalize">capitalize me</span>
          </div>








          .list .capitalize
          display: block;

          .list .capitalize::first-letter
          text-transform: uppercase;

          <div class="list">
          <span class="capitalize">capitalize me</span>
          </div>





          .list .capitalize
          display: block;

          .list .capitalize::first-letter
          text-transform: uppercase;

          <div class="list">
          <span class="capitalize">capitalize me</span>
          </div>






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 7 at 14:19









          pavelberepavelbere

          439110




          439110





















              -1














              You need to make the span itself display: inline-block - not the ::first-letter pseudo element.



              .list .capitalize 
              display: inline-block;






              share|improve this answer



























                -1














                You need to make the span itself display: inline-block - not the ::first-letter pseudo element.



                .list .capitalize 
                display: inline-block;






                share|improve this answer

























                  -1












                  -1








                  -1







                  You need to make the span itself display: inline-block - not the ::first-letter pseudo element.



                  .list .capitalize 
                  display: inline-block;






                  share|improve this answer













                  You need to make the span itself display: inline-block - not the ::first-letter pseudo element.



                  .list .capitalize 
                  display: inline-block;







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 7 at 14:13









                  04FS04FS

                  1,3241314




                  1,3241314



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55045789%2fcapitalize-first-letter-of-an-inline-elements-text%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      1928 у кіно

                      Захаров Федір Захарович

                      Ель Греко