FAQ Database Discussion Community


Hover over a pre - how to highlight a single line with plain CSS?

html,css,pre
I have some <pre> blocks. Would it be possible, using just CSS, to highlight single lines when hovering over them? == Update == Here is some sample code: <pre> #include <stdio.h> int main() { printf("Hello World"); return 0; } </pre> When lines become longer it would be useful to have...

If you set a style for a pre or div once, do you need to set again?

html,pre
for example, if i do: pre style="white-space:pre-wrap;" at the beginning of my first pre block, would this apply to all pre blocks? it doesn't seem to have the effect I want....

How to use html tags in
 when updated from the script

javascript,html,pre
I have a text <pre id="printed-table">bunch of monkeys</pre>. I want to process the text with a javascript window.onload to highlight the word monkeys. So, it should look like bunch of monkeys when page is loaded. I have a script <script type="text/javascript"> window.onload = function() { var p = document.getElementById("printed-table"); var...

How to display code block in AngularJS app

javascript,angularjs,pre
I'm trying to create some website about AngularJS in AngularJS ;-) I've added ng-app on body element, and now all my code snippets (which are all in <pre><code> ... </code></pre> tags) are parsed by angular (it adds ng-binding class for example). Is there a way to tell angular that given...

Retrieve Code or PRE tag content on server side

javascript,c#,html,pre
I am trying to read the content of "PRE" or "CODE" tag of HTML to server side in C#. I am using HTML editor "tinymce". Preview is displayed properly. But when I read it on server side in string variable and the display it in some div. Then all the...

CKEditor escape html

html,escaping,ckeditor,pre
I have CKEditor on post text where I want to insert html-code. Something like this: <pre> <code class="html"> <img src="path/to/img.jpg" /> </code> </pre> But when I save the text, CKEditor interprets img-tag as actual html-image and shows broken image. How I can prevent that and tell to escape html-code in...

How to automatically disable and enable scroll for pre tag

html,scroll,overflow,pre
I need to implement down and up scroll when height of pre will be became more than X px. My friend behind cell phone says you can, and you need define maximum px of pre tag and when pre overflow, it must be visible, but I don't know css well...

Froala code snippet losing breaklines on edit

ruby-on-rails-3,ruby-on-rails-4,wysiwyg,pre,froala
I am making a simple blog in RoR. When I edit a post I am losing all linebreakes in the code snippet. How can I make sure that when I am reloading the content of the post, the editor correctly formats the code snippets? This is the input into the...

Pre code html rendering rather than displaying text

html,html5,pre
I want to show some code for some documentation. But whenever I try, the browser actually renders it as HTML rather than as text. How do I stop this? <pre> <code class="html"> <div class="alert-wrap g--5"> <input type="checkbox" id="alert-check"> <label for="alert-check">CLOSE</label> <div class="alert card"> <p>Surface rules! That is all.</p> </div> </div>...

Pre and post on Java. Not taking effect? [duplicate]

java,post,int,pre
This question already has an answer here: What is x after “x = x++”? 16 answers int x = 12; int y = 15; while (y >= 0) { x = x--; y = --y; } System.out.print(x); This prints out 12 and I'm guessing x is never changed because...

white-space:pre does not work with contenteditable.

contenteditable,pre
Hi I am trying to prevent a contenteditable div from word wrapping. The white-space: pre property does not work for a contenteditable. This is the css: .preDiv{ border:1px solid blue; overflow:auto; width:100px; white-space:pre; } Here is a fiddle:contentEditable-fiddle I want it to work the way it does as if it...

What's the difference between `word-break: break-all` and `word-wrap: break-word`? [duplicate]

css,css3,word-wrap,pre,word-break
This question already has an answer here: What is the difference between “word-break: break-all” versus “word-wrap: break-word” in CSS 7 answers I don't understand why there are two properties that seem to do the same thing, yet their interrelation does not appear to be defined within the spec. http://dev.w3.org/csswg/css-text-3/#word-break-property...

Difficulty getting pre and code tags to scroll rather than wrap

css,syntax-highlighting,highlight,pre
My website is built using a static site generator I created myself, and uses Bootstrap for the layout. I'm using Highlight.js for the syntax highlighting (running server-side as part of the build process) and it's working pretty well. However, one thing has stumped me. I would like the code tags...

PHP Regex expression excluding
 tag

php,regex,wordpress,replace,pre
I am using a WordPress plugin named Acronyms (https://wordpress.org/plugins/acronyms/). This plugin replaces acronyms with their description. It uses a PHP PREG_REPLACE function. The issue is that it replaces the acronyms contained in a <pre> tag, which I use to present a source code. Could you modify this expression so that...