This question already has answers here:
Is whitespace allowed within XML/HTML tags?
(4 answers)
Closed 8 years ago.
I'm building a slicer for deserializing html and xml. The question is - is it legal in either language to put a space after angle bracket and still have it count as a tag? For example
< div>
Or should I just consider that plain text?
And yes, I tried searching web for this but even after browsing through w3, I couldn't spot an explicit answer.
The HTML spec from WHATWG indicates the opening bracket must be immediately followed by the tag name.
The XML spec from W3C has the same requirements.
You may not have space leading the tag name. However, there can be any amount of space between the end of the tag name and the closing bracket. The following is valid:
<p ></p >
<p
></p>
No this is not legal,
For example this,
<html>
<head>
</head>
<body>
<h1>Hey sup man</h1>
< div><p>hey sup</p></div>
</body>
</html>
outputs this to the browser,
Hey sup man
< div>
hey sup
Related
This question already has answers here:
How to display raw HTML code on an HTML page
(30 answers)
Closed 1 year ago.
Is it possible to have display tags with a paragraph? For example, I want to display the text '<c>' on my page within a p tag. however, the <c> is parsed as a tag instead of raw text.
<p1>Microsoft Windows<c></p1>
In this example, I want the <c> to be displayed as text rather than being used as a tag.
In order to do that, you need to use HTML codes for the symbols '<>'. The code for '<' is < and that for '>' is >, so your code should be:
<p> Microsoft Windows <c></p>
You can use HTML Entitites.
The basic syntax goes like this:
<some_tag> Some text &entity_code </some_tag>
Talking about your case, it would go like
<p> Microsoft Windows <c></p>
This question already has answers here:
Reason why I can't insert a comment inside the HTML tag?
(4 answers)
Closed 2 years ago.
This is weird, I just found my code in HTML not working
<img
src="animal-chihuahua-cute-39317.jpg"
align="center"
border="3"
hspace="50"
vspace="10" <!--attribute indicates amount of space to the top and bottom on the image-->
alt="doggy"
width="250"
height="250"
/>
I also read an article on StackOverflow: Reason why I can't insert a comment inside the HTML tag?
still not clear with the explanation. Can someone help me with this!!
You can't use a tag inside a tag attribute list. < aren't parenthesis: you can't nest them, you need to close one before you open another. Comments in html are like all other tags, except they are not interpreted and displayed by the browser, and as such they must adhere the rules of all tags
All language have rules for where comments can and cannot be placed. You normally can't use a comment in a quoted string literal for example. Some language restrict you to comment only at the end of the lines. Some don't allow comments inside other comments. HTML don't allow them inside tag declarations (between < and the corresponding >). Just accept it.
This question already has answers here:
How can I display html tags inside an HTML document?
(8 answers)
Closed 3 years ago.
I'm just starting around with HTML and CSS and I have a probably stupid question but I that I haven't found an answer for.
Lets say I want to show this on my website:
<p>Coder and developer</p>
as simple as that, but when I write that inside the <p> tag it recognise the other <p> tag that I want to use just as text.
Probably the solution is very straight forward but I haven't found it yet as I said.
You may be done this way using <pre> </pre> tag:
<pre><p>Coder and developer</p></pre>
You can't add a "p" tag in between another p tag.
HTML couldn't parse it.
If you want to create above template then use a "div" and then insert a "p" tag into it.
This question already has answers here:
Is HTML case sensitive?
(6 answers)
Closed 8 years ago.
So the thing is, I am currently analyzing html documents by reading them though java and I see that the p tag is one of the most commonly used tags. I know that it's there to provide a new line, but what I don't know is why in some documents I see
<P>Hello world!</P>
and in others
<p>Hello world!</p>
Sometimes both are even used in the same document.
It seems to have exactly the same effect but I am just wondering if there is any reason these two variations exist.
There is no difference.
In HTML, elements are case-insensitive.
However, in XHTML, you must use lowercase.
http://www.w3.org/TR/html-markup/documents.html#case-insensitivity
HTML is case-insensitive. as you can see in the documentation.
They're same. It does not matter if its lowercase or uppercase or even mixed.
<p></p> Is used for a new paragraph
HTML is case-insensitive, which means you can use both spellings.
there is no difference. Inherited from SGML, HTML is not case sensitive for elements and attributes.
I prefere to use the lower-case form... Else I've the impression that the coder is shouting at me ^^
This question already has answers here:
How to escape < and > inside <pre> tags
(8 answers)
Closed 9 years ago.
I have some html that uses a few "pre" tags to preserve code snippets, using "html" as the lang. For the most part, it works, but in one specific instance, namely:
<pre lang="html">
<li><a runat="server" href="~/Images">Images</a></li>
</pre>
Instead of preserving the snippet, it shows a bullet and a hyperlinked "Images" - what the deuce?
The whole shebang can be seen, malformed, beneformed, and/or mutilated at: http://jsfiddle.net/7BSLc/
<pre> is for telling the browser to keep white space formatting and doesn't tell the browser not to render html elements within. you need to encode the html you're trying to put in. You can use encoded values for the angle brackets < and it will render the html as text instead of randering the html. http://jsfiddle.net/7BSLc/9/
It is ugly, but it works:
<li><a runat="server" href="~/Images">Images</a></li>
HTML-Elements are interpreted within pre-elements! You should use HTML-entities for HTML-specific chars.