Skip to main content
keithh55578997
Participant
July 12, 2017
Answered

doctype declaration negatively affecting code formatting

  • July 12, 2017
  • 2 replies
  • 318 views

Hello -

I've searched across multiple forums for a solution to this issue, but was unable to come across anything.

I am using Dreamweaver CC 2017 and I'm attempting to apply code formatting. I've discovered that including the doctype html declaration tag in the HTML file messes with the formatting rules, specifically with closing tags. I've already reviewed my code formatting settings, and they are as they should be.

In example 1 below, the formatting is working properly. In example 2, the closing tags are not aligning with the opening tags properly (this is the issue I'm having; assume ... is the code within head tags).

Example 1:

<div id="container">

     <p>My content goes here.</p>

</div

Example 2:

<!doctype html>

...

<div id="container">

     <p>My content goes here.</p>

   </div>

Notice how the div tags don't align vertically? Is there any way I can have the code formatting tool work properly without having to delete and re-add the doctype declaration every time? Thanks!

This topic has been closed for replies.
Correct answer Nancy OShea

Whether or not closing tags line up perfectly has zero effect on performance or how browsers render the page.  On the other hand, a missing doc type can effect performance and rendering.  So I can live with less than perfect code formatting.  But I can't live without a doc type.

Nancy

2 replies

Nancy OShea
Community Expert
Nancy OSheaCommunity ExpertCorrect answer
Community Expert
July 12, 2017

Whether or not closing tags line up perfectly has zero effect on performance or how browsers render the page.  On the other hand, a missing doc type can effect performance and rendering.  So I can live with less than perfect code formatting.  But I can't live without a doc type.

Nancy

Nancy O'Shea— Product User & Community Expert
keithh55578997
Participant
July 13, 2017

I totally agree, Nancy; functional code is much more important than aesthetic code. It's just my OCD for clean code that makes me curious as to why this is occurring in DW CC 2017.

Jon Fritz
Community Expert
Community Expert
July 12, 2017

I just tested and do not have the same issue. My <div> tags properly indent when Apply Source Formatting is used with the correct doctype declaration in place.

Have you made sure your code is free of errors via the validator under File > Validate > Current Document W3C or http://validator.w3.org/nu

Many of DW's features simply will not work correctly if you have structural code errors, ASF may be one of them.

keithh55578997
Participant
July 13, 2017

Hi, Jon -

I have resolved all W3C validation errors, and the vertical misalignment still occurs with tags when the doctype declaration is included. Any other ideas? Thanks!