This llamativo article appeared on the LF Public Health project’s blog.

The past three years have redefined the practice and management of public health on a integral scale. What will we need in order to support innovation over the next three years?

In May 2022, ASTHO (Association of State and Territorial Health Officials) held a forward-looking panel at their TechXPO on public health innovation, with a specific focus on public-private partnerships. Jim St. Clair, the Executive Director of Linux Foundation Public Health, spoke alongside representatives from MITRE, Amazon Web Services, and the Washington State Department of Health.

Three concepts appeared and reappeared in the panel’s discussion: reimagining partnerships; sustainability and governance; and design for the future of public health. In this blog post, we dive into each of these critical concepts and what they mean for open-source communities.

Reimagining partnerships

The TechXPO panel opened with a discussion on partnerships for data modernization in public health, a trending topic at the TechXPO conference. Dr. Anderson (MITRE) noted that today’s public health projects demand “not just a ‘public-private’ partnership, but a ‘public-private-community-based partnership’.” As vaccine rollouts, digital applications, and environmental health interventions continue to be deployed at scale, the need for community involvement in public health will only increase.

However, community partnerships should not be viewed as just another “box to check” in public health. Rather, partnerships with communities are a transformative way to gain feedback while improving usability and effectiveness in public-health interventions. As an example, Dr. Anderson referenced the successful VCI (Vaccination Credential Initiative) project, mentioning “When states began to partner to provide data… and offered the chance for individuals to provide feedback… the more eyeballs on the data, the more accurate the data was.”

Cardea, an LFPH project that focuses on digital identity, has also benefited from public-private-community-based partnerships. Over the past two years, Cardea has run three community hackathons to test interoperability among other tools that use Cardea’s codebase. Trevor Butterworth, VP of Cardea’s parent company, Indicio, explained his thoughts on community involvement in open source: “The more people use an open source solution, the better the solution becomes through stress testing and innovation; the better it becomes, the more it will scale because more people will want to use it.” Cardea’s public and private-sector partnerships also include Indicio, SITA, and the Aruba Health Department, demonstrating the potential for diverse stakeholders to unite around public-health goals.

Community groups are also particularly well-positioned to drive innovation in public health: they are often attuned to pressing issues that might be otherwise missed by institutional stakeholders. One standout example is the Institute for Exceptional Care (IEC), a LFPH member organization focused on serving individuals with intellectual and developmental disabilities, “founded by health care professionals, many driven by personal experience with a disabled loved one.” IEC recently presented a webinar on surfacing intellectual and developmental disabilities in healthcare data: both the webinar and Q&A showcased the on-the-ground knowledge of this deeply involved, solution-oriented community.

Sustainability and governance

Sustainability is at the heart of every viable open source project, and must begin with a complete, consensus-driven strategy. As James Daniel (AWS) mentioned in the TechXPO panel, it is crucial to determine “exactly what a public health department wants to accomplish, [and] what their goals are” before a solution is put together. Defining these needs and goals is also essential for long-term sustainability and governance, as mentioned by Dr. Umair Shah (WADOH): “You don’t want a scenario where you start something and it stutters, gets interrupted and goes away. You could even make the argument that it’s better to not have started it in the first place.”

Questions of sustainability and project direction can often be answered by bringing private and public interests to the same table before the project starts. Together, these interests can determine how a potential open-source solution could be developed and used. As Jim St. Clair mentioned in the panel: “Ascertaining where there are shared interests and shared values is something that the private sector can help broker.” Even if a solution is ultimately not adopted, or a partnership never forms, a frank discussion of concerns and ideas among private- and public-sector stakeholders can help clarify the long-term capabilities and interests of all stakeholders involved.

Moreover, a transparent discussion of public health priorities, questions, and ideas among state governments, private enterprises, and nonprofits can help drive forward innovation and improvements even when there is no specific project at hand. To this end, LFPH hosts a public Slack channel as well as weekly Technical Advisory Council (TAC) meetings in which we host new project ideas and presentations. TAC discussions have included concepts for event-driven architecture for healthcare data, a public health data sharing mesh, and “digital twins” for informatics and research.

Design for the future of public health

