- This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
Viewing 5 posts - 1 through 5 (of 5 total)
- The forum ‘CSS’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
hi,
I never figured this out, what is meant by encoding special characters?
there are reserved characters in HTML, ok we know it
" "
' '
& &
< <
> >
but what all should we encode in the body, text etc.?
every single asterisk, brackets, quotation mark, exclamation mark … I dunno
even stuff like this?
(
)
*
!
?
[
]
/
+
-
I think people generally encode things that could break their code… for example:
The apostrophe contained within “isn’t” will close the echo and cause some kind of error. Therefore that would be changed to something like:
And the same with HTML. In order to get a less than character in these forums ( < ) we have to use the code, otherwise it will be seen as code. So something like a * and () only needs to be encoded where appropriate.
for the most part, I just deal with <, >, & and ‘
Yeah, that’s fine :)
When you create a web page, send it through the validator. If it succeeds, you’re all good.
I don’t think I’ve ever encoded:
(
)
*
!
?
[
]
/
+
-
Via the html codes. If I want to escape something in php, I’ll do something like escape($foo);
jQuery seems to escape strings (at least most that I’ve used) for me. It’s pretty smart: for example
$('body').prepend('&');
$('body').prepend('&');
will put
&
in the body, which will display as &
If I want to use a ‘ in a js string. Instead of doing this
$('body').prepend('This won't work');
I’ll do this:
$('body').prepend("This won't work");
You don’t need to really worry about all that too much :p
@jamy_za But…but..what about..
Edit: Well, I should not skim the article. However, I don’t think everything is necessary to encode. If you have a word that has an apostrophe, use double quotes. You should probably use them anyway just to avoid the issue.