how to make line break in html without br [closed] - html

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
i have a lot of content and i am going to upload it to my website, and in website it will look like with no line breaks. and it will take a lot of time to add in content - <br>. Is there any other way to break lines?
Thank you!

I'll assume your original content has breaks caused by carriage returns or line feeds, but they're not rendered that way in your HTML.
To fix that, add CSS style pre-wrap:
div {
white-space: pre-wrap;
}
<div>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>

You can give width to paragraph tag or its parent tag. Please post your work in jsfiddle. So i can edit it and give it to you

Use CSS. For instance, if you have several paragraphs of text you can have a space between each one by just giving them a bottom margin as:
p { margin-bottom : 1em; }
That will give a complete blank line between each paragraph (or you could have 0.5em, say, to get half that amount of space, or any other measure. If you haven't used CSS before, now would be the time to learn, and it's pretty easy to learn the basics.
You can add CSS at the top of your HTML in the head section, for now (later learn how to put it into a separate file), doing:
<head>
....[other stuff here]
<style type="text/css">
p { margin-bottom : 1em; }
</style>
</head>

I imagine it would take even longer to wrap paragraphs in <p></p> than it would to add <br> between paragraphs. If I were going to take a huge amount of raw text and put it into content on a web page I would paste it into (or since I am a programmer write a program) a program that would make the conversion.
As I'm writing I'm thinking and wondering if you took your text and put it into MS Word and saved it as an HTML and made the format corrections could you get output from that that would work for your purposes?

Related

How do I style regular (untagged) HTML text with CSS? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
So I just started learning HTML and CSS like 2 days ago and I ran into a problem. I'm creating a cheat sheet for myself and all the CSS text indentations applies only to my h2 tags no matter what I do.
<section>
<!-- Bold, Italics, Underline -->
<h2>Bold, Italics, and Underline</h2>
<strong>&ltstrong></strong> The strong tag is used to <strong>bolden</strong> text.
<br>
<strong><em></strong> The em tag is used to <em>italicise</em> text.
<br>
<strong><u></strong> The u tag is used to <u>underline</u> text.
</section>
This is the way I've written my code, I sectioned my lines based on relevant tags and put all of them in a div with a container class. In my CSS stylesheet, I was playing around with text-indent and found that no matter where I place it, it only applies to my h2 tags.
I've tried nesting that command within different CSS classes, removing all my sections and just keeping my text in the div, etc but nothing works. I didn't want to use paragraph tags for each line of text because of the padding which is why I used regular text.
As w3schools about text-indent stated:
Definition and Usage
The text-indent property specifies the indentation of the first line in a text-block.
As for what counts as a text block, you can find it here.
Or you can move the section by using the CSS margin-left style.
Example:
<section style="margin-left: 12px;">
<strong>This is Indented with margin</strong>
<br>
Lorem consectetur mollit proident ad quis commodo pariatur ullamco mollit eiusmod cupidatat amet fugiat.
</section>
<br>
<br>
<br>
<section>
<strong>This is unindented</strong>
<br>
Lorem consectetur mollit proident ad quis commodo pariatur ullamco mollit eiusmod cupidatat amet fugiat.
</section>

Getting strange character encoding in json output

Getting stuff like this in my JSON responses:
\u003Cp\u003EOur Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.\u003C/p\u003E\n
I'm assuming CakePHP 3.3 is doing something here. Using standard json and xml route extensions. With set and serialize in my controllers. Nothing out of the ordinary that I can think of. Any idea how to change this to something that can be easily decoded by a client or just turn off the encoding all together?
There's nothing strange about this, that's simply unicode tag representations of the opening and closing angled brackets of the HTML tags in your content. This conversion is being applied when using the JSON_HEX_TAG option, which CakePHP does by default.
In fact, CakePHP currently uses
JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT
by default. If you want to change this, use the _jsonOptions view variable option to define your own bitmask, or set it to false to disable the defaults, ie in your controller action do something like
$this->set('_jsonOptions', false);
See also
http://php.net/en/json_encode
http://php.net/manual/en/json.constants.php
Cookbook > Views > JSON and XML views > Creating JSON Views

Jekyll: Use an include from content

How can I use a short include in Jekyll's content (not in the template files) and have it rendered?
For example inside a page content or post I want to write something like this:
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
{% include responsive_youtube.html video="nGeKSiCQkPw" %}
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
If I do it now Jekyll does not process the snippet it just posts the code. It works in template files but not as content. I'm using html with font matter code (and not markdown) as content.
Jekyll YouTube Embed Plugin can do it ! And you can find other plugins on the Jekyll plugins section.
Note that you cannot use this plugin with github pages.
This video is excellent !
{% youtube nGeKSiCQkPw %}
I definitely know that it's possible to use includes in the content, I made a site with Jekyll where I'm doing it exactly like this:
some text
{% include whatever.html %}
more text
The question is why it doesn't work for you.
You say you aren't using Markdown, but maybe the file still has the .md extension (even if you're using no Markdown inside, only HTML)?
If yes, Jekyll will treat it as Markdown.
I suspect that you indented the {% include... line like this:
some text
{% include whatever.html %}
more text
If yes, the Markdown parser will treat it as code.
Jekyll will still process the include and inject the HTML from the include file, but the HTML will not be rendered, but displayed as code because of the indentation.
If that doesn't help, you need to show us some actual source code.

Twitter Bootstrap zooms text differently on Webkit (Chrome, Safari)

I'm looking into using Twitter Bootstrap (with some customisations) for a site rebuild.
One problem is with page/text zooming on Webkit browsers like Chrome and Safari. These don't rewrap the text to the screen when zooming. Instead the text continues off the page requiring horizontal scrolling.
For an example, compare zooming the text on the Bootstrap home page on Chrome/Safari and Firefox - on Firefox even the responsive menubar works properly when there's not enough room for the menu text due to zooming.
This seems to be a known Webkit "feature" with pixel-based layouts, which can be solved by using em-based widths, which looks impractical with the standard Bootstrap (way too much to change and maintain).
So, is there any Bootstrap derivative around which uses em-based widths, or is there any way to add a snippet of css etc to work around the problem? It's the only thing so far stopping me from using Bootstrap on this project. I want the site to be accessible for lower vision users, who often zoom.
Would be nice if Webkit fixed the bug/feature to behave like other browser engines but I don't see that happening anytime soon unfortunately.
[update] Just to be clear, it's the full similar action to Firefox I'm after: zooming text stays constrained within columns, AND media queries realise the space on the screen is limited when text is zoomed and adjust the menu and number of columns accordingly. Fluid layouts help with constraining main article text, but the menus and sidebars are still a mess on Chrome/Safari when zooming.
You can set a slider as accessibility option for lower vision visitors of your site..
Just use text-resizing using jquery. No need to zoom the page.
See this example:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('a').click(function() {
var os = $('p').css('font-size');
var num = parseFloat(os, 10);
var px = os.slice(-2);
$('p').css('font-size', num / 1.4 + px);
if (this.id == 'larger') {
$('p').css('font-size', num * 1.4 + px);
}
});
});
</script>
Larger [+]
<br>
Smaller [-]
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
Rob,
You can accomplish what you want by using a fluid container in bootstrap and then setting its max-width property to a percentage width with something like:
[class*="container-"] {
margin: auto;
padding: 0 20px;
max-width: 90%;
}
the html would look something like:
<div class="content">
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
put your contents in here
</div>
</div>
</div>
</div>
Where the div of class content is not within the container and can serve as background. This is how I have my bootstrap site set up and have just tried in safari and firefox with the results you are looking for. As you mentioned the rendering has to do browser's rendering engine (gecko in the case of firefox and webkit in the case of safari). Hope this clears things up for you.