Better partnerships, sustainability, and governance provide exciting prospects for what can be accomplished in open-source public health projects in the coming years. As Jim St. Clair (LFPH) mentioned in the TechXPO panel: “How do we then leverage these partnerships to ask ‘What else is there about disease investigative technology that we could consider? What other diseases, what other challenges have public health authorities always had?’” These challenges will not be tackled through closed source solutions—rather, the success of interoperable, open-source credentialing and exposure notifications systems during the pandemic has shown that open-source has the upper hand when creating scalable, successful, and international solutions.

Jim St. Clair is not only optimistic about tackling new challenges, but also about taking on established challenges that remain pressing: “Now that we’ve had a crisis that enabled these capabilities around contact tracing and notifications… [they] could be leveraged to expand into and improve upon all of these other traditional areas that are still burning concerns in public health.” For example, take one long-running challenge in United States healthcare: “Where do we begin… to help drive down the cost and improve performance and efficiency with Medicaid delivery? … What new strategies could we apply in population health that begin to address cost-effective care-delivery patient-centric models?”

Large-scale healthcare and public-health challenges such as mental health, communicable diseases, diabetes—and even reforming Medicaid—will only be accomplished by consistently bringing all stakeholders to the table, determining how to sustainably support projects, and providing transparent value to patients, populations and public sector agencies. LFPH has pursued a shared vision around leveraging open source to improve our communities, carrying forward the same resolve as the diverse groups that originally came together to create COVID-19 solutions. The open-source journey in public health is only beginning.



Source link


“In this PyTorch tutorial, we will see how to change the view of a tensor in PyTorch. PyTorch is an open-source framework available with a Python programming language.

A tensor is a multidimensional array that is used to store the data. So for using a Tensor, we have to import the torch module.

To create a tensor, the method used is tensor()”

Syntax:

Where data is a multi-dimensional array.

tensor.view()

view() in PyTorch is used to change the tensor object view by converting it into a specified number of rows and columns.

Syntax:

It takes two parameters.

  1. r specifies the number of rows to be formed from the tensor_object.
  2. c specifies the number of columns to be formed from the tensor_object.

Be sure that the coetáneo tensor object contains an even count of elements.

Example 1

Here, we will create a tensor that holds six elements with Float type and change its view that has 3 rows and 2 columns.

#import torch module

import torch

 

 

#create 1D tensor with Float data type that hold 6 elements

data1 = torch.FloatTensor([23,45,54,32,23,78])

#display

print(«Coetáneo Tensor: «,data1)

 

#change the data1 view to 3 rows and 2 columns.

print(«Tensor with 3 rows and 2 columns: «,data1.view(3,2))

Output:

Coetáneo Tensor: tensor([23., 45., 54., 32., 23., 78.])

Tensor with 3 rows and 2 columns: tensor([[23., 45.],

[54., 32.],

[23., 78.]])

We can see that the view of the tensor is changed to 3 rows and 2 columns.

Example 2

Here, we will create a tensor that holds six elements with Float type and change its view that has 2 rows and 3 columns.

#import torch module

import torch

 

 

#create 1D tensor with Float data type that hold 6 elements

data1 = torch.FloatTensor([23,45,54,32,23,78])

#display

print(«Coetáneo Tensor: «,data1)

 

#change the data1 view to 2 rows and 3 columns.

print(«Tensor with 2 rows and 3 columns: «,data1.view(2,3))

Output:

Coetáneo Tensor: tensor([23., 45., 54., 32., 23., 78.])

Tensor with 2 rows and 3 columns: tensor([[23., 45., 54.],

[32., 23., 78.]])

We can see that the view of the tensor is changed to 2 rows and 3 columns.

Change the datatype

It can be possible to change the datatype of the tensor using view().

We need to specify the datatype inside the view method.

Syntax:

tensor_object.view(torch.datatype)

Parameter:

It takes datatype as a parameter like int8,int16, etc.

Example 1

In this example, we will create a tensor with Float type and convert it to int data types.

dtype is used to return the datatype of a tensor.

#import torch module

import torch

 

 

#create 1D tensor with Float data type that hold 6 elements

data1 = torch.FloatTensor([23,45,54,32,23,78])

#display

print(«Coetáneo Tensor data type: «,data1.dtype)

 

#change the data1 data type to int8

