You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enhance XML documentation for href attribute and br tag usage (#47049)
* Initial plan
* Enhance XML documentation for href attribute and br tag usage
Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com>
* Update URLs to use learn.microsoft.com domain
Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com>
Copy file name to clipboardExpand all lines: docs/csharp/language-reference/xmldoc/recommended-tags.md
+13-2Lines changed: 13 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -118,6 +118,9 @@ Some of the recommended tags can be used on any language element. Others have mo
118
118
119
119
The compiler verifies the syntax of the elements followed by a single \* in the following list. Visual Studio provides IntelliSense for the tags verified by the compiler and all tags followed by \*\* in the following list. In addition to the tags listed here, the compiler and Visual Studio validate the `<b>`, `<i>`, `<u>`, `<br/>`, and `<a>` tags. The compiler also validates `<tt>`, which is deprecated HTML.
120
120
121
+
> [!NOTE]
122
+
> HTML tags like `<br/>` are useful for formatting within documentation comments. The `<br/>` tag creates line breaks, while other HTML tags provide text formatting. These tags work in IntelliSense tooltips and generated documentation.
123
+
121
124
-[General Tags](#general-tags) used for multiple elements - These tags are the minimum set for any API.
122
125
-[`<summary>`](#summary): The value of this element is displayed in IntelliSense in Visual Studio.
123
126
-[`<remarks>`](#remarks)\*\*
@@ -246,6 +249,10 @@ The `<value>` tag lets you describe the value that a property represents. When y
246
249
247
250
The `<para>` tag is for use inside a tag, such as [\<summary>](#summary), [\<remarks>](#remarks), or [\<returns>](#returns), and lets you add structure to the text. The `<para>` tag creates a double spaced paragraph. Use the `<br/>` tag if you want a single spaced paragraph.
248
251
252
+
Here's an example showing the difference between `<para>` and `<br/>`:
@@ -416,11 +423,15 @@ The XML output for this method is shown in the following example:
416
423
```
417
424
418
425
-`cref="member"`: A reference to a member or field that is available to be called from the current compilation environment. The compiler checks that the given code element exists and passes `member` to the element name in the output XML. Place *member* within quotation marks ("). You can provide different link text for a "cref", by using a separate closing tag.
419
-
-`href="link"`: A clickable link to a given URL. For example, `<see href="https://github.com">GitHub</see>` produces a clickable link with text :::no-loc text="GitHub"::: that links to `https://github.com`.
426
+
-`href="link"`: A clickable link to a given URL. For example, `<see href="https://github.com">GitHub</see>` produces a clickable link with text :::no-loc text="GitHub"::: that links to `https://github.com`. Use `href` instead of `cref` when linking to external web pages, as `cref` is designed for code references and won't create clickable links for external URLs.
420
427
-`langword="keyword"`: A language keyword, such as `true` or one of the other valid [keywords](../keywords/index.md).
421
428
422
429
The `<see>` tag lets you specify a link from within text. Use [\<seealso>](#seealso) to indicate that text should be placed in a See Also section. Use the [cref attribute](#cref-attribute) to create internal hyperlinks to documentation pages for code elements. You include the type parameters to specify a reference to a generic type or method, such as `cref="IDictionary{T, U}"`. Also, ``href`` is a valid attribute that functions as a hyperlink.
423
430
431
+
Here's an example showing the difference between `cref` and `href` when referencing external URLs:
@@ -440,7 +451,7 @@ The `cref` attribute in an XML documentation tag means "code reference." It spec
440
451
441
452
### href attribute
442
453
443
-
The `href` attribute means a reference to a web page. You can use it to directly reference online documentation about your API or library.
454
+
The `href` attribute means a reference to a web page. You can use it to directly reference online documentation about your API or library. When you need to link to external URLs in your documentation comments, use `href` instead of `cref` to ensure the links are clickable in IntelliSense tooltips and generated documentation.
0 commit comments