New line in title attribute? [duplicate] - html

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How can I use a carriage return in a HTML tooltip?
Currently if I want to insert a new line in title=, I would do this:
<span id="dummy" title="Hello
World!">Dummy</span>
Live demo: http://jsfiddle.net/DerekL/XFMfx/
But this looks really weird to me, and it just messes up my HTML file. Just imagine all those new lines in it.
So I'm wondering if there is a better way to achieve this, so that it won't mess it up.
Thanks.

This is not possible. There are no cross-browser solutions. If you want a line break in your title attribute, you'll have to use JavaScript.

As of Firefox 12 (which is the current Aurora version), this is (finally) supported. See the related bug.

Related

Why escape code \n, \r in JSON doesn't work? [duplicate]

This question already has answers here:
Line break in HTML with '\n'
(10 answers)
Closed 5 years ago.
I know I am revisiting an old problem but I hope there are new answers. I am using angular/Modal to display a paragraph from a .json file. I need to insert a newline for each paragraph when displayed in the browser. I have tried \n ,\r, This is a sample of an entry:
"termsAndServiceContent": "1. TERMS OF USE: \n These Terms of Use (Terms) govern your access or use, from within the United States and its territories and possessions ...........\r <br/> By accessing or using the Services, you confirm your agreement to be bound by these Terms........",
I expected to get a new line for the \n and \r but nothing happens. How can I get the browser to recognize the escape characters?
I guess the question is quite similar and I did mentioned that its an old issue. I really didn't see this
https://stackoverflow.com/questions/39325414/line-break-in-html-with-n
question before but I still don't believe the answers address my issue. I am not using plain HTML I am using Angular and my render code looks like this:
<a (click)="showTermAndServicesWindow($event)">{{LOCALIZATION.tos}}</a>
where .tos is my .json file and that's all the HTML I want in the view....also I don't want to do any HTML templating in the .ts modules.
Use the HTML code <br> for new lines, and make sure you use <div [innerHTML]="theHtmlString"></div> to insert it as HTML.

How can I write my own tags? I want to write something like div/span or any other html tags [duplicate]

This question already has answers here:
Is there a way to create your own html tag in HTML5?
(18 answers)
Closed 6 years ago.
I don't want it to be specific to one project, I am looking for any way to write a tag which can be used globally?
I don't want something like :
richa {...styles} [Style.css]
<richa>Contents </richa> [index.html]
I want to write it the way, div/span etc are written to be used globally.
How do I do that?
Please follow the link for your query.Hope this will help, let me know if this is working for you.
Is there a way to create your own html tag in HTML5?

Which HTML5 attributes can be a URL? [duplicate]

This question already has answers here:
COMPLETE list of HTML tag attributes which have a URL value?
(2 answers)
Closed 7 years ago.
Obviously a href and img src. Are there any others? How would you search for this?
One of them is certainly srcset on the picture element, well its contains a URL but is maybe one.
Not sure how to properly search for one, maybe browsers have implemented some logic like that?
Mh, at least servo has implemented a generic get_url_attribute function which tries to converts any attribute to a URL https://github.com/servo/servo/blob/master/components/script/dom/element.rs#L997 sorry no help here

How do I post a sample of PHP code on my webpage? [duplicate]

This question already has answers here:
How do I display PHP code in HTML?
(4 answers)
Closed 8 years ago.
I want to post a sample of some code I've written. I'm aware of the <code></code> tags, but the problem is that the PHP inside will actually get interpreted and executed when the page loads. What is the way around this?
You should be encoding your entities anyway, which will prevent PHP from parsing them.
Instead of <?php, use <php.
See also: What Are The Reserved Characters In (X)HTML?
If you want to display the source of an entire PHP script, you can use the show_source() function. For example,
show_source("sample.php");
If you want to display the code of the current page, you can do something like
show_source(__FILE__);
You can also use hightlight_file() in place of show_source().
If you were looking to display just a random line of code, you can use htmlspecialchars() or htmlentities(). For example,
htmlspecialchars(" <b> This will be a bold text </b> ");
A tip on the aside: Please look around, and google atleast once before asking. :)

Make new HTML tag which acts like an exist tag with extras [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Custom html tags — Is there a better way?
I using finding myself very frequently writing: <pre class="cpp">, when using highlight.js. Just out of interest, is there any way I could make a new tag, say <pcpp>, which would act exactly like <pre class="cpp">, just using CSS?
I can imagine this would be possible with JavaScript, but I would not want to start changing all my tags every time the page is loaded.
No, but if you are using JavaScript anyways then you can apply the cpp class to all <pre> elements if you're finding that you're applying that class to every <pre> element on the page:
// Using jQuery
$('pre').addClass('cpp');
Making a new element would probably cause major issues with the page, much more trouble than it's worth, and it wouldn't validate as HTML anymore.
No you are not supposed to create new tag in HTML