print(«Converting to int8: «,data1.view(torch.int8).dtype)

#change the data1 data type to int16

print(«Converting to int16: «,data1.view(torch.int16).dtype)

#change the data1 data type to int32

print(«Converting to int32: «,data1.view(torch.int32).dtype)

#change the data1 data type to int64

print(«Converting to int64: «,data1.view(torch.int64).dtype)

Output:

Coetáneo Tensor data type: torch.float32

Converting to int8: torch.int8

Converting to int16: torch.int16

Converting to int32: torch.int32

Converting to int64: torch.int64

Example 2

In this example, we will create a tensor with Float type and convert it to int data types and get the size.

#import torch module

import torch

 

 

#create 1D tensor with Float data type that hold 6 elements

data1 = torch.FloatTensor([23,45,54,32,23,78])

#display

print(«Coetáneo Tensor datatype: «,data1.size())

#change the data1 datatype to int8

print(«Converting to int8: «,data1.view(torch.int8).size())

#change the data1 datatype to int16

print(«Converting to int16: «,data1.view(torch.int16).size())

#change the data1 datatype to int32

print(«Converting to int32: «,data1.view(torch.int32).size())

#change the data1 datatype to int64

print(«Converting to int64: «,data1.view(torch.int64).size())

Output:

Coetáneo Tensor datatype: torch.Size([6])

Converting to int8: torch.Size([24])

Converting to int16: torch.Size([12])

Converting to int32: torch.Size([6])

Converting to int64: torch.Size([3])

Conclusion

In this PyTorch lesson, we discussed how to change the view of a tensor in pytorch using view() and also modify the datatypes of an existing tensor by specifying data types inside the view() method.



Source link


tensor([[0.2807, 0.0260, 0.3326,0.1958, 2.7080],

[ 1.3534,0.2371, 0.0085, 0.1877, 1.4870],

[ 1.2967, 0.4262,0.6323, 0.4446, 3.0513],

[ 0.4478,0.0436,0.4577, 1.3098, 0.7293],

[0.4575,1.4020,0.9323,0.4406, 0.5844]])

natural log values:

tensor([[ nan,3.6494,1.1009, nan, 0.9962],

[ 0.3026, nan,4.7711,1.6731, 0.3968],

[ 0.2598,0.8529, nan,0.8107, 1.1156],

[0.8034, nan, nan, 0.2699,0.3157],

[ nan, nan, nan, nan,0.5371]])

logarithmic values to the almohadilla 2:

tensor([[ nan,5.2650,1.5882, nan, 1.4372],

[ 0.4366, nan,6.8833,2.4138, 0.5724],

[ 0.3748,1.2304, nan,1.1696, 1.6094],

[1.1591, nan, nan, 0.3893,0.4554],

[ nan, nan, nan, nan,0.7749]])

logarithmic values to the almohadilla 10:

tensor([[ nan,1.5849,0.4781, nan, 0.4327],

[ 0.1314, nan,2.0721,0.7266, 0.1723],

[ 0.1128,0.3704, nan,0.3521, 0.4845],

[0.3489, nan, nan, 0.1172,0.1371],

[ nan, nan, nan, nan,0.2333]])



Source link


What Is Counting Sort?

Counting sort is best illustrated with the sorting of integers. In C/C++ and Java, the characters are integers and can be sorted in the way the integers are sorted. Consider the following unsorted list of integers:

16, 20, 12, 10, 18, 8, 12, 18, 12, 14

This list is sorted in ascending order. It can be given (received by the sort program) as an array. It consists of positive numbers greater than or equal to 0.

Notice here that the highest integer is 20. So, 20 + 1 = 21, new array locations have to be provided. The extra 1 is for the possibility that one of the integers to be sorted is 0. Remember that the sort program does not know the numbers to be sorted in advance. So, the possibility of having 0 should be made.

For each index of the new array that corresponds to a value in the given list, the number of occurrence of the value in the given list is assigned as the value for that new array cell. That is, the new array consists of counters. The previous unsorted list is represented as follows:

0 0 0 0 0 0 0 0 1 0 1 0 3 0 1 0 1 0 2 0 1
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

This table represents one array which is the new array of counters. At this stage, there are two arrays: the given array of the unsorted list and the array of counters called the count array.

