I don't post in this part very often.

mrp2049

Senior Member
And there is a reason for that! Jaz, Glen, Andy etc, you all frighten me with your ability/knowledge of coding.

I do however have a question, I tried googling it, but its rather difficult mostly because I don't know how to describe it!

I am coding something for a friend and I am trying my best to learn how it all works, but I am struggling as there is a big mess of code and I want him to be able to edit certain sections of text, but also find them a little easier.

<div class="aboutme">

blah

</div>
now thats what I want it to say, but if I want to help him find it can I use the <-- or <!-- whichever one it is (if you know that would also help) so the code looks something like this

<!-- This is the space for your about me text -->

<div class="aboutme">

blah

</div>

with the text inside <!-- obviously not seen on screen.

Is that correct?

Sorry if this is real idiot grade stuff, I'm new at this.
 
If he's editing the code in a text-editor, use server side comments so that they don't uglify your rendered markup.


PHP:
<? /* This is the space for your about me text */ ?>

<div class="aboutme">

blah

</div>
 
<!-- Fill this space with comments -->

It has the exclamation mark, and indeed it is a comment which in alot of text editors will show up in different colours to help distinguish it, aswell as being able to make it stand out with asterix' or similar.
 
Harry said:
If he's editing the code in a text-editor, use server side comments so that they don't uglify your rendered markup.


PHP:
<? /* This is the space for your about me text */ ?>

<div class="aboutme">

blah

</div>

Why do normal HTML comments uglify rendered markup :) ?
 
Renniks said:
Why do normal HTML comments uglify rendered markup :) ?

If they're comments like that, there's no reason for them to appear in rendered source. They serve no purpose to anyone other than people who edit the original files. A comment like <!-- /wrapper --> serves some use to people viewing source, but <!-- Info about you goes here --> is extraneous and unnecessary.
 
Cheers, was under the impression you meant <! -- wrapper --> type comments also should go in <? /* */ ?>
 
Sooo to clarify

If the comment you are making is directed at your friend or anyone just intended to see it in a text editor
use

<? /* COMMENT GOES HERE */ ?>

If the comment is more section headings etc. you can use that, or you can use

<!-- COMMENT GOES HERE -->

As that is visible in the online source code, aswell as in text editors.
 
Yeah, if the comment is an instruction of some info for a developer or someone who will be actively editing the code at its source, use a server side comment. (<? /* */ ?> being PHP).

If the comment will be of use to anyone just browsing the rendered source then use a HTML comment.
 
To make it even easier for your friend and save him having to phone you when he accidentally deletes a closing tag or something use one of these:

Free and simple CMS CushyCMS (free version!)
Perch - A really little content management system (CMS)

Basically you don't have to set up a CMS and get all technical Simply the bits of your html you want to be editable give them a class of - class="cushycms" so you'd have <div class="aboutme cushycms">

Then you pop your ftp info into your cushy (or pearch) account bobs your uncle fannies your aunt and you mate can log on and easily edit in a WYSIWYG editor.
 
Harry is using the best method I would say if its server side.

However if your commenting a style sheet you can use the /* WHATEVER HERE */

Comments are also used if you are testing a page. Instead od deleting code and losing it you can use the start and end comment commands to just comment out code. You can then remove them if needs be to make the code active again.
 
That's why this section isn't scary. Much more clear cut answers most of the time ^_^ so many questions, but lots of answers
 
However if your commenting a style sheet you can use the /* WHATEVER HERE */
Really I would go with <?php //CSS comment goes in here ?> TBH, and then get fancy with some coding and mod-rewrite.

But yeah Harry's spot on, unless it is an Ebay template due to Ebay having shocking code and it not really any benefit for any reason.

But the reason server side comments should be used, bare in mind the page in this example would need a .php extension or the server would need to be told to parse whatever extension is for PHP code otherwise all you will get is <?php //comment ?> outputted to the user as it would be parsed as HTML and not PHP, but the main reason is <!--comment --> adds bytes that have to be downloaded when they don't need to.

But dude don't get worried about posting I, and I'm pretty sure everyone else on that list including all the others listed under etc..., value opinions I wont think any less of you for asking a question or getting it wrong. Everyone learns that way, including me from time to time. ;)
 
Jazajay said:
But dude don't get worried about posting I, and I'm pretty sure everyone else on that list including all the others listed under etc..., value opinions I wont think any less of you for asking a question or getting it wrong. Everyone learns that way, including me from time to time. ;)

I am totally blown away by everyones response! And it has been muchly appreciated!

I will be back to hound you coding nerds soon enough!
 
Back
Top