Grow your CSS skills. Land your dream job.

Extra indent when viewing source code in browser

  • # January 8, 2013 at 1:44 pm

    When I view my source code in a browser (i.e., Chrome and Opera), I’m getting extra indents in random spots of my code. Although I’ve formatted the code to my liking in my text editors of choice, both Chrome and Opera don’t seem to be fully honoring this formatting. I don’t get this issue when I view my code in FF, however.

    My initial inclination was that this issue was stemming from the text editor in which I wrote and formatted the code. The text editor I used initially was Dreamweaver. When I copied my code to Notepad++, however, and viewed my source code in both of the aforementioned browsers, I still had the same issue.

    Has anyone dealt with this issue before and if so how did you solve it? Thanks for any help or suggestions.

    # January 8, 2013 at 2:15 pm

    Just curious, why do you care about the minor indentation problem?

    I’ve had the same result happen before due to PHP but nothing that I really cared to worry about.

    # January 8, 2013 at 2:20 pm

    @chrisburton I suppose I’m very particular.

    # January 8, 2013 at 2:39 pm

    If you are including files via PHP, you’re definitely going to get odd indentation.

    # January 8, 2013 at 2:54 pm

    @TheDoc I wrote and saved my code as .html and I am still getting the odd indentation. Perhaps it’s a browser bug — I don’t know . . .

    # January 8, 2013 at 2:57 pm

    In Notepad++, try to paste it, remove all the white space and re-indent the code.

    # January 8, 2013 at 3:19 pm

    @chrisburton Yeah, I’ve tried that, too, but no cigar. I suppose I’d rather have odd indentation in my code than a bug-laden, hardly functioning web site.

    # January 8, 2013 at 3:55 pm

    You may be seeing tabs and not spaces. Most text editors have a setting to show tabs as X-number of spaces. For instance, let’s say your text editor is set to show a tab as 2 spaces while a browser source viewer would render a tab as 4 spaces.This is where the inconsistency would arise. Also, most text editors have a setting to automatically convert tabs to spaces on save, which would eliminate the inconsistency (if that’s what’s actually causing it).

    As I haven’t seen your site, this is just speculation.

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".