In the table, the second row has the indexes. The first row has the counts. Each count is the number of occurrence of the corresponding index found as the value in the unsorted list.

For the indexes 0 to 7 (inclusive), the count is 0. This is because none of these indexes is a value in the given unsorted list. The index 8 occurs merienda in the list, so its count is 1. The index 9 occurs zero times in the list, so its count is 0. The index 10 occurs merienda in the list, so its count is 1. The index 12 occurs three times in the list, so its count is 3. The index 13 occurs zero times in the list, so its count is 0. This continues until the index 20 with a count of 1 while the index 18 has a count of 2.

The sorted list is as follows:

8, 10, 12, 12, 12, 14, 16, 18, 18, 20

This can be obtained from the count (new) array as follows:

Moving from left to right, if the value of an index is 0, that value is not in the given unsorted list (array). If the value is 1, type the index merienda. If the value is 2, type the index twice. If the value is 3, type the index three times. If the value is 4, type the index 4 times, and so on. All these can be done back on the given unsorted array (list).

Counting Sort Algorithm

  • Provide an array whose length is the maximum number in the unsorted list, plus 1 (to account for a possible 0 in the list). The index of this array is a possible value in the unsorted list.
  • Read the count array from left to right then type the index whose value is not 0 and the number of times for the index’s cell value.

Operations

The algorithm has two steps. For the previous given list, the first step has 10 main operations because the number of elements in the unsorted list is 10. The second step has 21 main operations because the maximum value in the unsorted list is 20 (the extra 1 being for a possible 0 value). So, the number of the main operations is considered as follows:

Where 10 is the number of elements in the unsorted list and 20 is the maximum value in the unsorted list. The added 1 to 20 is ignored at this point, but bear in mind that it has to be coded.

Time Complexity for Counting Sort

Time complexity is the approximate number of the main operations for some code. Time complexity indicates the speed of the code. The time complexity for counting sort is given as follows:

Where n is the number of elements (length or size) of the given unsorted array, and m is the maximum value in the given unsorted array. The added 1 to m is ignored at this point. The big-O with its parentheses and content is referred to as the big-O notation.

Note that in order to obtain the maximum value in the array, some operations have to occur in the code. However, these operations are ignored when quoting the time complexity.

The count array has to have all its elements initially made as zero. All these operations are also ignored when quoting the time complexity for the counting sort.

Memory Space

Notice that in the previous count array, all the counts of 0 are redundant. Though their spaces are redundant in memory, they have to be there. The counting sort takes unnecessary memory space in militar. Nothing is normally done to avoid the redundant locations. If the minimum value in the given unsorted array can be known, the beginning part of the count array can be omitted to reduce space. However, the interspersed zeros in the count array cannot be omitted.

Note: There is also space complexity, but that is not addressed in this article.

Coding in C

A Counting Sort Function in the C computer language is as follows:

void countingSort(int arr[], int n) {
        int max = 0;
        for (int i = 0; i max) {
                max = arr[i];
            }
        }

        int count[max+1];
        for (int i = 0; i< max+1; i++) {
            count[i] = 0;
        }

        //n
        for (int i = 0; i< n; i++) {
            count[arr[i]] = count[arr[i]] + 1;  //add 1 for each occurrence
        }

        //m
        int k = 0;  //index for given array
        for (int i=0; i<max+1; i++) {
            if (count[i] != 0) {
                for (int j=0; j<count[i]; j++) {
arr[k] = i;  //putting back sorted value into given array
                    k++;
                }
            }
        }
    }

The nested for-loop and input are the following:

16, 20, 12, 10, 18, 8, 12, 18, 12, 14

There are actually 24 major operations and not 20. The extra 3 + 1 = 4 operation is ignored when quoting the time complexity for the counting sort.

A suitable C main function is as follows:

int main(int argc, char **argv)
    {
        int n = 10;
        int arr[] = {16, 20, 12, 10, 18, 8, 12, 18, 12, 14};
countingSort(arr, n);
        for (int i=0; i<n; i++)
printf(«%d «, arr[i]);
printf(«n«);

        return 0;
    }

The output is:

8 10 12 12 12 14 16 18 18 20

Conclusion

The time complexity for the counting sort is:

