Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by Bhanu Priya
Page 34 of 107
How to allow no breaks in the enclosed text in HTML?
To prevent line breaks in enclosed text in HTML, the tag was traditionally used to force content onto a single line regardless of length. However, this tag is deprecated and not supported in HTML5. Modern HTML uses CSS properties like white-space: nowrap to achieve the same result with better standards compliance. Syntax Following is the deprecated syntax for the tag − Text content Following is the modern CSS approach − white-space: nowrap; The Deprecated Tag The HTML tag instructed browsers not to break the specified ...
Read MoreShould I write my script in the body or the head of the HTML?
In HTML, the script tag can be placed either in the section or in the section. The location affects when the script executes and how it interacts with page elements. Understanding the differences helps you choose the optimal placement for your JavaScript code. Syntax Following is the basic syntax for embedding JavaScript in HTML − //JavaScript code here You can place multiple script tags in an HTML document, and they can appear in the , , or both sections. Script in Head Section When scripts ...
Read MoreCreate a selectable list in HTML
The tag is used to create a drop-down list in HTML. A selectable list allows users to choose one or more options from a predefined set of values. By adding the multiple attribute to the element, users can select multiple options by holding the Ctrl key (Windows) or Cmd key (Mac) while clicking. Syntax Following is the basic syntax for creating a selectable list − Option Text 1 Option Text 2 To create a multiple selection list, add the multiple attribute − ...
Read MoreHow to use external “.js” files in an HTML file?
External JavaScript files are .js files containing JavaScript code that can be linked to HTML documents using the tag with the src attribute. This approach separates JavaScript code from HTML markup, making code more organized, reusable, and maintainable. Syntax Following is the syntax to link an external JavaScript file to an HTML document − The src attribute specifies the path to the external JavaScript file. The path can be relative (within your project) or absolute (full URL to external resources). Creating an External JavaScript File An external JavaScript file is ...
Read MoreWhat is the difference between id and name attributes in HTML?
The id and name attributes in HTML serve different purposes. The id attribute uniquely identifies an element for CSS styling and JavaScript manipulation on the client side, while the name attribute identifies form data sent to the server as name-value pairs in the HTTP request. Syntax Following is the syntax for using the id attribute − Content Following is the syntax for using the name attribute − The id must be unique within the document, while the name can be shared across multiple elements (e.g., radio buttons in the ...
Read MoreWhat are valid values for the id attribute in HTML?
The ID attribute in HTML is a unique identifier for an element. It helps in identifying a specific area on a web page for CSS styling, JavaScript targeting, and anchor linking. Let us first see the common uses of the ID attribute in HTML − Script reference − In JavaScript, we use the ID attribute to select and manipulate a specific element on the page using methods like getElementById(). CSS selector − The ID is used as a selector with the # symbol to apply styles to a single specific element on the page. ...
Read MoreAre HTML comments inside script tags a best practice?
Before trying to understand whether HTML comments inside script tags is a best practice or not, let us first discuss how comments work in HTML and the different ways to use them. Comments are helpful for understanding code, leaving reminders, and providing explanations. They also help in disabling statements temporarily when testing or working on a new feature. The browser ignores everything inside a comment tag and does not render it on the page. HTML Comment Syntax Following is the basic syntax for writing an HTML comment − The comment starts with ...
Read MoreWhat is CDATA in HTML?
The full form of CDATA is Character Data. It is a section in XML used to include blocks of text that should be treated as raw character data, not as markup. The XML parser does not parse the content inside a CDATA section, so tags and entities within it are ignored. A CDATA section starts with and ends with the delimiter ]]>. Everything between these markers is treated as plain text. CDATA sections cannot be nested. In HTML, CDATA sections are not used − browsers treat them as comments and do not display them. CDATA is primarily ...
Read MoreHow can I use multiple submit buttons in an HTML form?
Generally, HTML forms use a single submit button to save or send data. However, in some cases we need multiple submit buttons such as "Save", "Update", or "Delete" within the same form. Each button may perform a different action or send data to a different URL. To handle multiple submit buttons, we can use the formaction attribute, assign the same name with different value attributes, or give each button a different name. The server-side code then determines which button was clicked and processes accordingly. Syntax Using formaction Attribute Default Action ...
Read MoreHow to place two divs next to each other in HTML?
A DIV tag is a division element in HTML used to group and separate content on web pages. It helps organize text, images, navigation bars, and other elements into distinct sections. A tag consists of an opening and closing tag. Both are required. DIV elements can be styled with CSS or manipulated with JavaScript using the class or id attributes. Placing Two Divs Next to Each Other By default, elements are block-level and stack vertically. To place them side by side, we can use CSS properties like float, display: inline-block, or display: flex. ...
Read More