Offline lorem ipsum generator

What would be a good offline alternative of the online Lipsum generator? It's frustrating when I'm not online and need some placeholder text for testing purpose. A CLI utility would be ideal, so that I can tailor the output to fit my needs.
In Office 2007 apps, you can type in
=lorem(n)
with n equaling the number of paragraphs of lorem ipsum you would like generated.
Django's lipsum addon seemed pretty straightforward. As I didn't want to install python just to run this script, I ported it to php.
Here's my PHP version:
http://pastebin.com/eA3nsJ83
If you have python available, google code has a CLI generator.
http://code.google.com/p/lorem/
Generate a long section online. Save it to a txt file. Refer to txt file when offline.
Textmate has a built in snippet to print this
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
From
lorem
I think you could use a Markov Text Generator, fed from the original Lorem Ipsum text. That way you should be able to find an implementation in any language you prefer.
You can try out if that will do, online, here.
Not sure about a command line version but there is a firefox extension that does Lorem Ipsum: https://addons.mozilla.org/en-US/firefox/addon/2064
Just checked and found that it pulls text from the website so it wouldn't work online... sorry about that, how about this though:
#!/usr/bin/env python
import sys
import random
try:
n = int(sys.argv[1])
except:
print 'Usage: %s num-words' % sys.argv[0]
words = open('/usr/share/dict/words').readlines()
for i in range(n):
print words[random.randrange(0, len(words))][:-1],
Word 2007 will produce a block of placeholder text when you type in =rand() and this hit the return/enter key. If you're looking for simple placeholder text, I'd go ahead and generate a bunch ahead of time and stick it in a text file.
Django includes the {% lorem %} tag as part of the contrib addons. It shouldn't be too hard to make a command-line version. Here's the source.
If you are on linux and have these tools:
pdf2ps | ps2txt < yourarticlecollection/someresearchpaper.pdf
:)
Seiously, most of the time I just copy&paste from research papers and articles that interests me. They have good amount of text that show white rivers and sometimes as incomprehensible as "Lorem ipsum".
On http://www.lipsum.com there are links to several offline Lorem Ipsum generators, about halfway down the frontpage. Or you could write one of your own in a matter of minutes.
Edit: This isn't accurate, I wrongfully assumed all of the linked lorem ipsum generators were offline ones, not only the LaTeX one.
For completeness: a Perl module to do this is called Text::Lorem, and there is also a Text::Lorem::More.
To make Juan’s answer more complete, there is fine wrapper to Text::Lorem module. If you’re on debian:
$> sudo apt-get install libtext-lorem-perl
And after this just type
$> lorem
There's a nice generator available from homebrew if you're on macOS. brew install lorem. My default python distribution is python 3 which caused a syntax error for the print statements. After fixing that, it was quite nice for my purposes.
At the bottom of the lorem ipsum generator you will find links to the generator for other usage. My understanding is the following can be used offline:
TeX Package
Java Class
But you may also find the following helpful:
WWW::Lipsum CPAN Module
Firefox Add-on
Dreamweaver Extension
GTK Lipsum
ActionScript3
Each of these, while requiring connectivity, reduce the load on the lipsum generator as they don't require loading the actual website.
Slightly off-topic: try to avoid using lorem ipsum for layout testing!
The letter frequencies in Latin are way different than in e.g. English or German. There's lots of 'i' and 'l', i.e. lots of narrow letters.
The alternative is to use VS Code to generate dummy text within html tag.
You can control how much text you want to generate. For example, type lorem10 then press Enter key it will generate 10 words of lorem text.
You can also generate a few paragraphs containing lorem text inside.
For example, p*3>lorem5 will create 3 paragraphs each containing 5 words of lorem text.