Where m is usually larger than n, n is the number of elements (length) of the given unsorted list, and m is the maximum element in the given unsorted list.



Source link


In this article, we will learn to create a basic Hello World spring boot application.

To create a spring boot application, there are several tools such as:

  • Spring Initializer
  • Spring Tools Suits
  • Oscurecimiento
  • IntelliJ IDEA

All these tools are used by the developers to create the spring applications.

Since the Spring Initializer is a mostly used tool, we will start with this first and then we will discuss the other tools in our next articles.

We will use the Oscurecimiento for the development/coding. Oscurecimiento is an IDE that is primarily used to create the java-based applications.

If you are not sabido with Oscurecimiento, don’t worry because it’s a simple code editor. We will help you understand it in this article. To get it, visit the official site https://www.eclipse.org/downloads/ and install it to your tópico system.

Prerequisites:

Before starting further, make sure that you have the following tools installed in your tópico system:

  • Java must be installed in your system. Java 11 LTS or Java 17 LTS is recommended.
  • Oscurecimiento must be installed before starting as this is the main IDE/Editor.

Now, let’s get started in this step-by-step learning.

Step1: Open the Spring Initializer Tool

To open this tool, visit the https://start.spring.io/ URL. This is the official web-based tool provided by Spring itself to create the spring boot application.

At first glance, it looks like the following image:

It asks for a couple of options before creating the project. For example:

The first is project type which refers to what type of project you want to create. It gives two choices: either Maven or Gradle, which are basically the project dependency management tools.

We selected Maven and Java as the main programming language. After that, we selected the spring boot version. It shows all the available versions. We selected the version 2.7.1 which is one of the stable versions to start with.

Project Metadata comprises several steps:

Group: It is a name that should be unique and is used to group all the files. It follows the reverse domain name and the java package name concept.

Artifact: It is a sub-package name under the group name and used as a part of name of the JAR file while building the project.

Name: It is the name of the application that you wish to have.

Description: It is a short description of your project.

Packaging: It specifies the type of package for the application while building. JAR is used for creating libraries and plugins while WAR is used for building the Web Applications.

In our case, we selected JAR as we are not creating a web application.

Java Version: It specifies the Java version that will be used for creating the application. In our case, we used the Java 11.

Dependency: This specifies the dependencies that we want to include in our application such as Web, JDBC, Thymeleaf, etc.

Since we are just creating a simple application, it does not require any dependency for now. We will learn this more in our next articles while creating more functional applications.

Now, click on the GENERATE button to download this project.

Step 2: Extract the Application

After downloading the project, extract it first since the project is a zip file.

Step 3: Import Project to the Oscurecimiento

After extracting the zip project, open the desvanecimiento IDE and import this project. For this, just click on the “File” menu and select the import option like the following:

File -> Import -> Existing Maven Project -> Next -> Browse -> Select the project -> Finish

This opens a sub-window like in the following image. Choose the existing Maven project and click next.

Locate the location in the application folder and select it.

If all is good, it should look like the following image. Click on the finish button.

After importing, it takes a couple of minutes to set up the project and download all the project dependencies. If your computer network speed is good, it should load faster. Otherwise, have patience and wait for a while.

Step 4: Project the Explorer

After downloading all the dependencies, set up the project. It looks like the following:

This project contains some default files such as:

  • SpringbootappApplication.java
  • SpringbootappApplicationTests.java
  • Application.properties
  • Pom.xml

Let’s understand the uses of these files one by one.

// SpringbootApplication.java

This is the main application file that contains the main() method. This method calls the run() method to run the application.

This class uses the @SpringBootApplication which specifies this application as a spring boot application. This annotation is a combination of @EnableAutoConfiguration, @Configuration, and @ComponentScan annotations. We will learn more about these annotations in our next detailed articles.

package com.linuxhint.springbootapp;

import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication

public class SpringbootappApplication {

public static void main(String[] args) {

SpringApplication.run(SpringbootappApplication.class, args);

}

}

// pom.xml

This is another important file that is basically an XML file containing the entries of all the project dependencies and configurations.

Since we did not add any dependency while creating the project, it contains the default configurations and dependencies.

<?xml version=«1.0» encoding=«UTF-8»?>

