Changing content of the element with pseudo-element</a></h1> </div> <div class="grid fw-wrap pb8 mb16 bb bc-black-075"> <div class="grid--cell ws-nowrap mr16 mb8" title="2016-01-12 19:07:53Z"> <span class="fc-light mr2">Asked</span> <time itemprop="dateCreated" datetime="2016-09-24T12:03:35.250" class="fromnow">Sep 24 '16 at 12:03</time> </div> <div class="grid--cell ws-nowrap mr16 mb8"> <span class="fc-light mr2">Active</span> <time class="fromnow" title="2016-09-24T15:45:15.243" datetime="2016-09-24T15:45:15.243">Sep 24 '16 at 15:45</a> </div> <div class="grid--cell ws-nowrap mb8" title="Viewed 807 times"> <span class="fc-light mr2">Viewed</span> 807 times </div> </div> <div id="mainbar" role="main" aria-label="questions and answers"> <div id="question" class="question" data-questionid="39676130" data-ownerid="6874433" data-score="0"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container grid jc-center fd-column ai-stretch gs4 fc-black-200" data-post-id="39676130"> <button class="js-vote-up-btn grid--cell s-btn s-btn__unset c-pointer"><svg aria-hidden="true" class="m0 svg-icon iconArrowUpLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 26h32L18 10 2 26z"></path></svg></button> <div class="js-vote-count grid--cell fc-black-500 fs-title grid fd-column ai-center" itemprop="upvoteCount" data-value="0">0</div> <button class="js-bookmark-btn s-btn s-btn__unset c-pointer py4"> <svg aria-hidden="true" class="svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M6 1a2 2 0 00-2 2v14l5-4 5 4V3a2 2 0 00-2-2H6zm3.9 3.83h2.9l-2.35 1.7.9 2.77L9 7.59l-2.35 1.7.9-2.76-2.35-1.7h2.9L9 2.06l.9 2.77z"></path></svg> <div class="js-bookmark-count mt4" data-value=""></div> </button> </div> </div> <div class="postcell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"><h1>What i want</h1> <p>To change contents of html 'title' element by selecting it via '::before' pseudo-element and applying 'content' attribute to selection.</p> <h1>Problem</h1> <p>I have a webpage:</p> <pre><code><html> <head> <title>Some title</title> <link rel="stylesheet" type="text/css" href="stylesheet.css"> </head> <body> <p>Some paragraph</p> </body> </html> </code></pre> <p>and the css stylesheet:</p> <pre><code>title::before { content: "Text"; } p::before { content: "Text"; } </code></pre> <p>I can't seem to be able to change content of the html 'title' element this way with css style, but it works with 'p' element.</p> <p>I know there is good javascript libraries with good functions which can handle this easily, but i want to apply these changes to external webpage served in my webbrowser with custom userstyle.css.</p> <p>Is it possible?</p></div> <div class="mt24 mb12"> <div class="post-taglist grid gs4 gsy fd-column"> <div class="grid ps-relative"> <a href="../../questions/tagged/html" class="post-tag js-gps-track" title="show questions tagged 'html'" rel="tag">html</a> <a href="../../questions/tagged/css" class="post-tag js-gps-track" title="show questions tagged 'css'" rel="tag">css</a> <a href="../../questions/tagged/pseudo-element" class="post-tag js-gps-track" title="show questions tagged 'pseudo-element'" rel="tag">pseudo-element</a> <a href="../../questions/tagged/css-content" class="post-tag js-gps-track" title="show questions tagged 'css-content'" rel="tag">css-content</a> </div> </div> </div> <div class="mb0"> <div class="mt16 grid gs8 gsy fw-wrap jc-end ai-start pt4 mb16"> <div class="grid--cell mr16 fl1 w96"></div> <div class="post-signature grid--cell"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="edited Jun 20 '20 at 09:12">edited Jun 20 '20 at 09:12</time> <a href="../../users/-1/community" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/-1.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Community" /> </a> <div class="s-user-card--info"> <a href="../../users/-1/community" class="s-user-card--link">Community</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">1</li> <li class="s-award-bling s-award-bling__silver" title="1 silver badges">1</li> </ul> </div> </div> </div> <div class="post-signature owner grid--cell"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Sep 24 '16 at 12:03">asked Sep 24 '16 at 12:03</time> <a href="../../users/6874433/petteri-knihti" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/6874433.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Petteri Knihti" /> </a> <div class="s-user-card--info"> <a href="../../users/6874433/petteri-knihti" class="s-user-card--link">Petteri Knihti</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">1</li> <li class="s-award-bling s-award-bling__bronze" title="3 bronze badges">3</li> </ul> </div> </div> </div> </div> </div> </div> <div class="post-layout--right js-post-comments-component"> </div> </div> </div> <div id="answers"> <a name="tab-top"></a> <div id="answers-header"> <div class="answers-subheader grid ai-center mb8"> <div class="grid--cell fl1"> <h2 class="mb0" data-answercount="9">2 Answers<span style="display:none;" itemprop="answerCount">2</span></h2> </div> </div> </div> <a name="39676148"></a> <div id="answer-39676148" class="answer " data-answerid="39676148" data-ownerid="106224" data-score="3" itemprop="suggestedAnswer" itemscope="" itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container grid jc-center fd-column ai-stretch gs4 fc-black-200" data-post-id="39676148"> <button class="js-vote-up-btn grid--cell s-btn s-btn__unset c-pointer"><svg aria-hidden="true" class="m0 svg-icon iconArrowUpLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 26h32L18 10 2 26z"></path></svg></button> <div class="js-vote-count grid--cell fc-black-500 fs-title grid fd-column ai-center" itemprop="upvoteCount" data-value="3">3</div> </div> </div> <div class="postcell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"><p>The title element isn't rendered on the viewport like other elements since it's in the head and not the body, so pseudo-elements aren't going to work with it.</p></div> <div class="mb0"> <div class="mt16 grid gs8 gsy fw-wrap jc-end ai-start pt4 mb16"> <div class="grid--cell mr16 fl1 w96"></div> <div class="post-signature grid--cell"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="answered Sep 24 '16 at 12:06">answered Sep 24 '16 at 12:06</time> <a href="../../users/106224/boltclock" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/106224.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="BoltClock" /> </a> <div class="s-user-card--info"> <a href="../../users/106224/boltclock" class="s-user-card--link">BoltClock</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">700,868</li> <li class="s-award-bling s-award-bling__gold" title="160 gold badges">160</li> <li class="s-award-bling s-award-bling__silver" title="1,392 silver badges">1,392</li> <li class="s-award-bling s-award-bling__bronze" title="1,356 bronze badges">1,356</li> </ul> </div> </div> </div> </div> </div> </div> <div class="post-layout--right js-post-comments-component"> </div> </div> </div> <a name="39678150"></a> <div id="answer-39678150" class="answer " data-answerid="39678150" data-ownerid="4182629" data-score="1" itemprop="suggestedAnswer" itemscope="" itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container grid jc-center fd-column ai-stretch gs4 fc-black-200" data-post-id="39678150"> <button class="js-vote-up-btn grid--cell s-btn s-btn__unset c-pointer"><svg aria-hidden="true" class="m0 svg-icon iconArrowUpLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 26h32L18 10 2 26z"></path></svg></button> <div class="js-vote-count grid--cell fc-black-500 fs-title grid fd-column ai-center" itemprop="upvoteCount" data-value="1">1</div> </div> </div> <div class="postcell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"><p>Just press F12 find head tag. You will find that it's already hidden by default. You can Change the content by jQuery. $('title').text('you text here');</p></div> <div class="mb0"> <div class="mt16 grid gs8 gsy fw-wrap jc-end ai-start pt4 mb16"> <div class="grid--cell mr16 fl1 w96"></div> <div class="post-signature grid--cell"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="answered Sep 24 '16 at 15:45">answered Sep 24 '16 at 15:45</time> <a href="../../users/4182629/amin-charoliya" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/4182629.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Amin charoliya" /> </a> <div class="s-user-card--info"> <a href="../../users/4182629/amin-charoliya" class="s-user-card--link">Amin charoliya</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">566</li> <li class="s-award-bling s-award-bling__gold" title="1 gold badge">1</li> <li class="s-award-bling s-award-bling__silver" title="5 silver badge">5</li> <li class="s-award-bling s-award-bling__bronze" title="15 bronze badge">15</li> </ul> </div> </div> </div> </div> </div> </div> <div class="post-layout--right js-post-comments-component"> </div> </div> </div> </div> </div> <div id="sidebar" class="show-votes" role="complementary" aria-label="sidebar"> <div class="module sidebar-linked"> <h4 id="h-linked">Linked</h4> <div class="linked"> <div class="spacer"> <a title="Vote score (upvotes - downvotes)"><div class="answer-votes answered-accepted default">0</div></a> <a href="../../questions/66926768/how-to-capture-document-title-using-css-string-set" class="question-hyperlink">How to capture document title using CSS string-set</a> </div> </div> </div> </div> </div> </div> <script src="../../static/js/stack-icons.js"></script> <script src="../../static/js/fromnow.js"></script> </body> </html>