This question already has answers here:
How to display HTML tags as plain text [duplicate]
(11 answers)
Closed 9 years ago.
I'm currently creating a website and I need to show an example of code on the page. simply putting it within a p obviously doesn't work, as the tags do not display. Is there anyway to get them to display on the webpage?
You can put code in <code> tags (if what you're displaying is in a programming language) just to get something going quickly. If what you're displaying is Markup (HTML), you'll have to replace < with < and > with >.
You can also look at tools like SyntaxHighlighter if you want your code to be more readable.
Related
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?
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
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. :)
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
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Using custom HTML Tags
is their an easy way to add custom tags in HTML , I'm looking at some cool filters that I'd only like to apply to certain parts of my web page .
Yes we can add custom tags in Html.
<customTag>Hello world</customTag>
But IE wont detect custom tags .
Just add this head of your document.
<script>document.createElement('customTag');</script>
The above example is a part of html5shiv.
This is one more article which I found to for IE.
No. A custom tag is not an HTML tag. If you use one your document stops being HTML.
Use the (semantically) most appropriate HTML element, then add attributes (generally class) to distinguish it for your script/stylesheet.