<project xmlns=«http://maven.apache.org/POM/4.0.0» xmlns:xsi=«http://www.w3.org/2001/XMLSchema-instance»

xsi:schemaLocation=«http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd»>

<modelVersion>4.0.0</modelVersion>

<parent>

<groupId>org.springframework.boot</groupId>

<artifactId>springbootstarterparent</artifactId>

<version>2.7.1</version>

<relativePath/> <!– lookup parent from repository –>

</parent>

<groupId>com.linuxhint</groupId>

<artifactId>springbootapp</artifactId>

<version>0.0.1SNAPSHOT</version>

<name>springbootapp</name>

<description>this is a hello world application </description>

<properties>

<java.version>11</java.version>

</properties>

<dependencies>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>springbootstarter</artifactId>

</dependency>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>springbootstartertest</artifactId>

<scope>test</scope>

</dependency>

</dependencies>

<build>

<plugins>

<plugin>

<groupId>org.springframework.boot</groupId>

<artifactId>springbootmavenplugin</artifactId>

</plugin>

</plugins>

</build>

</project>

// application.poperties

This file is used to set the total properties for the application such as database connection, server port number, view files path, etc. Initially, this file is empty.

// SpringbootappApplicationTests.java

This file is used to create the test cases for testing the application by using the Junit library. Initially, it does not have any test case.

package com.linuxhint.springbootapp;

import org.junit.jupiter.api.Test;

import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest

class SpringbootappApplicationTests {

@Test

void contextLoads() {

}

}

Step 5: Run the Application

Now, let’s run the application by selecting the main class (SpringbootappApplication.java). Right click, choose “run as” and then click the java application like this:

Right-click -> Run as -> Java application

It starts executing the code and you can see the output in the console.

You can see the status of the running application in the console tab which means that the application is started.

We have successfully created and run our first spring boot application.

Step 6: Display the Hello World Message

By default, the spring boot application does not display any message to the console.

If you wish to display a Hello World message to the console, simply update the main class by adding this print statement:

System.out.println(«Hello World!»);

The new updated file looks like this:

package com.linuxhint.springbootapp;

import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication

public class SpringbootappApplication {

public static void main(String[] args) {

SpringApplication.run(SpringbootappApplication.class, args);

System.out.println(«Hello World!»);

}

}

Run the application again and see the output console.

This time, it shows the Hello World message to the console.

Conclusion

This article comprises the steps for creating a simple spring boot application. We used the Spring Initializer tool and Oscurecimiento for editing and running the application. Spring boot uses its own in-built server to run the application, although we can set up an external server as well. In the following articles, we will learn to add more dependencies to the project to create a more functional and web-based applications.



Source link


This article will focus on the CSS counter property, which helps us adjust the content’s appearance based on its location on a webpage. For example, we can use a counter to automate the number of headings on the webpage. We can create our own named counters and modify the default list item by using the counter property and its related functions and properties, which are Counter-reset, Counter-Increment, Content, and Counter.

Example 01: Using the CSS Counter Property for Automatically Numbering Headings in an HTML File

In this example, we discuss the counter property, which automatically assigns a number to any element of the Hypertext Markup language. We will be numbering our headings in this example by using different functions of the counter property:

Text Description automatically generated

We will start with the header of the file, where we will assign styling properties to the body and h2 tag of the file. For the body tag, we will be using the counter reset function. For the h2 tag, we will use the counter increment property and the content property, which will assign the counter-generated numbers to the h2 tag in the body.

After this, we will open the body tag in which we will provide a title to the page by using the h1 tag. Then we will add multiple h2 tags with the styling properties defined in the styling tag. We have a list of people’s names and their employees’ IDs, which need to be auto-increased when a new name is added to the list. We have added a pretext using content property, i.e., “Employee ID:” and then use the counter to increment the value. Next, we will close all the remaining tags to end the file and open it on our browser to view the styling properties.

Text Description automatically generated

In the previous snippet, we can see the employee id, which was the content we defined. The values are auto-increment through the counter, i.e., 1, 2, 3, 4, etc.

Example 02: Using the CSS Counter Property To Create Multiple Headings and Subheadings With Hierarchical Numbers

In this example, we will number our headings and subheadings utilizing various functionalities of the counter property. In this example, we will look at the counter property, which assigns a number to any element in the Hypertext Markup language.

Text Description automatically generated with medium confidence

In this script, we will implement the concept of the nested counter. First, we will define the counter in the body style class, named “Section.” Here, we defined two counter names, Section and Subsection, respectively. As we have a list of headings and subheadings, we reset both counters for the specific elements. Now, we will extend the h1 and h2 styling class with the before state. In this part of the class, we will define the content adjustment for the heading and subheading by using the counter increment and content properties. Then, we will add the heading and subheading using the h1 and h2 tags, respectively. We will be creating two sections with separate headings and subheadings. Then, we will close the tags and end the file to save it in the “.html” format so that we can open it in our browser.

Text Description automatically generated

In the previous output, we can see that the two sections have different numbering as defined in the styling class of the file. The heading number increases as well as the subheadings’ number, which is reset to one when they are called to another section.

Example 03: Creating a Number Ordered List Using the CSS Counter Property in an HTML File

In this example, we will create an ordered list that will be numbered using the counter property and its related functions, dividing the list into different sections with predefined numbers per the change of section.

Text Description automatically generated with medium confidence

In this script, we will be adding the styling classes initially as we are opting for the style tag CSS method. The style tag will first have the “ol” tag for providing styling properties. In this class, we will start with the counter reset function, which will be set to the section function. Then we will add the list style type property, which can be used to add any predefined style or the default view of the list. We will only add styling properties to this tag’s “before” state. In this section, we will add the counter-increment property, which will be set to the section function, and define the content property with the counter function having the content added as the suheadings’ parameter. This part of the style tag will assign the correct set of numbers with several subheadings and sub-subheadings. Then we will create an ordered list with five different sections using the ol and li tags.

Text, letter Description automatically generated

As we can see in the previous snippet, the headings, subheadings, and sub-subheadings are perfectly organized with a distinct set of numbers concerning their respective section and are distinct from other sections simultaneously.

Example 04: Creating a Dynamic Page List Using the CSS Counter Property in an HTML File

We will create a dynamic page list using the CSS counter property in this example. We will assign the page list numbers, adapted to the flow change on page traversal on our webpage. The style tag approach for CSS will be utilized in this example:

Text, letter Description automatically generated

The previous script is an example of a list with dynamic paging through counters. In the ul tag of the styling class, we will reset the counter for the paginate counter. Then, we will create a styling class collectively for the ul and li tags where we will give it design properties by adding padding, color, and margin, giving it a solid border, cursor pointer, and the floating property. After this, we will move to the next and previous state of the ul and li tags in the same class, where we will add the counter-increment property, which will be set to the paginate counter. We will also define the content property with the paginate counter function having the content to be added as the parameter. After this, we will create a list in the file’s body using the li and ul tags. The first li tag will have the previous class as the styling properties guide, while the last li tag will have the following class as the styling properties guide, and the rest will be empty.

Icon Description automatically generated

We can see the list is created in an ordered series of numbers with an incremental state along with the next and previous buttons and the stylings as defined in the styling tag.

Conclusion

In this article, we discussed the several functions of the CSS counter property in the Hypertext Markup language. The CSS counter property is used to assign numbers to any element dynamically. With the help of its related functions, we can swirl around the labeling changes in the heading according to the section. The counter increment and counter reset are the most common functions when assigning numbers to an element. We implemented the CSS counter property and its related functions in different scenarios in the Notepad++ environment.



Source link


This article will discuss using the CSS delay property in HTML. The delay property is used as a subpart for two different properties, which are transition and animation properties. In both properties, the element upon which are assigned undergoes some transformation. During this transformation, the delay property can be used to halt the transformation for a certain period. Now, we will implement several examples for this property.

Example 1: Transition Delay on a div Widthwise Using the Style Tag Approach

In this example, we will use the delay property to transition a div element width-wise using the style tag approach. The transition-delay property will be applied on a div, and the transition will happen at the div’s width.

In this script, we will begin with the header of the file. We will open the style tag and create a styling class for the div element in this tag. In this styling class, we will add height and width for the default size of the div. After this, we will add the transition property on the width by using it as a keyword. Then, we will define the transition duration in seconds. At the end of this tag, we will also define the transition delay constraint by giving it a value in seconds.

After this, we will inherit this class for a hover function in which we will add the width property, which would be increased from the previous setting and activated when the div is hovered. This change in width will be administered by the transition properties, including the transition-delay property, which will decide the time gap for this transition. Then, we will end the styling properties and close the style tag to move toward the file’s body. We will give the page a heading in the body tag by using the h1 tag. After this, we will add a div element by a div tag where we will not add any value because it is all defined in the style tag in the file’s header.

Shape, square Description automatically generated

Shape, rectangle Description automatically generated

The first snippet shows that the div is in its default stage. After hovering on the div, the transition will happen according to the properties defined in the style tag that can be observed in the second snippet.

Example 2: Transition Delay on a div Height-Wise Using the Style Tag Approach

In this example, we’ll use the delay attribute to transition a div element vertically using the style tag technique.

Text, letter Description automatically generated

We’ll start with the file’s header in this script. We will open the style tag in this tag and build a styling class for the div element. In this style class, we will add height and width for the div’s default size. Following that, we’ll use a keyword to add the transition attribute to the height of a div. Then, after this tag, we will define the transition time in seconds and the transition delay constraint by providing it with a value in seconds. We will inherit this class for a hover function and add the height property, which will be increased from the previous value and activated when the div has hovered. This change in height will be managed by the transition properties, which include the transition-delay property and determines the time gap for this transition.

After that, we will add a div element with a div tag in the body. The file will then be closed by closing all the tags.

A picture containing text Description automatically generated

Chart, bar chart Description automatically generated

The first output shows that the div is in its default state. When we hover over it, the transition occurs according to the properties provided in the style tag, displayed in the second output.

Example 3: Animation Delay on a div’s Top Side Using the Style Tag Approach

In this example, we’ll utilize the delay property while employing the style tag approach to animate a div element from the top side.

Text, letter Description automatically generated

In this script, we’ll begin with the file’s header. We’ll open the style tag and create a styling class for the div element in this tag. We will add height and width for the div default size in this style class. Following that, we’ll use a keyword to add the div’s animation property. Then, at the end of this tag, we’ll provide the animation time in seconds and the transition delay restriction by supplying a value in seconds. We’ll make a new class for the animation and add a size property for the top side of the div that will be increased from the previous value and active after the delay period.

The transition properties will control the animation, including the animation-delay property, which controls the time gap before the animation begins. The styling attributes will then be removed, and the style tag will be closed, enabling us to go on to the file’s body. We’ll add a div element with a div tag but no value because everything is defined in the file’s style tag.

Shape Description automatically generated with medium confidence

A picture containing shape Description automatically generated

The first output shows that the div is in its default position. When the animation-delay time finishes, the animation occurs according to the properties provided in the style tag, as seen in the second output.

Example 4: Animation Delay on a div’s Left Side Using the Style Tag Approach

In this example, we’ll use the delay attribute in conjunction with the style tag method to animate a div element from the left side.

Text, letter Description automatically generated

In this script, we’ll begin with the file’s header. We’ll open the style tag and create a styling class for the div element in this tag. We will add height and width for the div default size in this style class. Following that, we’ll use a keyword to add the div’s animation property. Then, at the end of this tag, we’ll provide the animation time in seconds and the transition delay restriction by supplying a value in seconds.

We’ll make a new class for the animation and add a size property for the top side of the div that will be increased from the previous value and active after the delay period. The transition properties will control the animation, including the animation-delay property, which controls the time gap before the animation begins. The styling attributes will then be removed, and the style tag will be closed, enabling us to go on to the file’s body. We’ll add a div element with a div tag but no value because everything is defined in the file’s style tag.

Shape, square Description automatically generated

Shape, square Description automatically generated

The div is in its default position, as shown in the first result. After the animation-delay timer expires, the animation happens according to the parameters specified in the style tag, as seen in the second output.

Conclusion

In this article, we have discussed using the CSS’s delay property in the Hypertext Markup language. The delay property is commonly used with CSS’s transition and animation property. This property is used as a sub-property for the animation and transition property, which helps define the individual property’s delay. We implemented these properties with the delay property as a sub-property in the Notepad++ environment.



Source link